{"id":"JammTk1qM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/introduction/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Introduction","summary":"What jComponent is, the ideas it is built on and what the library file contains.","markdown":"---\ntitle: Introduction\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/introduction/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Introduction\n\n> What jComponent is, the ideas it is built on and what the library file contains.\n\njComponent is the client-side UI library of Total.js. You build a page from reusable components and plain HTML elements, and all of them read and write one shared data model. When a value in the model changes, everything that depends on it updates by itself.\n\nThere is no build step. You load one JavaScript file and one stylesheet, and the page works.\n\n## A first look\n\nThis page shows one value in two places. A component formats it, and a `<ui-bind>` element prints it as it is.\n\n```html\n<ui-component name=\"greeting\" path=\"visitor.name\" config=\"prefix:Hello\"></ui-component>\n<p>Stored value: <ui-bind path=\"visitor.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('greeting', 'prefix:Hi', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.prefix + ', ' + value + '!');\n\t\t};\n\t});\n\n\tSET('visitor.name', 'Ana');\n</script>\n```\n\nThe page renders `Hello, Ana!` and `Stored value: Ana`. Calling `SET('visitor.name', 'Ben')` later changes both to the new name. Neither the component nor the element knows about the other: they only share the path `visitor.name`.\n\n## The main ideas\n\n| Idea | What it does | Guide |\n| --- | --- | --- |\n| Paths | Name a place in the data model, such as `order.address.city`. | [Paths](../paths/) |\n| Flags | Change how a read or a write behaves, such as `SET('price @nowatch', 5)`. | [Flags and path modifiers](../flags/) |\n| Data binding | Connects HTML elements to paths without writing JavaScript. | [Data binding](../data-binding/) |\n| Scopes | Give a part of the page its own base path. | [Scopes](../scopes/) |\n| Virtual bindings | Render detached HTML and lists from a private model. | [Virtual bindings](../virtual-bindings/) |\n| Components | Reusable UI pieces with their own behaviour. | [Using components](../using-components/), [Creating components](../creating-components/) |\n\n## What the library file contains\n\nThe file `spa.min@19.js` is self-contained. Besides jComponent it includes:\n\n- jQuery 3.6.0, available as `$`.\n- [Tangular](../tangular/), the template engine, with its `Thelpers` helpers.\n- [Routing](../routing/) for single-page applications, with `NAV`, `ROUTE` and `REDIRECT`.\n\nThe stylesheet `spa.min@19.css` contains the `.hidden` and `.invisible` classes that the binding commands `show`, `hide`, `visible` and `invisible` rely on, so load it on every page.\n\nThe value of `MAIN.version` is the number of the running release, `19.194`.\n\n## Where to go next\n\nFollow [Getting started](../getting-started/) to build a working page with bound data and your own component.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTk1qM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/introduction/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Einführung","summary":"Was jComponent ist, auf welchen Ideen es aufbaut und was die Bibliotheksdatei enthält.","markdown":"---\ntitle: \"Einführung\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/introduction/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Einführung\n\n> Was jComponent ist, auf welchen Ideen es aufbaut und was die Bibliotheksdatei enthält.\n\njComponent ist die clientseitige UI-Bibliothek von Total.js. Du baust eine Seite aus wiederverwendbaren Komponenten und einfachen HTML-Elementen auf, und alle lesen und schreiben ein gemeinsames Datenmodell. Ändert sich ein Wert im Modell, aktualisiert sich alles, was davon abhängt, von selbst.\n\nEinen Build-Schritt gibt es nicht. Du lädst eine JavaScript-Datei und ein Stylesheet, und die Seite funktioniert.\n\n## Ein erster Blick\n\nDiese Seite zeigt einen Wert an zwei Stellen. Eine Komponente formatiert ihn, und ein `<ui-bind>`-Element gibt ihn unverändert aus.\n\n```html\n<ui-component name=\"greeting\" path=\"visitor.name\" config=\"prefix:Hello\"></ui-component>\n<p>Stored value: <ui-bind path=\"visitor.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('greeting', 'prefix:Hi', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.prefix + ', ' + value + '!');\n\t\t};\n\t});\n\n\tSET('visitor.name', 'Ana');\n</script>\n```\n\nDie Seite rendert `Hello, Ana!` und `Stored value: Ana`. Ein späterer Aufruf von `SET('visitor.name', 'Ben')` ändert beide auf den neuen Namen. Die Komponente und das Element wissen nichts voneinander: Beide teilen sich nur den Path `visitor.name`.\n\n## Die wichtigsten Ideen\n\n| Idee | Was sie bewirkt | Anleitung |\n| --- | --- | --- |\n| Paths | Benennen eine Stelle im Datenmodell, etwa `order.address.city`. | [Paths](../paths/) |\n| Flags | Ändern das Verhalten eines Lese- oder Schreibvorgangs, etwa `SET('price @nowatch', 5)`. | [Flags und Path-Modifikatoren](../flags/) |\n| Datenbindung | Verbindet HTML-Elemente mit Paths, ohne dass du JavaScript schreibst. | [Datenbindung](../data-binding/) |\n| Scopes | Geben einem Teil der Seite einen eigenen Basis-Path. | [Scopes](../scopes/) |\n| Virtuelle Bindungen | Rendern losgelöstes HTML und Listen aus einem privaten Modell. | [Virtuelle Bindungen](../virtual-bindings/) |\n| Komponenten | Wiederverwendbare UI-Bausteine mit eigenem Verhalten. | [Komponenten verwenden](../using-components/), [Komponenten erstellen](../creating-components/) |\n\n## Was die Bibliotheksdatei enthält\n\nDie Datei `spa.min@19.js` ist in sich geschlossen. Neben jComponent enthält sie:\n\n- jQuery 3.6.0, verfügbar als `$`.\n- [Tangular](../tangular/), die Template-Engine, mit ihren `Thelpers`-Helpern.\n- [Routing](../routing/) für Single-Page-Anwendungen, mit `NAV`, `ROUTE` und `REDIRECT`.\n\nDas Stylesheet `spa.min@19.css` enthält die Klassen `.hidden` und `.invisible`, auf die sich die Bindungsbefehle `show`, `hide`, `visible` und `invisible` stützen. Lade es also auf jeder Seite.\n\nDer Wert von `MAIN.version` ist die Nummer des laufenden Releases, `19.194`.\n\n## Wie es weitergeht\n\nFolge [Erste Schritte](../getting-started/), um eine funktionierende Seite mit gebundenen Daten und deiner eigenen Komponente zu bauen.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTk1qM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/introduction/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Introducción","summary":"Qué es jComponent, las ideas en las que se basa y qué contiene el archivo de la biblioteca.","markdown":"---\ntitle: \"Introducción\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/introduction/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Introducción\n\n> Qué es jComponent, las ideas en las que se basa y qué contiene el archivo de la biblioteca.\n\njComponent es la biblioteca de interfaz de usuario del lado del cliente de Total.js. Construyes una página con componentes reutilizables y elementos HTML normales, y todos ellos leen y escriben en un único modelo de datos compartido. Cuando cambia un valor del modelo, todo lo que depende de él se actualiza solo.\n\nNo hay paso de compilación. Cargas un archivo JavaScript y una hoja de estilos, y la página funciona.\n\n## Un primer vistazo\n\nEsta página muestra un valor en dos lugares. Un componente le da formato y un elemento `<ui-bind>` lo imprime tal cual.\n\n```html\n<ui-component name=\"greeting\" path=\"visitor.name\" config=\"prefix:Hello\"></ui-component>\n<p>Stored value: <ui-bind path=\"visitor.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('greeting', 'prefix:Hi', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.prefix + ', ' + value + '!');\n\t\t};\n\t});\n\n\tSET('visitor.name', 'Ana');\n</script>\n```\n\nLa página renderiza `Hello, Ana!` y `Stored value: Ana`. Si después llamas a `SET('visitor.name', 'Ben')`, ambos cambian al nuevo nombre. Ni el componente ni el elemento saben nada el uno del otro: solo comparten el path `visitor.name`.\n\n## Las ideas principales\n\n| Idea | Qué hace | Guía |\n| --- | --- | --- |\n| Paths | Dan nombre a un lugar del modelo de datos, como `order.address.city`. | [Paths](../paths/) |\n| Flags | Cambian el comportamiento de una lectura o una escritura, como `SET('price @nowatch', 5)`. | [Flags y modificadores de path](../flags/) |\n| Enlace de datos | Conecta elementos HTML con paths sin escribir JavaScript. | [Enlace de datos](../data-binding/) |\n| Scopes | Dan a una parte de la página su propio path base. | [Scopes](../scopes/) |\n| Enlaces virtuales | Renderizan HTML desconectado y listas a partir de un modelo privado. | [Enlaces virtuales](../virtual-bindings/) |\n| Componentes | Piezas de interfaz reutilizables con su propio comportamiento. | [Usar componentes](../using-components/), [Crear componentes](../creating-components/) |\n\n## Qué contiene el archivo de la biblioteca\n\nEl archivo `spa.min@19.js` es autónomo. Además de jComponent, incluye:\n\n- jQuery 3.6.0, disponible como `$`.\n- [Tangular](../tangular/), el motor de plantillas, con sus helpers `Thelpers`.\n- [Enrutamiento](../routing/) para aplicaciones de una sola página, con `NAV`, `ROUTE` y `REDIRECT`.\n\nLa hoja de estilos `spa.min@19.css` contiene las clases `.hidden` e `.invisible` de las que dependen los comandos de enlace `show`, `hide`, `visible` e `invisible`, así que cárgala en todas las páginas.\n\nEl valor de `MAIN.version` es el número de la versión en ejecución, `19.194`.\n\n## Por dónde seguir\n\nSigue [Primeros pasos](../getting-started/) para construir una página funcional con datos enlazados y tu propio componente.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTk1qM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/introduction/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Introduction","summary":"Ce qu'est jComponent, les idées sur lesquelles il repose et ce que contient le fichier de la bibliothèque.","markdown":"---\ntitle: Introduction\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/introduction/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Introduction\n\n> Ce qu'est jComponent, les idées sur lesquelles il repose et ce que contient le fichier de la bibliothèque.\n\njComponent est la bibliothèque d'interface côté client de Total.js. Tu construis une page à partir de composants réutilisables et d'éléments HTML simples, qui lisent et écrivent tous dans un même modèle de données partagé. Quand une valeur du modèle de données change, tout ce qui en dépend se met à jour tout seul.\n\nAucune étape de build n'est nécessaire. Tu charges un fichier JavaScript et une feuille de style, et la page fonctionne.\n\n## Un premier aperçu\n\nCette page affiche une même valeur à deux endroits. Un composant la formate, et un élément `<ui-bind>` l'affiche telle quelle.\n\n```html\n<ui-component name=\"greeting\" path=\"visitor.name\" config=\"prefix:Hello\"></ui-component>\n<p>Stored value: <ui-bind path=\"visitor.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('greeting', 'prefix:Hi', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.prefix + ', ' + value + '!');\n\t\t};\n\t});\n\n\tSET('visitor.name', 'Ana');\n</script>\n```\n\nLa page affiche `Hello, Ana!` et `Stored value: Ana`. Appeler ensuite `SET('visitor.name', 'Ben')` remplace le nom aux deux endroits. Ni le composant ni l'élément ne se connaissent : ils partagent seulement le path `visitor.name`.\n\n## Les idées principales\n\n| Idée | Ce qu'elle fait | Guide |\n| --- | --- | --- |\n| Paths | Nomment un emplacement du modèle de données, comme `order.address.city`. | [Paths](../paths/) |\n| Flags | Modifient le comportement d'une lecture ou d'une écriture, comme `SET('price @nowatch', 5)`. | [Flags et modificateurs de path](../flags/) |\n| Liaison de données | Connecte des éléments HTML à des paths sans écrire de JavaScript. | [Liaison de données](../data-binding/) |\n| Scopes | Donnent à une partie de la page son propre path de base. | [Scopes](../scopes/) |\n| Liaisons virtuelles | Affichent du HTML détaché et des listes à partir d'un modèle de données privé. | [Liaisons virtuelles](../virtual-bindings/) |\n| Composants | Des éléments d'interface réutilisables dotés de leur propre comportement. | [Utiliser les composants](../using-components/), [Créer des composants](../creating-components/) |\n\n## Ce que contient le fichier de la bibliothèque\n\nLe fichier `spa.min@19.js` est autonome. En plus de jComponent, il inclut :\n\n- jQuery 3.6.0, disponible sous le nom `$`.\n- [Tangular](../tangular/), le moteur de modèles, avec ses helpers `Thelpers`.\n- Le [routage](../routing/) pour les applications monopages, avec `NAV`, `ROUTE` et `REDIRECT`.\n\nLa feuille de style `spa.min@19.css` contient les classes `.hidden` et `.invisible` sur lesquelles s'appuient les commandes de liaison `show`, `hide`, `visible` et `invisible` : charge-la donc sur chaque page.\n\nLa valeur de `MAIN.version` est le numéro de la version en cours d'exécution, `19.194`.\n\n## Pour aller plus loin\n\nSuis le guide [Prise en main](../getting-started/) pour construire une page fonctionnelle avec des données liées et ton propre composant.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTk1qM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/introduction/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Introduzione","summary":"Che cos'è jComponent, le idee su cui si basa e che cosa contiene il file della libreria.","markdown":"---\ntitle: Introduzione\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/introduction/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Introduzione\n\n> Che cos'è jComponent, le idee su cui si basa e che cosa contiene il file della libreria.\n\njComponent è la libreria UI lato client di Total.js. Costruisci una pagina con componenti riutilizzabili ed elementi HTML semplici, e tutti leggono e scrivono un unico modello di dati condiviso. Quando un valore del modello cambia, tutto ciò che dipende da esso si aggiorna da solo.\n\nNon c'è nessuna fase di build. Carichi un file JavaScript e un foglio di stile, e la pagina funziona.\n\n## Un primo sguardo\n\nQuesta pagina mostra un valore in due punti. Un componente lo formatta e un elemento `<ui-bind>` lo stampa così com'è.\n\n```html\n<ui-component name=\"greeting\" path=\"visitor.name\" config=\"prefix:Hello\"></ui-component>\n<p>Stored value: <ui-bind path=\"visitor.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('greeting', 'prefix:Hi', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.prefix + ', ' + value + '!');\n\t\t};\n\t});\n\n\tSET('visitor.name', 'Ana');\n</script>\n```\n\nLa pagina renderizza `Hello, Ana!` e `Stored value: Ana`. Chiamando in seguito `SET('visitor.name', 'Ben')`, entrambi passano al nuovo nome. Né il componente né l'elemento sanno l'uno dell'altro: condividono soltanto il path `visitor.name`.\n\n## I concetti principali\n\n| Concetto | Che cosa fa | Guida |\n| --- | --- | --- |\n| Path | Assegnano un nome a un punto del modello di dati, come `order.address.city`. | [Path](../paths/) |\n| Flag | Cambiano il comportamento di una lettura o di una scrittura, come `SET('price @nowatch', 5)`. | [Flag e modificatori di path](../flags/) |\n| Associazione dei dati | Collega gli elementi HTML ai path senza scrivere JavaScript. | [Associazione dei dati](../data-binding/) |\n| Scope | Assegnano a una parte della pagina un proprio path di base. | [Scope](../scopes/) |\n| Associazioni virtuali | Renderizzano HTML staccato dalla pagina ed elenchi a partire da un modello privato. | [Associazioni virtuali](../virtual-bindings/) |\n| Componenti | Parti di interfaccia riutilizzabili con un proprio comportamento. | [Usare i componenti](../using-components/), [Creare componenti](../creating-components/) |\n\n## Che cosa contiene il file della libreria\n\nIl file `spa.min@19.js` è autonomo. Oltre a jComponent include:\n\n- jQuery 3.6.0, disponibile come `$`.\n- [Tangular](../tangular/), il motore di template, con i suoi helper `Thelpers`.\n- Il [routing](../routing/) per le applicazioni a pagina singola, con `NAV`, `ROUTE` e `REDIRECT`.\n\nIl foglio di stile `spa.min@19.css` contiene le classi `.hidden` e `.invisible` su cui si basano i comandi di associazione `show`, `hide`, `visible` e `invisible`, quindi caricalo in ogni pagina.\n\nIl valore di `MAIN.version` è il numero della release in esecuzione, `19.194`.\n\n## Come proseguire\n\nSegui [Primi passi](../getting-started/) per costruire una pagina funzionante con dati associati e un tuo componente.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTk1qM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/introduction/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Úvod","summary":"Čo je jComponent, na akých myšlienkach stojí a čo obsahuje súbor knižnice.","markdown":"---\ntitle: \"Úvod\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/introduction/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Úvod\n\n> Čo je jComponent, na akých myšlienkach stojí a čo obsahuje súbor knižnice.\n\njComponent je klientska knižnica UI pre Total.js. Stránku skladáš z opakovane použiteľných komponentov a obyčajných elementov HTML a všetky čítajú a zapisujú jeden spoločný dátový model. Keď sa hodnota v modeli zmení, všetko, čo od nej závisí, sa aktualizuje samo.\n\nNetreba žiadny krok zostavenia. Načítaš jeden súbor JavaScriptu a jeden súbor štýlov a stránka funguje.\n\n## Prvý pohľad\n\nTáto stránka zobrazuje jednu hodnotu na dvoch miestach. Komponent ju naformátuje a element `<ui-bind>` ju vypíše tak, ako je.\n\n```html\n<ui-component name=\"greeting\" path=\"visitor.name\" config=\"prefix:Hello\"></ui-component>\n<p>Stored value: <ui-bind path=\"visitor.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('greeting', 'prefix:Hi', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.prefix + ', ' + value + '!');\n\t\t};\n\t});\n\n\tSET('visitor.name', 'Ana');\n</script>\n```\n\nStránka vykreslí `Hello, Ana!` a `Stored value: Ana`. Neskoršie volanie `SET('visitor.name', 'Ben')` zmení obe na nové meno. Komponent ani element o sebe navzájom nevedia: zdieľajú iba path `visitor.name`.\n\n## Hlavné myšlienky\n\n| Myšlienka | Čo robí | Príručka |\n| --- | --- | --- |\n| Paths | Pomenúvajú miesto v dátovom modeli, napríklad `order.address.city`. | [Paths](../paths/) |\n| Flagy | Menia správanie čítania alebo zápisu, napríklad `SET('price @nowatch', 5)`. | [Flagy a modifikátory path](../flags/) |\n| Dátová väzba | Prepája elementy HTML s paths bez písania JavaScriptu. | [Dátová väzba](../data-binding/) |\n| Scopes | Dávajú časti stránky vlastný základný path. | [Scopes](../scopes/) |\n| Virtuálne väzby | Vykresľujú oddelené HTML a zoznamy zo súkromného modelu. | [Virtuálne väzby](../virtual-bindings/) |\n| Komponenty | Opakovane použiteľné časti UI s vlastným správaním. | [Používanie komponentov](../using-components/), [Vytváranie komponentov](../creating-components/) |\n\n## Čo obsahuje súbor knižnice\n\nSúbor `spa.min@19.js` je samostatný. Okrem jComponent obsahuje:\n\n- jQuery 3.6.0, dostupné ako `$`.\n- [Tangular](../tangular/), šablónovací engine, s jeho helpermi `Thelpers`.\n- [Smerovanie](../routing/) pre jednostránkové aplikácie s `NAV`, `ROUTE` a `REDIRECT`.\n\nSúbor štýlov `spa.min@19.css` obsahuje triedy `.hidden` a `.invisible`, na ktoré sa spoliehajú príkazy väzby `show`, `hide`, `visible` a `invisible`, preto ho načítaj na každej stránke.\n\nHodnota `MAIN.version` je číslo spusteného vydania, `19.194`.\n\n## Kam ďalej\n\nPokračuj časťou [Začíname](../getting-started/) a vytvor funkčnú stránku s naviazanými dátami a vlastným komponentom.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTe1mM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/getting-started/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Getting started","summary":"Build a working page with bound data and a custom component, starting from an empty HTML file.","markdown":"---\ntitle: Getting started\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/getting-started/\nupdated: 2026-11-18T18:15:26.748Z\n---\n\n# Getting started\n\n> Build a working page with bound data and a custom component, starting from an empty HTML file.\n\nThis guide takes you from an empty file to a page with bound data and two custom components. You only need a text editor and a browser.\n\n## Load the library\n\nCreate a file named `index.html` and load the script and the stylesheet in the `<head>`:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n</body>\n</html>\n```\n\nEvery snippet in the next steps goes inside `<body>`.\n\n## Show a value\n\nData lives at [paths](../paths/). `SET()` writes a value, and the `<ui-bind>` element displays it:\n\n```html\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('page.title', 'My first page');\n</script>\n```\n\nThe heading shows `My first page`. The `path` attribute says which value to read, and `config=\"text\"` says to write it as the text of the element. If you run `SET('page.title', 'Changed')` in the browser console, the heading changes immediately. [Data binding](../data-binding/) lists everything `<ui-bind>` can do.\n\n## Create a component\n\nA component is declared once with `COMPONENT()` and placed with `<ui-component>` as many times as you need. This one renders a labelled text box:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n- `'label:Text'` is the default configuration. The `config` attribute of the element overrides it.\n- `self.make` runs once and builds the content of the element.\n- `data-jc-bind` connects the input to the path of the component. Typing `Ana` into the box stores `{\"name\":\"Ana\"}` in `form`, and writing to `form.name` updates the box.\n\n## Add behaviour\n\nComponents often need their own logic. The `counter` component below draws a button and writes to its path through `self.set()`. Its `self.setter` function runs each time the value at the path changes, so the screen always follows the data.\n\n```html\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<script>\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n</script>\n```\n\n## The complete page\n\nPut everything together. This is the whole file:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<p data-bind=\"form.name__show:value\">\n\t<ui-bind path=\"form\" config=\"text:value.name + ' booked ' + value.tickets + ' ticket(s)'\"></ui-bind>\n</p>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n\n\tSET('page.title', 'Book your tickets');\n\tSET('form', { name: '', tickets: 1 });\n</script>\n\n</body>\n</html>\n```\n\nOpen the file in a browser. The summary line stays hidden until you type a name, because `show:value` hides the paragraph while `form.name` is empty. If you type `Ana` and press the button twice, the page shows `Ana booked 3 ticket(s)`. The counter stops at `5`, the value of `max` in the `config` attribute.\n\n## Run code when the page is ready\n\nThe `ready` event fires once the components on the page are initialized. It needs at least one component on the page.\n\n```html\n<ui-component name=\"clock\"></ui-component>\n\n<script>\n\tCOMPONENT('clock', function(self) {\n\t\tself.make = function() {\n\t\t\tself.text('12:00');\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log('ready:', FIND('clock').element.text());   // ready: 12:00\n\t});\n</script>\n```\n\n## Next steps\n\n- Learn how values are addressed and who is notified of a change in [Paths](../paths/).\n- Connect more of your page with [Data binding](../data-binding/).\n- Give each part of the page its own data with [Scopes](../scopes/).\n- Go deeper into the component API in [Creating components](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:26.748Z"}
{"id":"JammTe1mM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/getting-started/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Erste Schritte","summary":"Baue ausgehend von einer leeren HTML-Datei eine funktionierende Seite mit gebundenen Daten und einer eigenen Komponente.","markdown":"---\ntitle: Erste Schritte\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/getting-started/\nupdated: 2026-11-18T18:15:26.748Z\n---\n\n# Erste Schritte\n\n> Baue ausgehend von einer leeren HTML-Datei eine funktionierende Seite mit gebundenen Daten und einer eigenen Komponente.\n\nDiese Anleitung führt dich von einer leeren Datei zu einer Seite mit gebundenen Daten und zwei eigenen Komponenten. Du brauchst nur einen Texteditor und einen Browser.\n\n## Bibliothek laden\n\nErstelle eine Datei namens `index.html` und lade das Skript und das Stylesheet im `<head>`:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n</body>\n</html>\n```\n\nJedes Snippet in den nächsten Schritten gehört in den `<body>`.\n\n## Wert anzeigen\n\nDaten liegen an [Paths](../paths/). `SET()` schreibt einen Wert, und das Element `<ui-bind>` zeigt ihn an:\n\n```html\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('page.title', 'My first page');\n</script>\n```\n\nDie Überschrift zeigt `My first page`. Das Attribut `path` gibt an, welcher Wert gelesen wird, und `config=\"text\"` legt fest, dass er als Text des Elements geschrieben wird. Wenn du in der Browserkonsole `SET('page.title', 'Changed')` ausführst, ändert sich die Überschrift sofort. [Datenbindung](../data-binding/) listet alles auf, was `<ui-bind>` kann.\n\n## Komponente erstellen\n\nEine Komponente wird einmal mit `COMPONENT()` deklariert und mit `<ui-component>` beliebig oft platziert. Diese hier rendert ein Textfeld mit Beschriftung:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n- `'label:Text'` ist die Standardkonfiguration. Das Attribut `config` des Elements überschreibt sie.\n- `self.make` läuft einmal und baut den Inhalt des Elements auf.\n- `data-jc-bind` verbindet das Eingabefeld mit dem Path der Komponente. Tippst du `Ana` in das Feld, wird `{\"name\":\"Ana\"}` in `form` gespeichert, und ein Schreibvorgang auf `form.name` aktualisiert das Feld.\n\n## Verhalten hinzufügen\n\nKomponenten brauchen oft eigene Logik. Die Komponente `counter` unten zeichnet einen Button und schreibt über `self.set()` an ihren Path. Die Funktion `self.setter` der Komponente läuft jedes Mal, wenn sich der Wert am Path ändert, sodass die Anzeige immer den Daten folgt.\n\n```html\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<script>\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n</script>\n```\n\n## Die vollständige Seite\n\nFüge alles zusammen. Das ist die gesamte Datei:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<p data-bind=\"form.name__show:value\">\n\t<ui-bind path=\"form\" config=\"text:value.name + ' booked ' + value.tickets + ' ticket(s)'\"></ui-bind>\n</p>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n\n\tSET('page.title', 'Book your tickets');\n\tSET('form', { name: '', tickets: 1 });\n</script>\n\n</body>\n</html>\n```\n\nÖffne die Datei in einem Browser. Die Zusammenfassung bleibt verborgen, bis du einen Namen eingibst, weil `show:value` den Absatz ausblendet, solange `form.name` leer ist. Wenn du `Ana` eingibst und den Button zweimal drückst, zeigt die Seite `Ana booked 3 ticket(s)`. Der Zähler stoppt bei `5`, dem Wert von `max` im Attribut `config`.\n\n## Code ausführen, wenn die Seite bereit ist\n\nDas Event `ready` wird ausgelöst, sobald die Komponenten auf der Seite initialisiert sind. Dafür muss mindestens eine Komponente auf der Seite vorhanden sein.\n\n```html\n<ui-component name=\"clock\"></ui-component>\n\n<script>\n\tCOMPONENT('clock', function(self) {\n\t\tself.make = function() {\n\t\t\tself.text('12:00');\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log('ready:', FIND('clock').element.text());   // ready: 12:00\n\t});\n</script>\n```\n\n## Nächste Schritte\n\n- Erfahre in [Paths](../paths/), wie Werte adressiert werden und wer über eine Änderung benachrichtigt wird.\n- Verbinde mit [Datenbindung](../data-binding/) weitere Teile deiner Seite.\n- Gib mit [Scopes](../scopes/) jedem Teil der Seite eigene Daten.\n- Vertiefe die API der Komponenten in [Komponenten erstellen](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:26.748Z"}
{"id":"JammTe1mM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/getting-started/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Primeros pasos","summary":"Construye una página funcional con datos enlazados y un componente personalizado, partiendo de un archivo HTML vacío.","markdown":"---\ntitle: Primeros pasos\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/getting-started/\nupdated: 2026-11-18T18:15:26.748Z\n---\n\n# Primeros pasos\n\n> Construye una página funcional con datos enlazados y un componente personalizado, partiendo de un archivo HTML vacío.\n\nEsta guía te lleva de un archivo vacío a una página con datos enlazados y dos componentes personalizados. Solo necesitas un editor de texto y un navegador.\n\n## Carga la biblioteca\n\nCrea un archivo llamado `index.html` y carga el script y la hoja de estilos en el `<head>`:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n</body>\n</html>\n```\n\nTodos los fragmentos de los pasos siguientes van dentro de `<body>`.\n\n## Muestra un valor\n\nLos datos viven en [paths](../paths/). `SET()` escribe un valor y el elemento `<ui-bind>` lo muestra:\n\n```html\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('page.title', 'My first page');\n</script>\n```\n\nEl encabezado muestra `My first page`. El atributo `path` indica qué valor se lee, y `config=\"text\"` indica que se escriba como texto del elemento. Si ejecutas `SET('page.title', 'Changed')` en la consola del navegador, el encabezado cambia de inmediato. [Enlace de datos](../data-binding/) enumera todo lo que puede hacer `<ui-bind>`.\n\n## Crea un componente\n\nUn componente se declara una vez con `COMPONENT()` y se coloca con `<ui-component>` tantas veces como necesites. Este renderiza un cuadro de texto con etiqueta:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n- `'label:Text'` es la configuración predeterminada. El atributo `config` del elemento la sobrescribe.\n- `self.make` se ejecuta una vez y construye el contenido del elemento.\n- `data-jc-bind` conecta el input con el path del componente. Al escribir `Ana` en el cuadro, se guarda `{\"name\":\"Ana\"}` en `form`, y al escribir en `form.name` se actualiza el cuadro.\n\n## Añade comportamiento\n\nLos componentes suelen necesitar su propia lógica. El componente `counter` siguiente dibuja un botón y escribe en su path mediante `self.set()`. Su función `self.setter` se ejecuta cada vez que cambia el valor del path, así que la pantalla siempre sigue a los datos.\n\n```html\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<script>\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n</script>\n```\n\n## La página completa\n\nJúntalo todo. Este es el archivo completo:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<p data-bind=\"form.name__show:value\">\n\t<ui-bind path=\"form\" config=\"text:value.name + ' booked ' + value.tickets + ' ticket(s)'\"></ui-bind>\n</p>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n\n\tSET('page.title', 'Book your tickets');\n\tSET('form', { name: '', tickets: 1 });\n</script>\n\n</body>\n</html>\n```\n\nAbre el archivo en un navegador. La línea de resumen permanece oculta hasta que escribes un nombre, porque `show:value` oculta el párrafo mientras `form.name` está vacío. Si escribes `Ana` y pulsas el botón dos veces, la página muestra `Ana booked 3 ticket(s)`. El contador se detiene en `5`, el valor de `max` en el atributo `config`.\n\n## Ejecuta código cuando la página esté lista\n\nEl evento `ready` se dispara cuando los componentes de la página están inicializados. Necesita al menos un componente en la página.\n\n```html\n<ui-component name=\"clock\"></ui-component>\n\n<script>\n\tCOMPONENT('clock', function(self) {\n\t\tself.make = function() {\n\t\t\tself.text('12:00');\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log('ready:', FIND('clock').element.text());   // ready: 12:00\n\t});\n</script>\n```\n\n## Siguientes pasos\n\n- Aprende cómo se direccionan los valores y a quién se notifica un cambio en [Paths](../paths/).\n- Conecta más partes de tu página con [Enlace de datos](../data-binding/).\n- Da a cada parte de la página sus propios datos con [Scopes](../scopes/).\n- Profundiza en la API de componentes en [Crear componentes](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:26.748Z"}
{"id":"JammTe1mM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/getting-started/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Premiers pas","summary":"Construis une page fonctionnelle avec des données liées et un composant personnalisé, à partir d'un fichier HTML vide.","markdown":"---\ntitle: Premiers pas\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/getting-started/\nupdated: 2026-11-18T18:15:26.748Z\n---\n\n# Premiers pas\n\n> Construis une page fonctionnelle avec des données liées et un composant personnalisé, à partir d'un fichier HTML vide.\n\nCe guide t'emmène d'un fichier vide à une page avec des données liées et deux composants personnalisés. Il te suffit d'un éditeur de texte et d'un navigateur.\n\n## Charger la bibliothèque\n\nCrée un fichier nommé `index.html` et charge le script et la feuille de style dans le `<head>` :\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n</body>\n</html>\n```\n\nChaque extrait des étapes suivantes se place dans `<body>`.\n\n## Afficher une valeur\n\nLes données se trouvent à des [paths](../paths/). `SET()` écrit une valeur, et l'élément `<ui-bind>` l'affiche :\n\n```html\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('page.title', 'My first page');\n</script>\n```\n\nLe titre affiche `My first page`. L'attribut `path` indique quelle valeur lire, et `config=\"text\"` demande de l'écrire comme texte de l'élément. Si tu exécutes `SET('page.title', 'Changed')` dans la console du navigateur, le titre change immédiatement. [Liaison de données](../data-binding/) liste tout ce que `<ui-bind>` peut faire.\n\n## Créer un composant\n\nUn composant se déclare une seule fois avec `COMPONENT()` et se place avec `<ui-component>` autant de fois que nécessaire. Celui-ci affiche une zone de texte avec un libellé :\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n- `'label:Text'` est la configuration par défaut. L'attribut `config` de l'élément la remplace.\n- `self.make` s'exécute une fois et construit le contenu de l'élément.\n- `data-jc-bind` connecte le champ de saisie au path du composant. Saisir `Ana` dans la zone stocke `{\"name\":\"Ana\"}` dans `form`, et écrire dans `form.name` met la zone à jour.\n\n## Ajouter un comportement\n\nLes composants ont souvent besoin de leur propre logique. Le composant `counter` ci-dessous dessine un bouton et écrit dans son path avec `self.set()`. Sa fonction `self.setter` s'exécute chaque fois que la valeur du path change : l'écran suit donc toujours les données.\n\n```html\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<script>\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n</script>\n```\n\n## La page complète\n\nAssemble le tout. Voici le fichier entier :\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<p data-bind=\"form.name__show:value\">\n\t<ui-bind path=\"form\" config=\"text:value.name + ' booked ' + value.tickets + ' ticket(s)'\"></ui-bind>\n</p>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n\n\tSET('page.title', 'Book your tickets');\n\tSET('form', { name: '', tickets: 1 });\n</script>\n\n</body>\n</html>\n```\n\nOuvre le fichier dans un navigateur. La ligne de résumé reste masquée jusqu'à ce que tu saisisses un nom, car `show:value` masque le paragraphe tant que `form.name` est vide. Si tu saisis `Ana` et que tu appuies deux fois sur le bouton, la page affiche `Ana booked 3 ticket(s)`. Le compteur s'arrête à `5`, la valeur de `max` dans l'attribut `config`.\n\n## Exécuter du code quand la page est prête\n\nL'événement `ready` se déclenche une fois les composants de la page initialisés. Il faut au moins un composant sur la page.\n\n```html\n<ui-component name=\"clock\"></ui-component>\n\n<script>\n\tCOMPONENT('clock', function(self) {\n\t\tself.make = function() {\n\t\t\tself.text('12:00');\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log('ready:', FIND('clock').element.text());   // ready: 12:00\n\t});\n</script>\n```\n\n## Prochaines étapes\n\n- Découvre comment les valeurs sont adressées et qui est notifié d'une modification dans [Paths](../paths/).\n- Connecte davantage ta page avec [Liaison de données](../data-binding/).\n- Donne à chaque partie de la page ses propres données avec [Scopes](../scopes/).\n- Approfondis l'API des composants dans [Créer des composants](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:26.748Z"}
{"id":"JammTe1mM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/getting-started/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Primi passi","summary":"Costruisci una pagina funzionante con dati associati e un componente personalizzato, partendo da un file HTML vuoto.","markdown":"---\ntitle: Primi passi\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/getting-started/\nupdated: 2026-11-18T18:15:26.748Z\n---\n\n# Primi passi\n\n> Costruisci una pagina funzionante con dati associati e un componente personalizzato, partendo da un file HTML vuoto.\n\nQuesta guida ti accompagna da un file vuoto a una pagina con dati associati e due componenti personalizzati. Ti servono solo un editor di testo e un browser.\n\n## Carica la libreria\n\nCrea un file chiamato `index.html` e carica lo script e il foglio di stile nel `<head>`:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n</body>\n</html>\n```\n\nOgni frammento dei passaggi successivi va inserito in `<body>`.\n\n## Mostra un valore\n\nI dati risiedono nei [path](../paths/). `SET()` scrive un valore e l'elemento `<ui-bind>` lo visualizza:\n\n```html\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('page.title', 'My first page');\n</script>\n```\n\nIl titolo mostra `My first page`. L'attributo `path` indica quale valore leggere, e `config=\"text\"` indica di scriverlo come testo dell'elemento. Se esegui `SET('page.title', 'Changed')` nella console del browser, il titolo cambia immediatamente. [Associazione dei dati](../data-binding/) elenca tutto ciò che `<ui-bind>` può fare.\n\n## Crea un componente\n\nUn componente si dichiara una sola volta con `COMPONENT()` e si inserisce con `<ui-component>` tutte le volte che ti serve. Questo renderizza una casella di testo con un'etichetta:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n- `'label:Text'` è la configurazione predefinita. L'attributo `config` dell'elemento la sovrascrive.\n- `self.make` viene eseguito una sola volta e costruisce il contenuto dell'elemento.\n- `data-jc-bind` collega l'input al path del componente. Digitando `Ana` nella casella, `{\"name\":\"Ana\"}` viene memorizzato in `form`, e scrivendo in `form.name` la casella si aggiorna.\n\n## Aggiungi un comportamento\n\nSpesso i componenti hanno bisogno di una propria logica. Il componente `counter` qui sotto disegna un pulsante e scrive nel proprio path tramite `self.set()`. La sua funzione `self.setter` viene eseguita ogni volta che cambia il valore nel path, quindi lo schermo segue sempre i dati.\n\n```html\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<script>\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n</script>\n```\n\n## La pagina completa\n\nMetti insieme tutti i pezzi. Questo è il file completo:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<p data-bind=\"form.name__show:value\">\n\t<ui-bind path=\"form\" config=\"text:value.name + ' booked ' + value.tickets + ' ticket(s)'\"></ui-bind>\n</p>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n\n\tSET('page.title', 'Book your tickets');\n\tSET('form', { name: '', tickets: 1 });\n</script>\n\n</body>\n</html>\n```\n\nApri il file in un browser. La riga di riepilogo resta nascosta finché non digiti un nome, perché `show:value` nasconde il paragrafo mentre `form.name` è vuoto. Se digiti `Ana` e premi il pulsante due volte, la pagina mostra `Ana booked 3 ticket(s)`. Il contatore si ferma a `5`, il valore di `max` nell'attributo `config`.\n\n## Esegui codice quando la pagina è pronta\n\nL'evento `ready` scatta quando i componenti della pagina sono inizializzati. Richiede almeno un componente nella pagina.\n\n```html\n<ui-component name=\"clock\"></ui-component>\n\n<script>\n\tCOMPONENT('clock', function(self) {\n\t\tself.make = function() {\n\t\t\tself.text('12:00');\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log('ready:', FIND('clock').element.text());   // ready: 12:00\n\t});\n</script>\n```\n\n## Prossimi passi\n\n- Scopri in [Path](../paths/) come vengono indirizzati i valori e chi riceve la notifica di una modifica.\n- Collega altre parti della tua pagina con [Associazione dei dati](../data-binding/).\n- Assegna a ogni parte della pagina i propri dati con [Scope](../scopes/).\n- Approfondisci l'API dei componenti in [Creare componenti](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:26.748Z"}
{"id":"JammTe1mM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/getting-started/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Začíname","summary":"Vytvor funkčnú stránku s naviazanými dátami a vlastným komponentom, počnúc prázdnym súborom HTML.","markdown":"---\ntitle: \"Začíname\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/getting-started/\nupdated: 2026-11-18T18:15:26.748Z\n---\n\n# Začíname\n\n> Vytvor funkčnú stránku s naviazanými dátami a vlastným komponentom, počnúc prázdnym súborom HTML.\n\nTáto príručka ťa prevedie od prázdneho súboru k stránke s naviazanými dátami a dvoma vlastnými komponentmi. Stačí ti textový editor a prehliadač.\n\n## Načítaj knižnicu\n\nVytvor súbor s názvom `index.html` a v `<head>` načítaj skript a súbor štýlov:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n</body>\n</html>\n```\n\nKaždá ukážka v ďalších krokoch patrí do `<body>`.\n\n## Zobraz hodnotu\n\nDáta sa nachádzajú na [paths](../paths/). `SET()` zapíše hodnotu a element `<ui-bind>` ju zobrazí:\n\n```html\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('page.title', 'My first page');\n</script>\n```\n\nNadpis zobrazí `My first page`. Atribút `path` určuje, ktorá hodnota sa má prečítať, a `config=\"text\"` hovorí, že sa má zapísať ako text elementu. Ak v konzole prehliadača spustíš `SET('page.title', 'Changed')`, nadpis sa okamžite zmení. Všetko, čo `<ui-bind>` dokáže, uvádza časť [Dátová väzba](../data-binding/).\n\n## Vytvor komponent\n\nKomponent deklaruješ raz pomocou `COMPONENT()` a pomocou `<ui-component>` ho umiestniš toľkokrát, koľkokrát potrebuješ. Tento vykreslí textové pole s popisom:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n- `'label:Text'` je predvolená konfigurácia. Atribút `config` elementu ju prepíše.\n- `self.make` sa spustí raz a vytvorí obsah elementu.\n- `data-jc-bind` prepojí vstupné pole s path komponentu. Keď do poľa napíšeš `Ana`, do `form` sa uloží `{\"name\":\"Ana\"}` a zápis do `form.name` aktualizuje pole.\n\n## Pridaj správanie\n\nKomponenty často potrebujú vlastnú logiku. Komponent `counter` nižšie nakreslí tlačidlo a zapisuje na svoj path pomocou `self.set()`. Jeho funkcia `self.setter` sa spustí pri každej zmene hodnoty na path, takže obrazovka vždy nasleduje dáta.\n\n```html\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<script>\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n</script>\n```\n\n## Celá stránka\n\nSpoj všetko dohromady. Toto je celý súbor:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<title>My first page</title>\n\t<script src=\"https://cdn.componentator.com/spa.min@19.js\"></script>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@19.css\" />\n</head>\n<body>\n\n<h1><ui-bind path=\"page.title\" config=\"text\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Your name\"></ui-component>\n<ui-component name=\"counter\" path=\"form.tickets\" config=\"max:5\"></ui-component>\n\n<p data-bind=\"form.name__show:value\">\n\t<ui-bind path=\"form\" config=\"text:value.name + ' booked ' + value.tickets + ' ticket(s)'\"></ui-bind>\n</p>\n\n<script>\n\tCOMPONENT('textbox', 'label:Text', function(self, config) {\n\t\tself.make = function() {\n\t\t\tself.html('<label>' + config.label + '</label> <input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tCOMPONENT('counter', 'max:10', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button type=\"button\">+1</button> <b></b>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar value = self.get() || 0;\n\t\t\t\tif (value < config.max)\n\t\t\t\t\tself.set(value + 1);\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('b').text(value || 0);\n\t\t};\n\t});\n\n\tSET('page.title', 'Book your tickets');\n\tSET('form', { name: '', tickets: 1 });\n</script>\n\n</body>\n</html>\n```\n\nOtvor súbor v prehliadači. Súhrnný riadok zostane skrytý, kým nezadáš meno, pretože `show:value` skrýva odsek, kým je `form.name` prázdne. Ak napíšeš `Ana` a dvakrát stlačíš tlačidlo, stránka zobrazí `Ana booked 3 ticket(s)`. Počítadlo sa zastaví na `5`, čo je hodnota `max` v atribúte `config`.\n\n## Spusti kód, keď je stránka pripravená\n\nUdalosť `ready` sa spustí, keď sú komponenty na stránke inicializované. Na stránke musí byť aspoň jeden komponent.\n\n```html\n<ui-component name=\"clock\"></ui-component>\n\n<script>\n\tCOMPONENT('clock', function(self) {\n\t\tself.make = function() {\n\t\t\tself.text('12:00');\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log('ready:', FIND('clock').element.text());   // ready: 12:00\n\t});\n</script>\n```\n\n## Ďalšie kroky\n\n- V časti [Paths](../paths/) sa dozvieš, ako sa hodnoty adresujú a kto dostane upozornenie o zmene.\n- Prepoj ďalšie časti stránky pomocou [Dátovej väzby](../data-binding/).\n- Daj každej časti stránky vlastné dáta pomocou [Scopes](../scopes/).\n- Ponor sa hlbšie do API komponentov v časti [Vytváranie komponentov](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:26.748Z"}
{"id":"JammTu1wM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/paths/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Paths","summary":"How paths address values in the data model, how to read and write them, and who is notified of a change.","markdown":"---\ntitle: Paths\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/paths/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Paths\n\n> How paths address values in the data model, how to read and write them, and who is notified of a change.\n\nA path is a string that names a place in the data model, such as `order.address.city`. Components, bindings and your own code all use paths to share data. By default a path starts at the `window` object, so `order.address.city` is the same value as `window.order.address.city`.\n\n## Read and write values\n\n[SET()](../../reference/globals/) writes a value and [GET()](../../reference/globals/) reads it. Missing objects and arrays on the way are created for you, and reading a path that does not exist returns `undefined` without an error.\n\n```js\nSET('shop.cart.total', 120);\nconsole.log(window.shop);\t\t\t  // {\"cart\":{\"total\":120}}\nconsole.log(GET('shop.cart.total'));   // 120\nconsole.log(GET('shop.order.total'));  // undefined\n\nSET('shop.items[1].name', 'Keyboard');\nconsole.log(shop.items);\t\t\t   // [null,{\"name\":\"Keyboard\"}]\n```\n\n## Helpers for common changes\n\nThese functions change a value and notify everything that depends on it:\n\n```js\nSET('cart', { count: 1, items: [], open: false, note: 'gift' });\n\nINC('cart.count');\t\t\t\t // 2\nINC('cart.count', 3);\t\t\t  // 5\nPUSH('cart.items', 'tea');\t\t // [\"tea\"]\nEXT('cart', { city: 'Rome' });\t // adds cart.city and keeps the other fields\nTOGGLE('cart.open');\t\t\t   // true\nNUL('cart.note');\t\t\t\t  // null\n\nconsole.log(cart);\n// {\"count\":5,\"items\":[\"tea\"],\"open\":true,\"note\":null,\"city\":\"Rome\"}\n\nWATCH('cart.count', (path, value) => console.log('changed', value));\n\ncart.count = 10;\t\t\t\t   // no notification\nUPD('cart.count');\t\t\t\t // changed 10\n```\n\n| Function | What it does |\n| --- | --- |\n| `SET(path, value)` | Replaces the value. |\n| `INC(path, [value])` | Adds `value` to a number. The default is `1`. |\n| `PUSH(path, value)` | Adds an item, or every item of an array, to an array. |\n| `EXT(path, object)` | Copies the fields of `object` into the object at the path. |\n| `TOGGLE(path)` | Inverts a boolean. |\n| `NUL(path)` | Sets the value to `null`. |\n| `UPD(path)` | Keeps the value and notifies its dependents. |\n\nAssigning to a variable directly, as in `cart.count = 10`, changes the value silently. Call `UPD()` afterwards to announce the change.\n\n## Delay a write\n\nA number of `10` or more as the third argument of `SET()` delays the write by that many milliseconds. Calling it again for the same path within the delay replaces the pending write.\n\n```js\nSET('delayed.value', 1, 100);\nconsole.log(window.delayed);\t\t   // undefined\n\nsetTimeout(() => console.log(delayed.value), 200);   // 1\n```\n\n## Path prefixes\n\nA prefix sends the path to a dedicated storage object:\n\n| Prefix | Stored in | Use it for |\n| --- | --- | --- |\n| `%` | `jctmp` | Temporary values. |\n| `*` | `common` | Values shared across the application. |\n| `#` | `DEF.cl` | Code lists, such as the options of a select box. |\n\n```js\nSET('%wizard.step', 2);\nconsole.log(jctmp.wizard.step);\t// 2\n\nSET('*user', 'Ana');\nconsole.log(common.user);\t\t  // Ana\n\nSET('#colors', ['red', 'green']);\nconsole.log(DEF.cl.colors);\t\t// [\"red\",\"green\"]\n\nconsole.log(GET('%wizard.step'), GET('*user'), GET('#colors'));\n// 2 Ana [\"red\",\"green\"]\n```\n\n## Who is notified of a change\n\nA change at a path notifies its parents and its children. Paths on other branches are left alone.\n\n```js\nWATCH('order', (path, value) => console.log('order\t  <-', path));\nWATCH('order.address', (path, value) => console.log('address\t<-', path));\nWATCH('order.address.city', (path, value) => console.log('city\t   <-', path));\nWATCH('order.note', (path, value) => console.log('note\t   <-', path));\n\nSET('order.address.city', 'Madrid');\n// order\t  <- order.address.city\n// address\t<- order.address.city\n// city\t   <- order.address.city\n\nSET('order.address', { city: 'Lisbon' });\n// order\t  <- order.address\n// address\t<- order.address\n// city\t   <- order.address\n```\n\nWriting to `order.address.city` reaches the watchers of `order`, `order.address` and `order.address.city`. The watcher of `order.note` stays silent in both writes. The same rule applies to components and to [bindings](../data-binding/).\n\n## Watch a path\n\n[WATCH()](../../reference/globals/) calls a function when a path changes. The function receives the path that changed, the current value at the watched path and the type of the change. Pass `true` as the third argument to run it immediately with the current value.\n\n```js\nWATCH('stock.count', function(path, value, type) {\n\tconsole.log(path, value, type);\n}, true);\n// stock.count undefined 0\n\nSET('stock.count', 5);\n// stock.count 5 1\n```\n\n| Type | Meaning |\n| --- | --- |\n| `0` | The initial value. |\n| `1` | Changed by code. |\n| `2` | Changed by user input. |\n| `3` | Set to the default value. |\n\n## Fixed paths\n\nA `!` in front of a watched path ignores changes that happen below it. The watcher still reacts to the path itself and to its parents.\n\n```js\nWATCH('order.address', () => console.log('normal'));\nWATCH('!order.address', () => console.log('fixed'));\n\nSET('order.address.city', 'Madrid');  // normal\nSET('order.address', { city: 'Rome' }); // normal, fixed\nSET('order', { address: {} });\t\t// normal, fixed\n```\n\n## Environment values\n\nA name in square brackets is replaced by the value stored with [ENV()](../../reference/globals/):\n\n```js\nENV('tenant', 'acme');\n\nSET('data.[tenant].plan', 'pro');\nconsole.log(window.data);   // {\"acme\":{\"plan\":\"pro\"}}\n```\n\n## Plugin paths\n\nThe form `name|property` addresses a property of a [plugin](../plugins/). To read a value you can also write `name/property`.\n\n```js\nPLUGIN('cart', function(exports) {\n\texports.total = 10;\n});\n\nsetTimeout(function() {\n\tconsole.log(GET('cart|total'));\t // 10\n\tSET('cart|total', 25);\n\tconsole.log(PLUGINS.cart.total);\t// 25\n\tconsole.log(GET('cart/total'));\t // 25\n}, 200);\n```\n\n## Paths relative to a scope\n\nInside a scope, the `?` character stands for the path of the scope, so `?.name` can point to a different value in each part of the page. [Scopes](../scopes/) explains how this works.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTu1wM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/paths/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Paths","summary":"Wie Paths Werte im Datenmodell adressieren, wie du sie liest und schreibst und wer über eine Änderung benachrichtigt wird.","markdown":"---\ntitle: Paths\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/paths/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Paths\n\n> Wie Paths Werte im Datenmodell adressieren, wie du sie liest und schreibst und wer über eine Änderung benachrichtigt wird.\n\nEin Path ist ein String, der eine Stelle im Datenmodell benennt, etwa `order.address.city`. Komponenten, Bindungen und dein eigener Code verwenden Paths, um Daten zu teilen. Standardmäßig beginnt ein Path beim Objekt `window`, `order.address.city` ist also derselbe Wert wie `window.order.address.city`.\n\n## Werte lesen und schreiben\n\n[SET()](../../reference/globals/) schreibt einen Wert und [GET()](../../reference/globals/) liest ihn. Fehlende Objekte und Arrays auf dem Weg werden für dich angelegt, und das Lesen eines nicht vorhandenen Paths ergibt ohne Fehler `undefined`.\n\n```js\nSET('shop.cart.total', 120);\nconsole.log(window.shop);\t\t\t  // {\"cart\":{\"total\":120}}\nconsole.log(GET('shop.cart.total'));   // 120\nconsole.log(GET('shop.order.total'));  // undefined\n\nSET('shop.items[1].name', 'Keyboard');\nconsole.log(shop.items);\t\t\t   // [null,{\"name\":\"Keyboard\"}]\n```\n\n## Helper für häufige Änderungen\n\nDiese Funktionen ändern einen Wert und benachrichtigen alles, was davon abhängt:\n\n```js\nSET('cart', { count: 1, items: [], open: false, note: 'gift' });\n\nINC('cart.count');\t\t\t\t // 2\nINC('cart.count', 3);\t\t\t  // 5\nPUSH('cart.items', 'tea');\t\t // [\"tea\"]\nEXT('cart', { city: 'Rome' });\t // adds cart.city and keeps the other fields\nTOGGLE('cart.open');\t\t\t   // true\nNUL('cart.note');\t\t\t\t  // null\n\nconsole.log(cart);\n// {\"count\":5,\"items\":[\"tea\"],\"open\":true,\"note\":null,\"city\":\"Rome\"}\n\nWATCH('cart.count', (path, value) => console.log('changed', value));\n\ncart.count = 10;\t\t\t\t   // no notification\nUPD('cart.count');\t\t\t\t // changed 10\n```\n\n| Funktion | Was sie macht |\n| --- | --- |\n| `SET(path, value)` | Ersetzt den Wert. |\n| `INC(path, [value])` | Addiert `value` zu einer Zahl. Standardwert: `1`. |\n| `PUSH(path, value)` | Fügt einem Array einen Eintrag oder jeden Eintrag eines Arrays hinzu. |\n| `EXT(path, object)` | Kopiert die Felder von `object` in das Objekt am Path. |\n| `TOGGLE(path)` | Kehrt einen Boolean um. |\n| `NUL(path)` | Setzt den Wert auf `null`. |\n| `UPD(path)` | Behält den Wert und benachrichtigt alles, was davon abhängt. |\n\nEine direkte Zuweisung an eine Variable, wie bei `cart.count = 10`, ändert den Wert stillschweigend. Rufe danach `UPD()` auf, um die Änderung bekannt zu machen.\n\n## Schreibvorgang verzögern\n\nEine Zahl von `10` oder mehr als drittes Argument von `SET()` verzögert den Schreibvorgang um so viele Millisekunden. Ein erneuter Aufruf für denselben Path innerhalb der Verzögerung ersetzt den ausstehenden Schreibvorgang.\n\n```js\nSET('delayed.value', 1, 100);\nconsole.log(window.delayed);\t\t   // undefined\n\nsetTimeout(() => console.log(delayed.value), 200);   // 1\n```\n\n## Path-Präfixe\n\nEin Präfix leitet den Path in ein eigenes Speicherobjekt:\n\n| Präfix | Gespeichert in | Verwendung |\n| --- | --- | --- |\n| `%` | `jctmp` | Temporäre Werte. |\n| `*` | `common` | Werte, die in der gesamten Anwendung geteilt werden. |\n| `#` | `DEF.cl` | Codelisten, etwa die Optionen eines Auswahlfelds. |\n\n```js\nSET('%wizard.step', 2);\nconsole.log(jctmp.wizard.step);\t// 2\n\nSET('*user', 'Ana');\nconsole.log(common.user);\t\t  // Ana\n\nSET('#colors', ['red', 'green']);\nconsole.log(DEF.cl.colors);\t\t// [\"red\",\"green\"]\n\nconsole.log(GET('%wizard.step'), GET('*user'), GET('#colors'));\n// 2 Ana [\"red\",\"green\"]\n```\n\n## Wer über eine Änderung benachrichtigt wird\n\nEine Änderung an einem Path benachrichtigt seine übergeordneten und untergeordneten Paths. Paths auf anderen Zweigen bleiben unberührt.\n\n```js\nWATCH('order', (path, value) => console.log('order\t  <-', path));\nWATCH('order.address', (path, value) => console.log('address\t<-', path));\nWATCH('order.address.city', (path, value) => console.log('city\t   <-', path));\nWATCH('order.note', (path, value) => console.log('note\t   <-', path));\n\nSET('order.address.city', 'Madrid');\n// order\t  <- order.address.city\n// address\t<- order.address.city\n// city\t   <- order.address.city\n\nSET('order.address', { city: 'Lisbon' });\n// order\t  <- order.address\n// address\t<- order.address\n// city\t   <- order.address\n```\n\nEin Schreibvorgang auf `order.address.city` erreicht die Watcher von `order`, `order.address` und `order.address.city`. Der Watcher von `order.note` bleibt bei beiden Schreibvorgängen still. Dieselbe Regel gilt für Komponenten und [Bindungen](../data-binding/).\n\n## Path beobachten\n\n[WATCH()](../../reference/globals/) ruft eine Funktion auf, wenn sich ein Path ändert. Die Funktion erhält den geänderten Path, den aktuellen Wert am beobachteten Path und den Typ der Änderung. Übergib `true` als drittes Argument, um sie sofort mit dem aktuellen Wert auszuführen.\n\n```js\nWATCH('stock.count', function(path, value, type) {\n\tconsole.log(path, value, type);\n}, true);\n// stock.count undefined 0\n\nSET('stock.count', 5);\n// stock.count 5 1\n```\n\n| Typ | Bedeutung |\n| --- | --- |\n| `0` | Der Anfangswert. |\n| `1` | Durch Code geändert. |\n| `2` | Durch Benutzereingabe geändert. |\n| `3` | Auf den Standardwert gesetzt. |\n\n## Feste Paths\n\nEin `!` vor einem beobachteten Path ignoriert Änderungen unterhalb davon. Der Watcher reagiert weiterhin auf den Path selbst und auf seine übergeordneten Paths.\n\n```js\nWATCH('order.address', () => console.log('normal'));\nWATCH('!order.address', () => console.log('fixed'));\n\nSET('order.address.city', 'Madrid');  // normal\nSET('order.address', { city: 'Rome' }); // normal, fixed\nSET('order', { address: {} });\t\t// normal, fixed\n```\n\n## Umgebungswerte\n\nEin Name in eckigen Klammern wird durch den mit [ENV()](../../reference/globals/) gespeicherten Wert ersetzt:\n\n```js\nENV('tenant', 'acme');\n\nSET('data.[tenant].plan', 'pro');\nconsole.log(window.data);   // {\"acme\":{\"plan\":\"pro\"}}\n```\n\n## Plugin-Paths\n\nDie Form `name|property` adressiert eine Eigenschaft eines [Plugins](../plugins/). Zum Lesen eines Werts kannst du auch `name/property` schreiben.\n\n```js\nPLUGIN('cart', function(exports) {\n\texports.total = 10;\n});\n\nsetTimeout(function() {\n\tconsole.log(GET('cart|total'));\t // 10\n\tSET('cart|total', 25);\n\tconsole.log(PLUGINS.cart.total);\t// 25\n\tconsole.log(GET('cart/total'));\t // 25\n}, 200);\n```\n\n## Paths relativ zu einem Scope\n\nInnerhalb eines Scopes steht das Zeichen `?` für den Path des Scopes, sodass `?.name` in jedem Teil der Seite auf einen anderen Wert zeigen kann. Wie das funktioniert, erklärt [Scopes](../scopes/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTu1wM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/paths/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Paths","summary":"Cómo los paths direccionan los valores del modelo de datos, cómo leerlos y escribirlos, y a quién se notifica un cambio.","markdown":"---\ntitle: Paths\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/paths/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Paths\n\n> Cómo los paths direccionan los valores del modelo de datos, cómo leerlos y escribirlos, y a quién se notifica un cambio.\n\nUn path es una cadena que da nombre a un lugar del modelo de datos, como `order.address.city`. Los componentes, los enlaces y tu propio código usan paths para compartir datos. De forma predeterminada, un path empieza en el objeto `window`, así que `order.address.city` es el mismo valor que `window.order.address.city`.\n\n## Leer y escribir valores\n\n[SET()](../../reference/globals/) escribe un valor y [GET()](../../reference/globals/) lo lee. Los objetos y arrays que faltan por el camino se crean automáticamente, y leer un path que no existe devuelve `undefined` sin ningún error.\n\n```js\nSET('shop.cart.total', 120);\nconsole.log(window.shop);\t\t\t  // {\"cart\":{\"total\":120}}\nconsole.log(GET('shop.cart.total'));   // 120\nconsole.log(GET('shop.order.total'));  // undefined\n\nSET('shop.items[1].name', 'Keyboard');\nconsole.log(shop.items);\t\t\t   // [null,{\"name\":\"Keyboard\"}]\n```\n\n## Helpers para los cambios habituales\n\nEstas funciones cambian un valor y notifican a todo lo que depende de él:\n\n```js\nSET('cart', { count: 1, items: [], open: false, note: 'gift' });\n\nINC('cart.count');\t\t\t\t // 2\nINC('cart.count', 3);\t\t\t  // 5\nPUSH('cart.items', 'tea');\t\t // [\"tea\"]\nEXT('cart', { city: 'Rome' });\t // adds cart.city and keeps the other fields\nTOGGLE('cart.open');\t\t\t   // true\nNUL('cart.note');\t\t\t\t  // null\n\nconsole.log(cart);\n// {\"count\":5,\"items\":[\"tea\"],\"open\":true,\"note\":null,\"city\":\"Rome\"}\n\nWATCH('cart.count', (path, value) => console.log('changed', value));\n\ncart.count = 10;\t\t\t\t   // no notification\nUPD('cart.count');\t\t\t\t // changed 10\n```\n\n| Función | Qué hace |\n| --- | --- |\n| `SET(path, value)` | Sustituye el valor. |\n| `INC(path, [value])` | Suma `value` a un número. El valor predeterminado es `1`. |\n| `PUSH(path, value)` | Añade a un array un elemento, o todos los elementos de un array. |\n| `EXT(path, object)` | Copia los campos de `object` en el objeto del path. |\n| `TOGGLE(path)` | Invierte un booleano. |\n| `NUL(path)` | Establece el valor en `null`. |\n| `UPD(path)` | Conserva el valor y notifica a lo que depende de él. |\n\nAsignar directamente a una variable, como en `cart.count = 10`, cambia el valor sin avisar. Llama a `UPD()` después para anunciar el cambio.\n\n## Retrasar una escritura\n\nUn número igual o mayor que `10` como tercer argumento de `SET()` retrasa la escritura ese número de milisegundos. Si vuelves a llamarlo para el mismo path dentro del retardo, se sustituye la escritura pendiente.\n\n```js\nSET('delayed.value', 1, 100);\nconsole.log(window.delayed);\t\t   // undefined\n\nsetTimeout(() => console.log(delayed.value), 200);   // 1\n```\n\n## Prefijos de path\n\nUn prefijo envía el path a un objeto de almacenamiento específico:\n\n| Prefijo | Se guarda en | Úsalo para |\n| --- | --- | --- |\n| `%` | `jctmp` | Valores temporales. |\n| `*` | `common` | Valores compartidos en toda la aplicación. |\n| `#` | `DEF.cl` | Listas de códigos, como las opciones de un cuadro de selección. |\n\n```js\nSET('%wizard.step', 2);\nconsole.log(jctmp.wizard.step);\t// 2\n\nSET('*user', 'Ana');\nconsole.log(common.user);\t\t  // Ana\n\nSET('#colors', ['red', 'green']);\nconsole.log(DEF.cl.colors);\t\t// [\"red\",\"green\"]\n\nconsole.log(GET('%wizard.step'), GET('*user'), GET('#colors'));\n// 2 Ana [\"red\",\"green\"]\n```\n\n## A quién se notifica un cambio\n\nUn cambio en un path notifica a sus padres y a sus hijos. Los paths de otras ramas no se ven afectados.\n\n```js\nWATCH('order', (path, value) => console.log('order\t  <-', path));\nWATCH('order.address', (path, value) => console.log('address\t<-', path));\nWATCH('order.address.city', (path, value) => console.log('city\t   <-', path));\nWATCH('order.note', (path, value) => console.log('note\t   <-', path));\n\nSET('order.address.city', 'Madrid');\n// order\t  <- order.address.city\n// address\t<- order.address.city\n// city\t   <- order.address.city\n\nSET('order.address', { city: 'Lisbon' });\n// order\t  <- order.address\n// address\t<- order.address\n// city\t   <- order.address\n```\n\nEscribir en `order.address.city` llega a los observadores de `order`, `order.address` y `order.address.city`. El observador de `order.note` no reacciona en ninguna de las dos escrituras. La misma regla se aplica a los componentes y a los [enlaces](../data-binding/).\n\n## Observar un path\n\n[WATCH()](../../reference/globals/) llama a una función cuando cambia un path. La función recibe el path que ha cambiado, el valor actual del path observado y el tipo de cambio. Pasa `true` como tercer argumento para ejecutarla de inmediato con el valor actual.\n\n```js\nWATCH('stock.count', function(path, value, type) {\n\tconsole.log(path, value, type);\n}, true);\n// stock.count undefined 0\n\nSET('stock.count', 5);\n// stock.count 5 1\n```\n\n| Tipo | Significado |\n| --- | --- |\n| `0` | El valor inicial. |\n| `1` | Cambiado por código. |\n| `2` | Cambiado por una entrada del usuario. |\n| `3` | Establecido en el valor predeterminado. |\n\n## Paths fijos\n\nUn `!` delante de un path observado ignora los cambios que ocurren por debajo de él. El observador sigue reaccionando al propio path y a sus padres.\n\n```js\nWATCH('order.address', () => console.log('normal'));\nWATCH('!order.address', () => console.log('fixed'));\n\nSET('order.address.city', 'Madrid');  // normal\nSET('order.address', { city: 'Rome' }); // normal, fixed\nSET('order', { address: {} });\t\t// normal, fixed\n```\n\n## Valores del entorno\n\nUn nombre entre corchetes se sustituye por el valor guardado con [ENV()](../../reference/globals/):\n\n```js\nENV('tenant', 'acme');\n\nSET('data.[tenant].plan', 'pro');\nconsole.log(window.data);   // {\"acme\":{\"plan\":\"pro\"}}\n```\n\n## Paths de plugins\n\nLa forma `name|property` direcciona una propiedad de un [plugin](../plugins/). Para leer un valor también puedes escribir `name/property`.\n\n```js\nPLUGIN('cart', function(exports) {\n\texports.total = 10;\n});\n\nsetTimeout(function() {\n\tconsole.log(GET('cart|total'));\t // 10\n\tSET('cart|total', 25);\n\tconsole.log(PLUGINS.cart.total);\t// 25\n\tconsole.log(GET('cart/total'));\t // 25\n}, 200);\n```\n\n## Paths relativos a un scope\n\nDentro de un scope, el carácter `?` representa el path del scope, así que `?.name` puede apuntar a un valor distinto en cada parte de la página. [Scopes](../scopes/) explica cómo funciona.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTu1wM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/paths/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Paths","summary":"Comment les paths adressent les valeurs du modèle de données, comment les lire et les écrire, et qui est notifié d'une modification.","markdown":"---\ntitle: Paths\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/paths/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Paths\n\n> Comment les paths adressent les valeurs du modèle de données, comment les lire et les écrire, et qui est notifié d'une modification.\n\nUn path est une chaîne qui nomme un emplacement du modèle de données, comme `order.address.city`. Les composants, les liaisons et ton propre code utilisent tous des paths pour partager des données. Par défaut, un path part de l'objet `window` : `order.address.city` est donc la même valeur que `window.order.address.city`.\n\n## Lire et écrire des valeurs\n\n[SET()](../../reference/globals/) écrit une valeur et [GET()](../../reference/globals/) la lit. Les objets et les tableaux manquants sur le chemin sont créés pour toi, et lire un path qui n'existe pas renvoie `undefined` sans erreur.\n\n```js\nSET('shop.cart.total', 120);\nconsole.log(window.shop);\t\t\t  // {\"cart\":{\"total\":120}}\nconsole.log(GET('shop.cart.total'));   // 120\nconsole.log(GET('shop.order.total'));  // undefined\n\nSET('shop.items[1].name', 'Keyboard');\nconsole.log(shop.items);\t\t\t   // [null,{\"name\":\"Keyboard\"}]\n```\n\n## Des helpers pour les modifications courantes\n\nCes fonctions modifient une valeur et notifient tout ce qui en dépend :\n\n```js\nSET('cart', { count: 1, items: [], open: false, note: 'gift' });\n\nINC('cart.count');\t\t\t\t // 2\nINC('cart.count', 3);\t\t\t  // 5\nPUSH('cart.items', 'tea');\t\t // [\"tea\"]\nEXT('cart', { city: 'Rome' });\t // adds cart.city and keeps the other fields\nTOGGLE('cart.open');\t\t\t   // true\nNUL('cart.note');\t\t\t\t  // null\n\nconsole.log(cart);\n// {\"count\":5,\"items\":[\"tea\"],\"open\":true,\"note\":null,\"city\":\"Rome\"}\n\nWATCH('cart.count', (path, value) => console.log('changed', value));\n\ncart.count = 10;\t\t\t\t   // no notification\nUPD('cart.count');\t\t\t\t // changed 10\n```\n\n| Fonction | Ce qu'elle fait |\n| --- | --- |\n| `SET(path, value)` | Remplace la valeur. |\n| `INC(path, [value])` | Ajoute `value` à un nombre. La valeur par défaut est `1`. |\n| `PUSH(path, value)` | Ajoute un élément, ou chaque élément d'un tableau, à un tableau. |\n| `EXT(path, object)` | Copie les champs de `object` dans l'objet situé au path. |\n| `TOGGLE(path)` | Inverse un booléen. |\n| `NUL(path)` | Définit la valeur à `null`. |\n| `UPD(path)` | Conserve la valeur et notifie ce qui en dépend. |\n\nAssigner directement une variable, comme dans `cart.count = 10`, modifie la valeur sans rien signaler. Appelle ensuite `UPD()` pour annoncer la modification.\n\n## Retarder une écriture\n\nUn nombre supérieur ou égal à `10` comme troisième argument de `SET()` retarde l'écriture d'autant de millisecondes. Un nouvel appel pour le même path pendant ce délai remplace l'écriture en attente.\n\n```js\nSET('delayed.value', 1, 100);\nconsole.log(window.delayed);\t\t   // undefined\n\nsetTimeout(() => console.log(delayed.value), 200);   // 1\n```\n\n## Préfixes de path\n\nUn préfixe envoie le path vers un objet de stockage dédié :\n\n| Préfixe | Stocké dans | À utiliser pour |\n| --- | --- | --- |\n| `%` | `jctmp` | Les valeurs temporaires. |\n| `*` | `common` | Les valeurs partagées dans toute l'application. |\n| `#` | `DEF.cl` | Les listes de codes, comme les options d'une liste déroulante. |\n\n```js\nSET('%wizard.step', 2);\nconsole.log(jctmp.wizard.step);\t// 2\n\nSET('*user', 'Ana');\nconsole.log(common.user);\t\t  // Ana\n\nSET('#colors', ['red', 'green']);\nconsole.log(DEF.cl.colors);\t\t// [\"red\",\"green\"]\n\nconsole.log(GET('%wizard.step'), GET('*user'), GET('#colors'));\n// 2 Ana [\"red\",\"green\"]\n```\n\n## Qui est notifié d'une modification\n\nUne modification à un path notifie ses parents et ses enfants. Les paths des autres branches ne sont pas concernés.\n\n```js\nWATCH('order', (path, value) => console.log('order\t  <-', path));\nWATCH('order.address', (path, value) => console.log('address\t<-', path));\nWATCH('order.address.city', (path, value) => console.log('city\t   <-', path));\nWATCH('order.note', (path, value) => console.log('note\t   <-', path));\n\nSET('order.address.city', 'Madrid');\n// order\t  <- order.address.city\n// address\t<- order.address.city\n// city\t   <- order.address.city\n\nSET('order.address', { city: 'Lisbon' });\n// order\t  <- order.address\n// address\t<- order.address\n// city\t   <- order.address\n```\n\nÉcrire dans `order.address.city` atteint les observateurs de `order`, `order.address` et `order.address.city`. L'observateur de `order.note` reste silencieux lors des deux écritures. La même règle s'applique aux composants et aux [liaisons](../data-binding/).\n\n## Observer un path\n\n[WATCH()](../../reference/globals/) appelle une fonction quand un path change. La fonction reçoit le path modifié, la valeur actuelle du path observé et le type de la modification. Passe `true` comme troisième argument pour l'exécuter immédiatement avec la valeur actuelle.\n\n```js\nWATCH('stock.count', function(path, value, type) {\n\tconsole.log(path, value, type);\n}, true);\n// stock.count undefined 0\n\nSET('stock.count', 5);\n// stock.count 5 1\n```\n\n| Type | Signification |\n| --- | --- |\n| `0` | La valeur initiale. |\n| `1` | Modifiée par le code. |\n| `2` | Modifiée par une saisie de l'utilisateur. |\n| `3` | Définie à la valeur par défaut. |\n\n## Paths fixes\n\nUn `!` devant un path observé ignore les modifications qui se produisent en dessous. L'observateur réagit toujours au path lui-même et à ses parents.\n\n```js\nWATCH('order.address', () => console.log('normal'));\nWATCH('!order.address', () => console.log('fixed'));\n\nSET('order.address.city', 'Madrid');  // normal\nSET('order.address', { city: 'Rome' }); // normal, fixed\nSET('order', { address: {} });\t\t// normal, fixed\n```\n\n## Valeurs de l'environnement\n\nUn nom entre crochets est remplacé par la valeur stockée avec [ENV()](../../reference/globals/) :\n\n```js\nENV('tenant', 'acme');\n\nSET('data.[tenant].plan', 'pro');\nconsole.log(window.data);   // {\"acme\":{\"plan\":\"pro\"}}\n```\n\n## Paths de plugin\n\nLa forme `name|property` adresse une propriété d'un [plugin](../plugins/). Pour lire une valeur, tu peux aussi écrire `name/property`.\n\n```js\nPLUGIN('cart', function(exports) {\n\texports.total = 10;\n});\n\nsetTimeout(function() {\n\tconsole.log(GET('cart|total'));\t // 10\n\tSET('cart|total', 25);\n\tconsole.log(PLUGINS.cart.total);\t// 25\n\tconsole.log(GET('cart/total'));\t // 25\n}, 200);\n```\n\n## Paths relatifs à un scope\n\nDans un scope, le caractère `?` représente le path du scope : `?.name` peut donc pointer vers une valeur différente dans chaque partie de la page. [Scopes](../scopes/) explique comment cela fonctionne.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTu1wM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/paths/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Path","summary":"Come i path indirizzano i valori nel modello di dati, come leggerli e scriverli e chi riceve la notifica di una modifica.","markdown":"---\ntitle: Path\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/paths/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Path\n\n> Come i path indirizzano i valori nel modello di dati, come leggerli e scriverli e chi riceve la notifica di una modifica.\n\nUn path è una stringa che assegna un nome a un punto del modello di dati, come `order.address.city`. Componenti, associazioni e il tuo codice usano tutti i path per condividere i dati. Per impostazione predefinita un path parte dall'oggetto `window`, quindi `order.address.city` è lo stesso valore di `window.order.address.city`.\n\n## Leggi e scrivi i valori\n\n[SET()](../../reference/globals/) scrive un valore e [GET()](../../reference/globals/) lo legge. Gli oggetti e gli array mancanti lungo il percorso vengono creati automaticamente, e la lettura di un path inesistente restituisce `undefined` senza errori.\n\n```js\nSET('shop.cart.total', 120);\nconsole.log(window.shop);\t\t\t  // {\"cart\":{\"total\":120}}\nconsole.log(GET('shop.cart.total'));   // 120\nconsole.log(GET('shop.order.total'));  // undefined\n\nSET('shop.items[1].name', 'Keyboard');\nconsole.log(shop.items);\t\t\t   // [null,{\"name\":\"Keyboard\"}]\n```\n\n## Helper per le modifiche comuni\n\nQueste funzioni modificano un valore e notificano tutto ciò che dipende da esso:\n\n```js\nSET('cart', { count: 1, items: [], open: false, note: 'gift' });\n\nINC('cart.count');\t\t\t\t // 2\nINC('cart.count', 3);\t\t\t  // 5\nPUSH('cart.items', 'tea');\t\t // [\"tea\"]\nEXT('cart', { city: 'Rome' });\t // adds cart.city and keeps the other fields\nTOGGLE('cart.open');\t\t\t   // true\nNUL('cart.note');\t\t\t\t  // null\n\nconsole.log(cart);\n// {\"count\":5,\"items\":[\"tea\"],\"open\":true,\"note\":null,\"city\":\"Rome\"}\n\nWATCH('cart.count', (path, value) => console.log('changed', value));\n\ncart.count = 10;\t\t\t\t   // no notification\nUPD('cart.count');\t\t\t\t // changed 10\n```\n\n| Funzione | Che cosa fa |\n| --- | --- |\n| `SET(path, value)` | Sostituisce il valore. |\n| `INC(path, [value])` | Aggiunge `value` a un numero. Il valore predefinito è `1`. |\n| `PUSH(path, value)` | Aggiunge a un array un elemento, oppure ogni elemento di un array. |\n| `EXT(path, object)` | Copia i campi di `object` nell'oggetto presente nel path. |\n| `TOGGLE(path)` | Inverte un booleano. |\n| `NUL(path)` | Imposta il valore su `null`. |\n| `UPD(path)` | Mantiene il valore e notifica ciò che dipende da esso. |\n\nL'assegnazione diretta a una variabile, come in `cart.count = 10`, modifica il valore senza avvisare nessuno. Chiama poi `UPD()` per annunciare la modifica.\n\n## Ritarda una scrittura\n\nUn numero pari o superiore a `10` come terzo argomento di `SET()` ritarda la scrittura di altrettanti millisecondi. Se la chiami di nuovo per lo stesso path entro il ritardo, la scrittura in sospeso viene sostituita.\n\n```js\nSET('delayed.value', 1, 100);\nconsole.log(window.delayed);\t\t   // undefined\n\nsetTimeout(() => console.log(delayed.value), 200);   // 1\n```\n\n## Prefissi dei path\n\nUn prefisso indirizza il path a un oggetto di archiviazione dedicato:\n\n| Prefisso | Memorizzato in | Usalo per |\n| --- | --- | --- |\n| `%` | `jctmp` | Valori temporanei. |\n| `*` | `common` | Valori condivisi in tutta l'applicazione. |\n| `#` | `DEF.cl` | Elenchi di codici, come le opzioni di una casella di selezione. |\n\n```js\nSET('%wizard.step', 2);\nconsole.log(jctmp.wizard.step);\t// 2\n\nSET('*user', 'Ana');\nconsole.log(common.user);\t\t  // Ana\n\nSET('#colors', ['red', 'green']);\nconsole.log(DEF.cl.colors);\t\t// [\"red\",\"green\"]\n\nconsole.log(GET('%wizard.step'), GET('*user'), GET('#colors'));\n// 2 Ana [\"red\",\"green\"]\n```\n\n## Chi riceve la notifica di una modifica\n\nUna modifica in un path notifica i suoi genitori e i suoi figli. I path su altri rami non vengono toccati.\n\n```js\nWATCH('order', (path, value) => console.log('order\t  <-', path));\nWATCH('order.address', (path, value) => console.log('address\t<-', path));\nWATCH('order.address.city', (path, value) => console.log('city\t   <-', path));\nWATCH('order.note', (path, value) => console.log('note\t   <-', path));\n\nSET('order.address.city', 'Madrid');\n// order\t  <- order.address.city\n// address\t<- order.address.city\n// city\t   <- order.address.city\n\nSET('order.address', { city: 'Lisbon' });\n// order\t  <- order.address\n// address\t<- order.address\n// city\t   <- order.address\n```\n\nLa scrittura in `order.address.city` raggiunge gli osservatori di `order`, `order.address` e `order.address.city`. L'osservatore di `order.note` resta silenzioso in entrambe le scritture. La stessa regola vale per i componenti e per le [associazioni](../data-binding/).\n\n## Osserva un path\n\n[WATCH()](../../reference/globals/) chiama una funzione quando un path cambia. La funzione riceve il path modificato, il valore corrente nel path osservato e il tipo di modifica. Passa `true` come terzo argomento per eseguirla subito con il valore corrente.\n\n```js\nWATCH('stock.count', function(path, value, type) {\n\tconsole.log(path, value, type);\n}, true);\n// stock.count undefined 0\n\nSET('stock.count', 5);\n// stock.count 5 1\n```\n\n| Tipo | Significato |\n| --- | --- |\n| `0` | Il valore iniziale. |\n| `1` | Modificato dal codice. |\n| `2` | Modificato dall'input dell'utente. |\n| `3` | Impostato sul valore predefinito. |\n\n## Path fissi\n\nUn `!` davanti a un path osservato ignora le modifiche che avvengono sotto di esso. L'osservatore reagisce comunque al path stesso e ai suoi genitori.\n\n```js\nWATCH('order.address', () => console.log('normal'));\nWATCH('!order.address', () => console.log('fixed'));\n\nSET('order.address.city', 'Madrid');  // normal\nSET('order.address', { city: 'Rome' }); // normal, fixed\nSET('order', { address: {} });\t\t// normal, fixed\n```\n\n## Valori dell'ambiente\n\nUn nome tra parentesi quadre viene sostituito con il valore memorizzato con [ENV()](../../reference/globals/):\n\n```js\nENV('tenant', 'acme');\n\nSET('data.[tenant].plan', 'pro');\nconsole.log(window.data);   // {\"acme\":{\"plan\":\"pro\"}}\n```\n\n## Path dei plugin\n\nLa forma `name|property` indirizza una proprietà di un [plugin](../plugins/). Per leggere un valore puoi anche scrivere `name/property`.\n\n```js\nPLUGIN('cart', function(exports) {\n\texports.total = 10;\n});\n\nsetTimeout(function() {\n\tconsole.log(GET('cart|total'));\t // 10\n\tSET('cart|total', 25);\n\tconsole.log(PLUGINS.cart.total);\t// 25\n\tconsole.log(GET('cart/total'));\t // 25\n}, 200);\n```\n\n## Path relativi a uno scope\n\nAll'interno di uno scope, il carattere `?` rappresenta il path dello scope, quindi `?.name` può puntare a un valore diverso in ogni parte della pagina. [Scope](../scopes/) spiega come funziona.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTu1wM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/paths/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Paths","summary":"Ako paths adresujú hodnoty v dátovom modeli, ako ich čítať a zapisovať a kto dostane upozornenie o zmene.","markdown":"---\ntitle: Paths\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/paths/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Paths\n\n> Ako paths adresujú hodnoty v dátovom modeli, ako ich čítať a zapisovať a kto dostane upozornenie o zmene.\n\nPath je reťazec, ktorý pomenúva miesto v dátovom modeli, napríklad `order.address.city`. Komponenty, väzby aj tvoj vlastný kód zdieľajú dáta pomocou paths. Predvolene sa path začína v objekte `window`, takže `order.address.city` je tá istá hodnota ako `window.order.address.city`.\n\n## Čítaj a zapisuj hodnoty\n\n[SET()](../../reference/globals/) hodnotu zapíše a [GET()](../../reference/globals/) ju prečíta. Chýbajúce objekty a polia na ceste sa vytvoria za teba a čítanie neexistujúceho path vráti `undefined` bez chyby.\n\n```js\nSET('shop.cart.total', 120);\nconsole.log(window.shop);\t\t\t  // {\"cart\":{\"total\":120}}\nconsole.log(GET('shop.cart.total'));   // 120\nconsole.log(GET('shop.order.total'));  // undefined\n\nSET('shop.items[1].name', 'Keyboard');\nconsole.log(shop.items);\t\t\t   // [null,{\"name\":\"Keyboard\"}]\n```\n\n## Pomocné funkcie pre bežné zmeny\n\nTieto funkcie zmenia hodnotu a upozornia všetko, čo od nej závisí:\n\n```js\nSET('cart', { count: 1, items: [], open: false, note: 'gift' });\n\nINC('cart.count');\t\t\t\t // 2\nINC('cart.count', 3);\t\t\t  // 5\nPUSH('cart.items', 'tea');\t\t // [\"tea\"]\nEXT('cart', { city: 'Rome' });\t // adds cart.city and keeps the other fields\nTOGGLE('cart.open');\t\t\t   // true\nNUL('cart.note');\t\t\t\t  // null\n\nconsole.log(cart);\n// {\"count\":5,\"items\":[\"tea\"],\"open\":true,\"note\":null,\"city\":\"Rome\"}\n\nWATCH('cart.count', (path, value) => console.log('changed', value));\n\ncart.count = 10;\t\t\t\t   // no notification\nUPD('cart.count');\t\t\t\t // changed 10\n```\n\n| Funkcia | Čo robí |\n| --- | --- |\n| `SET(path, value)` | Nahradí hodnotu. |\n| `INC(path, [value])` | Pripočíta `value` k číslu. Predvolene `1`. |\n| `PUSH(path, value)` | Pridá do poľa položku alebo každú položku poľa. |\n| `EXT(path, object)` | Skopíruje polia z `object` do objektu na path. |\n| `TOGGLE(path)` | Invertuje booleovskú hodnotu. |\n| `NUL(path)` | Nastaví hodnotu na `null`. |\n| `UPD(path)` | Zachová hodnotu a upozorní to, čo od nej závisí. |\n\nPriame priradenie do premennej, napríklad `cart.count = 10`, zmení hodnotu potichu. Ak chceš zmenu oznámiť, zavolaj potom `UPD()`.\n\n## Oneskor zápis\n\nČíslo `10` alebo vyššie ako tretí argument `SET()` oneskorí zápis o daný počet milisekúnd. Ďalšie volanie pre ten istý path počas oneskorenia nahradí čakajúci zápis.\n\n```js\nSET('delayed.value', 1, 100);\nconsole.log(window.delayed);\t\t   // undefined\n\nsetTimeout(() => console.log(delayed.value), 200);   // 1\n```\n\n## Prefixy path\n\nPrefix nasmeruje path do vyhradeného objektu úložiska:\n\n| Prefix | Uložené v | Použitie |\n| --- | --- | --- |\n| `%` | `jctmp` | Dočasné hodnoty. |\n| `*` | `common` | Hodnoty zdieľané v celej aplikácii. |\n| `#` | `DEF.cl` | Zoznamy kódov, napríklad možnosti výberového poľa. |\n\n```js\nSET('%wizard.step', 2);\nconsole.log(jctmp.wizard.step);\t// 2\n\nSET('*user', 'Ana');\nconsole.log(common.user);\t\t  // Ana\n\nSET('#colors', ['red', 'green']);\nconsole.log(DEF.cl.colors);\t\t// [\"red\",\"green\"]\n\nconsole.log(GET('%wizard.step'), GET('*user'), GET('#colors'));\n// 2 Ana [\"red\",\"green\"]\n```\n\n## Kto dostane upozornenie o zmene\n\nZmena na path upozorní jeho nadradené a podradené paths. Paths na iných vetvách zostávajú nedotknuté.\n\n```js\nWATCH('order', (path, value) => console.log('order\t  <-', path));\nWATCH('order.address', (path, value) => console.log('address\t<-', path));\nWATCH('order.address.city', (path, value) => console.log('city\t   <-', path));\nWATCH('order.note', (path, value) => console.log('note\t   <-', path));\n\nSET('order.address.city', 'Madrid');\n// order\t  <- order.address.city\n// address\t<- order.address.city\n// city\t   <- order.address.city\n\nSET('order.address', { city: 'Lisbon' });\n// order\t  <- order.address\n// address\t<- order.address\n// city\t   <- order.address\n```\n\nZápis do `order.address.city` sa dostane k sledovačom `order`, `order.address` a `order.address.city`. Sledovač `order.note` pri oboch zápisoch mlčí. Rovnaké pravidlo platí pre komponenty a [väzby](../data-binding/).\n\n## Sleduj path\n\n[WATCH()](../../reference/globals/) zavolá funkciu, keď sa path zmení. Funkcia dostane path, ktorý sa zmenil, aktuálnu hodnotu na sledovanom path a typ zmeny. Ak ju chceš spustiť hneď s aktuálnou hodnotou, odovzdaj ako tretí argument `true`.\n\n```js\nWATCH('stock.count', function(path, value, type) {\n\tconsole.log(path, value, type);\n}, true);\n// stock.count undefined 0\n\nSET('stock.count', 5);\n// stock.count 5 1\n```\n\n| Typ | Význam |\n| --- | --- |\n| `0` | Počiatočná hodnota. |\n| `1` | Zmenené kódom. |\n| `2` | Zmenené vstupom používateľa. |\n| `3` | Nastavené na predvolenú hodnotu. |\n\n## Pevné paths\n\nZnak `!` pred sledovaným path ignoruje zmeny, ktoré nastanú pod ním. Sledovač stále reaguje na samotný path a na jeho nadradené paths.\n\n```js\nWATCH('order.address', () => console.log('normal'));\nWATCH('!order.address', () => console.log('fixed'));\n\nSET('order.address.city', 'Madrid');  // normal\nSET('order.address', { city: 'Rome' }); // normal, fixed\nSET('order', { address: {} });\t\t// normal, fixed\n```\n\n## Hodnoty prostredia\n\nNázov v hranatých zátvorkách sa nahradí hodnotou uloženou pomocou [ENV()](../../reference/globals/):\n\n```js\nENV('tenant', 'acme');\n\nSET('data.[tenant].plan', 'pro');\nconsole.log(window.data);   // {\"acme\":{\"plan\":\"pro\"}}\n```\n\n## Paths pluginov\n\nTvar `name|property` adresuje vlastnosť [pluginu](../plugins/). Na čítanie hodnoty môžeš zapísať aj `name/property`.\n\n```js\nPLUGIN('cart', function(exports) {\n\texports.total = 10;\n});\n\nsetTimeout(function() {\n\tconsole.log(GET('cart|total'));\t // 10\n\tSET('cart|total', 25);\n\tconsole.log(PLUGINS.cart.total);\t// 25\n\tconsole.log(GET('cart/total'));\t // 25\n}, 200);\n```\n\n## Paths relatívne k scope\n\nVnútri scope znak `?` zastupuje path daného scope, takže `?.name` môže v každej časti stránky ukazovať na inú hodnotu. Ako to funguje, vysvetľuje časť [Scopes](../scopes/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTY1iM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/flags/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Flags and path modifiers","summary":"Change how a read or write behaves by adding flags and modifiers to a path.","markdown":"---\ntitle: Flags and path modifiers\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/flags/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Flags and path modifiers\n\n> Change how a read or write behaves by adding flags and modifiers to a path.\n\nA path can carry extra instructions. Flags start with `@` and follow the path after a space, as in `SET('price @nowatch', 5)`. Path modifiers are characters that change what the operation does, as in `SET('+tags', 'red')`. Several flags can be combined in one path.\n\n## Flags for the state of components\n\nComponents keep track of whether the user `touched` or `modified` them. These flags set that state while writing the value:\n\n| Flag | Effect on the components at the path |\n| --- | --- |\n| `@touch` | Marks them as touched. |\n| `@change` | Marks them as touched and modified. |\n| `@modify` | Marks them as touched and modified. |\n| `@reset` | Clears touched and modified. |\n| `@default` | Writes the default value of each component and clears touched and modified. |\n\n```html\n<ui-component id=\"age\" name=\"field\" path=\"person.age\" default=\"18\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar com = FIND('field');\n\t\tvar show = label => console.log(label, com.get(), 'touched=' + com.config.touched, 'modified=' + com.config.modified);\n\n\t\tSET('person.age @touch', 20);\n\t\tshow('@touch');     // @touch 20 touched=true modified=false\n\n\t\tSET('person.age @change', 30);\n\t\tshow('@change');    // @change 30 touched=true modified=true\n\n\t\tSET('person.age @reset', 40);\n\t\tshow('@reset');     // @reset 40 touched=false modified=false\n\n\t\tSET('person.age @default', 50);\n\t\tshow('@default');   // @default 18 touched=false modified=false\n\t});\n</script>\n```\n\n## Flags for notifications\n\n| Flag | Effect |\n| --- | --- |\n| `@nowatch` | Does not call the watchers of the path. |\n| `@type:N` | Reports the number `N` as the type of the change. |\n| `@diff` | Skips the write when the new value equals the current one. |\n\n```js\nWATCH('price', (path, value, type) => console.log('watch', value, type));\n\nSET('price', 10);\t\t\t// watch 10 1\nSET('price @nowatch', 20);   // (no output)\nSET('price @type:5', 30);\t// watch 30 5\nSET('price @diff', 30);\t  // (no output, the value is the same)\nSET('price @diff', 40);\t  // watch 40 1\n```\n\nThe flag `@nobind` works with [REWRITE()](../../reference/globals/), which stores a value without updating components. With the flag, bindings are not updated either:\n\n```html\n<ui-bind path=\"note\" config=\"text\"></ui-bind>\n\n<script>\n\tSET('note', 'first');\n\n\tsetTimeout(function() {\n\t\tREWRITE('note @nobind', 'second');\n\t\tconsole.log(note);                                     // second\n\t\tsetTimeout(() => console.log(document.querySelector('ui-bind').textContent), 100);   // first\n\t}, 200);\n</script>\n```\n\n## Flags for reading\n\n| Flag | What `GET()` does |\n| --- | --- |\n| `@clone` | Returns a copy of the value. |\n| `@modified` | Returns an object with only the fields whose components are touched and modified, or `null` when there are none. |\n| `@reset` | Returns the value and clears the state of the components at the path. |\n| `@update` | Returns the value and then notifies the dependents of the path. |\n\n```html\n<ui-component name=\"field\" path=\"user.name\"></ui-component>\n<ui-component name=\"field\" path=\"user.city\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('user', { name: 'Ana', city: 'Rome' });\n\n\tON('ready', function() {\n\n\t\tvar copy = GET('user @clone');\n\t\tconsole.log(copy === user);          // false\n\n\t\tSET('user.city @change', 'Oslo');\n\t\tconsole.log(GET('user @modified'));  // {\"city\":\"Oslo\"}\n\n\t\tGET('user @reset');\n\t\tconsole.log(GET('user @modified'));  // null\n\t});\n</script>\n```\n\n```js\nWATCH('stock', (path, value) => console.log('watch', value));\n\nwindow.stock = 5;\nconsole.log(GET('stock @update'));   // 5\n// watch 5\n```\n\n## Custom flags\n\nAny other name is a custom flag. Listen for it with `ON('@flag name', fn)`. The function receives the path, the value and the type. Custom flags also work with `EXEC()` and `EMIT()`, where the path argument is the name that was called.\n\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log('audit:', path, value);\n});\n\nfunction ping() {}\n\nSET('invoice.total @audit', 90);   // audit: invoice.total 90\nGET('invoice.total @audit');\t   // audit: invoice.total 90\nEXEC('ping @audit');\t\t\t   // audit: ping undefined\nEMIT('saved @audit');\t\t\t  // audit: saved undefined\n```\n\n## Add to arrays and merge objects\n\n| Syntax | Effect |\n| --- | --- |\n| `SET('+path', value)` | Adds the value to the array, like `PUSH()`. |\n| `PUSH('^path', value)` | Adds the value to the start of the array. |\n| `SET('~path', object)` | Merges the object into the current value, like `EXT()`. |\n| `SET('path @extend', object)` | Merges the object as well. |\n\n```js\nSET('+tags', 'red');\nSET('+tags', 'green');\nconsole.log(tags);\t\t\t// [\"red\",\"green\"]\n\nPUSH('^tags', 'first');\nconsole.log(tags);\t\t\t// [\"first\",\"red\",\"green\"]\n\nSET('user', { name: 'Ana', age: 30 });\nSET('~user', { age: 31 });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31}\n\nSET('user @extend', { city: 'Rome' });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31,\"city\":\"Rome\"}\n```\n\n## Transform a value\n\nAn arrow after the path runs an expression on the value. Both `-->` and `->` work. With `SET()` the result is stored, and with `GET()` the result is returned while the stored value stays the same. The expression must use the word `value`. The same syntax works in the `path` attribute of `<ui-bind>`.\n\n```html\n<script>\n\tSET('code --> value.toUpperCase()', 'abc');\n\tconsole.log(code);                     // ABC\n\n\tconsole.log(GET('code --> value.length'));  // 3\n\tconsole.log(GET('code -> value + \"!\"'));    // ABC!\n</script>\n<ui-bind path=\"code --> value.toLowerCase()\" config=\"text\"></ui-bind>\n```\n\n## Wait for a code list\n\nA `#name` after the path postpones the write until the code list `name` is loaded. Code lists are declared with [CL_INIT()](../../reference/globals/).\n\n```js\nCL_INIT('colors', function(next) {\n\tsetTimeout(() => next(['red', 'green']), 100);\n}, true);\n\nSET('form.color #colors', 'red');\nconsole.log(window.form);\t   // undefined\n\nsetTimeout(function() {\n\tconsole.log(form.color, DEF.cl.colors);   // red [\"red\",\"green\"]\n}, 300);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTY1iM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/flags/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Flags und Path-Modifikatoren","summary":"Ändere das Verhalten eines Lese- oder Schreibvorgangs, indem du einem Path Flags und Modifikatoren hinzufügst.","markdown":"---\ntitle: Flags und Path-Modifikatoren\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/flags/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Flags und Path-Modifikatoren\n\n> Ändere das Verhalten eines Lese- oder Schreibvorgangs, indem du einem Path Flags und Modifikatoren hinzufügst.\n\nEin Path kann zusätzliche Anweisungen enthalten. Flags beginnen mit `@` und folgen nach einem Leerzeichen auf den Path, wie in `SET('price @nowatch', 5)`. Path-Modifikatoren sind Zeichen, die ändern, was die Operation macht, wie in `SET('+tags', 'red')`. Mehrere Flags lassen sich in einem Path kombinieren.\n\n## Flags für den Zustand von Komponenten\n\nKomponenten merken sich, ob der Benutzer sie berührt (`touched`) oder geändert (`modified`) hat. Diese Flags setzen diesen Zustand beim Schreiben des Werts:\n\n| Flag | Wirkung auf die Komponenten am Path |\n| --- | --- |\n| `@touch` | Markiert sie als berührt. |\n| `@change` | Markiert sie als berührt und geändert. |\n| `@modify` | Markiert sie als berührt und geändert. |\n| `@reset` | Löscht berührt und geändert. |\n| `@default` | Schreibt den Standardwert jeder Komponente und löscht berührt und geändert. |\n\n```html\n<ui-component id=\"age\" name=\"field\" path=\"person.age\" default=\"18\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar com = FIND('field');\n\t\tvar show = label => console.log(label, com.get(), 'touched=' + com.config.touched, 'modified=' + com.config.modified);\n\n\t\tSET('person.age @touch', 20);\n\t\tshow('@touch');     // @touch 20 touched=true modified=false\n\n\t\tSET('person.age @change', 30);\n\t\tshow('@change');    // @change 30 touched=true modified=true\n\n\t\tSET('person.age @reset', 40);\n\t\tshow('@reset');     // @reset 40 touched=false modified=false\n\n\t\tSET('person.age @default', 50);\n\t\tshow('@default');   // @default 18 touched=false modified=false\n\t});\n</script>\n```\n\n## Flags für Benachrichtigungen\n\n| Flag | Wirkung |\n| --- | --- |\n| `@nowatch` | Ruft die Watcher des Paths nicht auf. |\n| `@type:N` | Meldet die Zahl `N` als Typ der Änderung. |\n| `@diff` | Überspringt den Schreibvorgang, wenn der neue Wert dem aktuellen entspricht. |\n\n```js\nWATCH('price', (path, value, type) => console.log('watch', value, type));\n\nSET('price', 10);\t\t\t// watch 10 1\nSET('price @nowatch', 20);   // (no output)\nSET('price @type:5', 30);\t// watch 30 5\nSET('price @diff', 30);\t  // (no output, the value is the same)\nSET('price @diff', 40);\t  // watch 40 1\n```\n\nDas Flag `@nobind` funktioniert mit [REWRITE()](../../reference/globals/), das einen Wert speichert, ohne Komponenten zu aktualisieren. Mit dem Flag werden auch Bindungen nicht aktualisiert:\n\n```html\n<ui-bind path=\"note\" config=\"text\"></ui-bind>\n\n<script>\n\tSET('note', 'first');\n\n\tsetTimeout(function() {\n\t\tREWRITE('note @nobind', 'second');\n\t\tconsole.log(note);                                     // second\n\t\tsetTimeout(() => console.log(document.querySelector('ui-bind').textContent), 100);   // first\n\t}, 200);\n</script>\n```\n\n## Flags zum Lesen\n\n| Flag | Was `GET()` macht |\n| --- | --- |\n| `@clone` | Gibt eine Kopie des Werts zurück. |\n| `@modified` | Gibt ein Objekt nur mit den Feldern zurück, deren Komponenten berührt und geändert sind, oder `null`, wenn es keine gibt. |\n| `@reset` | Gibt den Wert zurück und löscht den Zustand der Komponenten am Path. |\n| `@update` | Gibt den Wert zurück und benachrichtigt danach alles, was vom Path abhängt. |\n\n```html\n<ui-component name=\"field\" path=\"user.name\"></ui-component>\n<ui-component name=\"field\" path=\"user.city\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('user', { name: 'Ana', city: 'Rome' });\n\n\tON('ready', function() {\n\n\t\tvar copy = GET('user @clone');\n\t\tconsole.log(copy === user);          // false\n\n\t\tSET('user.city @change', 'Oslo');\n\t\tconsole.log(GET('user @modified'));  // {\"city\":\"Oslo\"}\n\n\t\tGET('user @reset');\n\t\tconsole.log(GET('user @modified'));  // null\n\t});\n</script>\n```\n\n```js\nWATCH('stock', (path, value) => console.log('watch', value));\n\nwindow.stock = 5;\nconsole.log(GET('stock @update'));   // 5\n// watch 5\n```\n\n## Eigene Flags\n\nJeder andere Name ist ein eigenes Flag. Höre mit `ON('@flag name', fn)` darauf. Die Funktion erhält den Path, den Wert und den Typ. Eigene Flags funktionieren auch mit `EXEC()` und `EMIT()`, wobei das Path-Argument der aufgerufene Name ist.\n\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log('audit:', path, value);\n});\n\nfunction ping() {}\n\nSET('invoice.total @audit', 90);   // audit: invoice.total 90\nGET('invoice.total @audit');\t   // audit: invoice.total 90\nEXEC('ping @audit');\t\t\t   // audit: ping undefined\nEMIT('saved @audit');\t\t\t  // audit: saved undefined\n```\n\n## Zu Arrays hinzufügen und Objekte zusammenführen\n\n| Syntax | Wirkung |\n| --- | --- |\n| `SET('+path', value)` | Fügt den Wert dem Array hinzu, wie `PUSH()`. |\n| `PUSH('^path', value)` | Fügt den Wert am Anfang des Arrays hinzu. |\n| `SET('~path', object)` | Führt das Objekt mit dem aktuellen Wert zusammen, wie `EXT()`. |\n| `SET('path @extend', object)` | Führt das Objekt ebenfalls zusammen. |\n\n```js\nSET('+tags', 'red');\nSET('+tags', 'green');\nconsole.log(tags);\t\t\t// [\"red\",\"green\"]\n\nPUSH('^tags', 'first');\nconsole.log(tags);\t\t\t// [\"first\",\"red\",\"green\"]\n\nSET('user', { name: 'Ana', age: 30 });\nSET('~user', { age: 31 });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31}\n\nSET('user @extend', { city: 'Rome' });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31,\"city\":\"Rome\"}\n```\n\n## Wert umwandeln\n\nEin Pfeil nach dem Path führt einen Ausdruck auf dem Wert aus. Sowohl `-->` als auch `->` funktionieren. Mit `SET()` wird das Ergebnis gespeichert, mit `GET()` wird das Ergebnis zurückgegeben, während der gespeicherte Wert gleich bleibt. Der Ausdruck muss das Wort `value` verwenden. Dieselbe Syntax funktioniert im Attribut `path` von `<ui-bind>`.\n\n```html\n<script>\n\tSET('code --> value.toUpperCase()', 'abc');\n\tconsole.log(code);                     // ABC\n\n\tconsole.log(GET('code --> value.length'));  // 3\n\tconsole.log(GET('code -> value + \"!\"'));    // ABC!\n</script>\n<ui-bind path=\"code --> value.toLowerCase()\" config=\"text\"></ui-bind>\n```\n\n## Auf eine Codeliste warten\n\nEin `#name` nach dem Path verschiebt den Schreibvorgang, bis die Codeliste `name` geladen ist. Codelisten werden mit [CL_INIT()](../../reference/globals/) deklariert.\n\n```js\nCL_INIT('colors', function(next) {\n\tsetTimeout(() => next(['red', 'green']), 100);\n}, true);\n\nSET('form.color #colors', 'red');\nconsole.log(window.form);\t   // undefined\n\nsetTimeout(function() {\n\tconsole.log(form.color, DEF.cl.colors);   // red [\"red\",\"green\"]\n}, 300);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTY1iM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/flags/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Flags y modificadores de path","summary":"Cambia el comportamiento de una lectura o una escritura añadiendo flags y modificadores a un path.","markdown":"---\ntitle: Flags y modificadores de path\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/flags/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Flags y modificadores de path\n\n> Cambia el comportamiento de una lectura o una escritura añadiendo flags y modificadores a un path.\n\nUn path puede llevar instrucciones adicionales. Los flags empiezan por `@` y siguen al path tras un espacio, como en `SET('price @nowatch', 5)`. Los modificadores de path son caracteres que cambian lo que hace la operación, como en `SET('+tags', 'red')`. Se pueden combinar varios flags en un mismo path.\n\n## Flags para el estado de los componentes\n\nLos componentes registran si el usuario los ha tocado (`touched`) o modificado (`modified`). Estos flags establecen ese estado al escribir el valor:\n\n| Flag | Efecto en los componentes del path |\n| --- | --- |\n| `@touch` | Los marca como tocados. |\n| `@change` | Los marca como tocados y modificados. |\n| `@modify` | Los marca como tocados y modificados. |\n| `@reset` | Borra el estado de tocado y modificado. |\n| `@default` | Escribe el valor predeterminado de cada componente y borra el estado de tocado y modificado. |\n\n```html\n<ui-component id=\"age\" name=\"field\" path=\"person.age\" default=\"18\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar com = FIND('field');\n\t\tvar show = label => console.log(label, com.get(), 'touched=' + com.config.touched, 'modified=' + com.config.modified);\n\n\t\tSET('person.age @touch', 20);\n\t\tshow('@touch');     // @touch 20 touched=true modified=false\n\n\t\tSET('person.age @change', 30);\n\t\tshow('@change');    // @change 30 touched=true modified=true\n\n\t\tSET('person.age @reset', 40);\n\t\tshow('@reset');     // @reset 40 touched=false modified=false\n\n\t\tSET('person.age @default', 50);\n\t\tshow('@default');   // @default 18 touched=false modified=false\n\t});\n</script>\n```\n\n## Flags para las notificaciones\n\n| Flag | Efecto |\n| --- | --- |\n| `@nowatch` | No llama a los observadores del path. |\n| `@type:N` | Indica el número `N` como tipo del cambio. |\n| `@diff` | Omite la escritura cuando el nuevo valor es igual al actual. |\n\n```js\nWATCH('price', (path, value, type) => console.log('watch', value, type));\n\nSET('price', 10);\t\t\t// watch 10 1\nSET('price @nowatch', 20);   // (no output)\nSET('price @type:5', 30);\t// watch 30 5\nSET('price @diff', 30);\t  // (no output, the value is the same)\nSET('price @diff', 40);\t  // watch 40 1\n```\n\nEl flag `@nobind` funciona con [REWRITE()](../../reference/globals/), que guarda un valor sin actualizar los componentes. Con el flag, tampoco se actualizan los enlaces:\n\n```html\n<ui-bind path=\"note\" config=\"text\"></ui-bind>\n\n<script>\n\tSET('note', 'first');\n\n\tsetTimeout(function() {\n\t\tREWRITE('note @nobind', 'second');\n\t\tconsole.log(note);                                     // second\n\t\tsetTimeout(() => console.log(document.querySelector('ui-bind').textContent), 100);   // first\n\t}, 200);\n</script>\n```\n\n## Flags para la lectura\n\n| Flag | Qué hace `GET()` |\n| --- | --- |\n| `@clone` | Devuelve una copia del valor. |\n| `@modified` | Devuelve un objeto solo con los campos cuyos componentes están tocados y modificados, o `null` cuando no hay ninguno. |\n| `@reset` | Devuelve el valor y borra el estado de los componentes del path. |\n| `@update` | Devuelve el valor y después notifica a lo que depende del path. |\n\n```html\n<ui-component name=\"field\" path=\"user.name\"></ui-component>\n<ui-component name=\"field\" path=\"user.city\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('user', { name: 'Ana', city: 'Rome' });\n\n\tON('ready', function() {\n\n\t\tvar copy = GET('user @clone');\n\t\tconsole.log(copy === user);          // false\n\n\t\tSET('user.city @change', 'Oslo');\n\t\tconsole.log(GET('user @modified'));  // {\"city\":\"Oslo\"}\n\n\t\tGET('user @reset');\n\t\tconsole.log(GET('user @modified'));  // null\n\t});\n</script>\n```\n\n```js\nWATCH('stock', (path, value) => console.log('watch', value));\n\nwindow.stock = 5;\nconsole.log(GET('stock @update'));   // 5\n// watch 5\n```\n\n## Flags personalizados\n\nCualquier otro nombre es un flag personalizado. Escúchalo con `ON('@flag name', fn)`. La función recibe el path, el valor y el tipo. Los flags personalizados también funcionan con `EXEC()` y `EMIT()`, donde el argumento path es el nombre al que se ha llamado.\n\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log('audit:', path, value);\n});\n\nfunction ping() {}\n\nSET('invoice.total @audit', 90);   // audit: invoice.total 90\nGET('invoice.total @audit');\t   // audit: invoice.total 90\nEXEC('ping @audit');\t\t\t   // audit: ping undefined\nEMIT('saved @audit');\t\t\t  // audit: saved undefined\n```\n\n## Añadir a arrays y fusionar objetos\n\n| Sintaxis | Efecto |\n| --- | --- |\n| `SET('+path', value)` | Añade el valor al array, como `PUSH()`. |\n| `PUSH('^path', value)` | Añade el valor al inicio del array. |\n| `SET('~path', object)` | Fusiona el objeto con el valor actual, como `EXT()`. |\n| `SET('path @extend', object)` | También fusiona el objeto. |\n\n```js\nSET('+tags', 'red');\nSET('+tags', 'green');\nconsole.log(tags);\t\t\t// [\"red\",\"green\"]\n\nPUSH('^tags', 'first');\nconsole.log(tags);\t\t\t// [\"first\",\"red\",\"green\"]\n\nSET('user', { name: 'Ana', age: 30 });\nSET('~user', { age: 31 });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31}\n\nSET('user @extend', { city: 'Rome' });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31,\"city\":\"Rome\"}\n```\n\n## Transformar un valor\n\nUna flecha después del path ejecuta una expresión sobre el valor. Funcionan tanto `-->` como `->`. Con `SET()` se guarda el resultado, y con `GET()` se devuelve el resultado mientras el valor guardado sigue igual. La expresión debe usar la palabra `value`. La misma sintaxis funciona en el atributo `path` de `<ui-bind>`.\n\n```html\n<script>\n\tSET('code --> value.toUpperCase()', 'abc');\n\tconsole.log(code);                     // ABC\n\n\tconsole.log(GET('code --> value.length'));  // 3\n\tconsole.log(GET('code -> value + \"!\"'));    // ABC!\n</script>\n<ui-bind path=\"code --> value.toLowerCase()\" config=\"text\"></ui-bind>\n```\n\n## Esperar a una lista de códigos\n\nUn `#name` después del path pospone la escritura hasta que se carga la lista de códigos `name`. Las listas de códigos se declaran con [CL_INIT()](../../reference/globals/).\n\n```js\nCL_INIT('colors', function(next) {\n\tsetTimeout(() => next(['red', 'green']), 100);\n}, true);\n\nSET('form.color #colors', 'red');\nconsole.log(window.form);\t   // undefined\n\nsetTimeout(function() {\n\tconsole.log(form.color, DEF.cl.colors);   // red [\"red\",\"green\"]\n}, 300);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTY1iM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/flags/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Flags et modificateurs de path","summary":"Modifie le comportement d'une lecture ou d'une écriture en ajoutant des flags et des modificateurs à un path.","markdown":"---\ntitle: Flags et modificateurs de path\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/flags/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Flags et modificateurs de path\n\n> Modifie le comportement d'une lecture ou d'une écriture en ajoutant des flags et des modificateurs à un path.\n\nUn path peut porter des instructions supplémentaires. Les flags commencent par `@` et suivent le path après une espace, comme dans `SET('price @nowatch', 5)`. Les modificateurs de path sont des caractères qui changent ce que fait l'opération, comme dans `SET('+tags', 'red')`. Plusieurs flags peuvent être combinés dans un même path.\n\n## Flags pour l'état des composants\n\nLes composants retiennent si l'utilisateur les a touchés (`touched`) ou modifiés (`modified`). Ces flags définissent cet état pendant l'écriture de la valeur :\n\n| Flag | Effet sur les composants du path |\n| --- | --- |\n| `@touch` | Les marque comme touchés. |\n| `@change` | Les marque comme touchés et modifiés. |\n| `@modify` | Les marque comme touchés et modifiés. |\n| `@reset` | Efface les états touché et modifié. |\n| `@default` | Écrit la valeur par défaut de chaque composant et efface les états touché et modifié. |\n\n```html\n<ui-component id=\"age\" name=\"field\" path=\"person.age\" default=\"18\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar com = FIND('field');\n\t\tvar show = label => console.log(label, com.get(), 'touched=' + com.config.touched, 'modified=' + com.config.modified);\n\n\t\tSET('person.age @touch', 20);\n\t\tshow('@touch');     // @touch 20 touched=true modified=false\n\n\t\tSET('person.age @change', 30);\n\t\tshow('@change');    // @change 30 touched=true modified=true\n\n\t\tSET('person.age @reset', 40);\n\t\tshow('@reset');     // @reset 40 touched=false modified=false\n\n\t\tSET('person.age @default', 50);\n\t\tshow('@default');   // @default 18 touched=false modified=false\n\t});\n</script>\n```\n\n## Flags pour les notifications\n\n| Flag | Effet |\n| --- | --- |\n| `@nowatch` | N'appelle pas les observateurs du path. |\n| `@type:N` | Indique le nombre `N` comme type de la modification. |\n| `@diff` | Ignore l'écriture quand la nouvelle valeur est égale à la valeur actuelle. |\n\n```js\nWATCH('price', (path, value, type) => console.log('watch', value, type));\n\nSET('price', 10);\t\t\t// watch 10 1\nSET('price @nowatch', 20);   // (no output)\nSET('price @type:5', 30);\t// watch 30 5\nSET('price @diff', 30);\t  // (no output, the value is the same)\nSET('price @diff', 40);\t  // watch 40 1\n```\n\nLe flag `@nobind` fonctionne avec [REWRITE()](../../reference/globals/), qui stocke une valeur sans mettre à jour les composants. Avec ce flag, les liaisons ne sont pas mises à jour non plus :\n\n```html\n<ui-bind path=\"note\" config=\"text\"></ui-bind>\n\n<script>\n\tSET('note', 'first');\n\n\tsetTimeout(function() {\n\t\tREWRITE('note @nobind', 'second');\n\t\tconsole.log(note);                                     // second\n\t\tsetTimeout(() => console.log(document.querySelector('ui-bind').textContent), 100);   // first\n\t}, 200);\n</script>\n```\n\n## Flags pour la lecture\n\n| Flag | Ce que fait `GET()` |\n| --- | --- |\n| `@clone` | Renvoie une copie de la valeur. |\n| `@modified` | Renvoie un objet contenant uniquement les champs dont les composants sont touchés et modifiés, ou `null` s'il n'y en a aucun. |\n| `@reset` | Renvoie la valeur et efface l'état des composants du path. |\n| `@update` | Renvoie la valeur puis notifie ce qui dépend du path. |\n\n```html\n<ui-component name=\"field\" path=\"user.name\"></ui-component>\n<ui-component name=\"field\" path=\"user.city\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('user', { name: 'Ana', city: 'Rome' });\n\n\tON('ready', function() {\n\n\t\tvar copy = GET('user @clone');\n\t\tconsole.log(copy === user);          // false\n\n\t\tSET('user.city @change', 'Oslo');\n\t\tconsole.log(GET('user @modified'));  // {\"city\":\"Oslo\"}\n\n\t\tGET('user @reset');\n\t\tconsole.log(GET('user @modified'));  // null\n\t});\n</script>\n```\n\n```js\nWATCH('stock', (path, value) => console.log('watch', value));\n\nwindow.stock = 5;\nconsole.log(GET('stock @update'));   // 5\n// watch 5\n```\n\n## Flags personnalisés\n\nTout autre nom est un flag personnalisé. Écoute-le avec `ON('@flag name', fn)`. La fonction reçoit le path, la valeur et le type. Les flags personnalisés fonctionnent aussi avec `EXEC()` et `EMIT()`, où l'argument path est le nom qui a été appelé.\n\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log('audit:', path, value);\n});\n\nfunction ping() {}\n\nSET('invoice.total @audit', 90);   // audit: invoice.total 90\nGET('invoice.total @audit');\t   // audit: invoice.total 90\nEXEC('ping @audit');\t\t\t   // audit: ping undefined\nEMIT('saved @audit');\t\t\t  // audit: saved undefined\n```\n\n## Ajouter à des tableaux et fusionner des objets\n\n| Syntaxe | Effet |\n| --- | --- |\n| `SET('+path', value)` | Ajoute la valeur au tableau, comme `PUSH()`. |\n| `PUSH('^path', value)` | Ajoute la valeur au début du tableau. |\n| `SET('~path', object)` | Fusionne l'objet dans la valeur actuelle, comme `EXT()`. |\n| `SET('path @extend', object)` | Fusionne également l'objet. |\n\n```js\nSET('+tags', 'red');\nSET('+tags', 'green');\nconsole.log(tags);\t\t\t// [\"red\",\"green\"]\n\nPUSH('^tags', 'first');\nconsole.log(tags);\t\t\t// [\"first\",\"red\",\"green\"]\n\nSET('user', { name: 'Ana', age: 30 });\nSET('~user', { age: 31 });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31}\n\nSET('user @extend', { city: 'Rome' });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31,\"city\":\"Rome\"}\n```\n\n## Transformer une valeur\n\nUne flèche après le path exécute une expression sur la valeur. `-->` et `->` fonctionnent tous les deux. Avec `SET()`, le résultat est stocké ; avec `GET()`, le résultat est renvoyé et la valeur stockée reste la même. L'expression doit utiliser le mot `value`. La même syntaxe fonctionne dans l'attribut `path` de `<ui-bind>`.\n\n```html\n<script>\n\tSET('code --> value.toUpperCase()', 'abc');\n\tconsole.log(code);                     // ABC\n\n\tconsole.log(GET('code --> value.length'));  // 3\n\tconsole.log(GET('code -> value + \"!\"'));    // ABC!\n</script>\n<ui-bind path=\"code --> value.toLowerCase()\" config=\"text\"></ui-bind>\n```\n\n## Attendre une liste de codes\n\nUn `#name` après le path reporte l'écriture jusqu'au chargement de la liste de codes `name`. Les listes de codes se déclarent avec [CL_INIT()](../../reference/globals/).\n\n```js\nCL_INIT('colors', function(next) {\n\tsetTimeout(() => next(['red', 'green']), 100);\n}, true);\n\nSET('form.color #colors', 'red');\nconsole.log(window.form);\t   // undefined\n\nsetTimeout(function() {\n\tconsole.log(form.color, DEF.cl.colors);   // red [\"red\",\"green\"]\n}, 300);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTY1iM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/flags/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Flag e modificatori di path","summary":"Cambia il comportamento di una lettura o di una scrittura aggiungendo flag e modificatori a un path.","markdown":"---\ntitle: Flag e modificatori di path\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/flags/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Flag e modificatori di path\n\n> Cambia il comportamento di una lettura o di una scrittura aggiungendo flag e modificatori a un path.\n\nUn path può contenere istruzioni aggiuntive. I flag iniziano con `@` e seguono il path dopo uno spazio, come in `SET('price @nowatch', 5)`. I modificatori di path sono caratteri che cambiano ciò che fa l'operazione, come in `SET('+tags', 'red')`. In un path puoi combinare più flag.\n\n## Flag per lo stato dei componenti\n\nI componenti tengono traccia del fatto che l'utente li abbia toccati (`touched`) o modificati (`modified`). Questi flag impostano quello stato durante la scrittura del valore:\n\n| Flag | Effetto sui componenti nel path |\n| --- | --- |\n| `@touch` | Li segna come toccati. |\n| `@change` | Li segna come toccati e modificati. |\n| `@modify` | Li segna come toccati e modificati. |\n| `@reset` | Azzera gli stati toccato e modificato. |\n| `@default` | Scrive il valore predefinito di ogni componente e azzera gli stati toccato e modificato. |\n\n```html\n<ui-component id=\"age\" name=\"field\" path=\"person.age\" default=\"18\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar com = FIND('field');\n\t\tvar show = label => console.log(label, com.get(), 'touched=' + com.config.touched, 'modified=' + com.config.modified);\n\n\t\tSET('person.age @touch', 20);\n\t\tshow('@touch');     // @touch 20 touched=true modified=false\n\n\t\tSET('person.age @change', 30);\n\t\tshow('@change');    // @change 30 touched=true modified=true\n\n\t\tSET('person.age @reset', 40);\n\t\tshow('@reset');     // @reset 40 touched=false modified=false\n\n\t\tSET('person.age @default', 50);\n\t\tshow('@default');   // @default 18 touched=false modified=false\n\t});\n</script>\n```\n\n## Flag per le notifiche\n\n| Flag | Effetto |\n| --- | --- |\n| `@nowatch` | Non chiama gli osservatori del path. |\n| `@type:N` | Indica il numero `N` come tipo della modifica. |\n| `@diff` | Salta la scrittura quando il nuovo valore è uguale a quello corrente. |\n\n```js\nWATCH('price', (path, value, type) => console.log('watch', value, type));\n\nSET('price', 10);\t\t\t// watch 10 1\nSET('price @nowatch', 20);   // (no output)\nSET('price @type:5', 30);\t// watch 30 5\nSET('price @diff', 30);\t  // (no output, the value is the same)\nSET('price @diff', 40);\t  // watch 40 1\n```\n\nIl flag `@nobind` funziona con [REWRITE()](../../reference/globals/), che memorizza un valore senza aggiornare i componenti. Con il flag, non vengono aggiornate nemmeno le associazioni:\n\n```html\n<ui-bind path=\"note\" config=\"text\"></ui-bind>\n\n<script>\n\tSET('note', 'first');\n\n\tsetTimeout(function() {\n\t\tREWRITE('note @nobind', 'second');\n\t\tconsole.log(note);                                     // second\n\t\tsetTimeout(() => console.log(document.querySelector('ui-bind').textContent), 100);   // first\n\t}, 200);\n</script>\n```\n\n## Flag per la lettura\n\n| Flag | Che cosa fa `GET()` |\n| --- | --- |\n| `@clone` | Restituisce una copia del valore. |\n| `@modified` | Restituisce un oggetto con i soli campi i cui componenti sono toccati e modificati, oppure `null` quando non ce ne sono. |\n| `@reset` | Restituisce il valore e azzera lo stato dei componenti nel path. |\n| `@update` | Restituisce il valore e poi notifica ciò che dipende dal path. |\n\n```html\n<ui-component name=\"field\" path=\"user.name\"></ui-component>\n<ui-component name=\"field\" path=\"user.city\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('user', { name: 'Ana', city: 'Rome' });\n\n\tON('ready', function() {\n\n\t\tvar copy = GET('user @clone');\n\t\tconsole.log(copy === user);          // false\n\n\t\tSET('user.city @change', 'Oslo');\n\t\tconsole.log(GET('user @modified'));  // {\"city\":\"Oslo\"}\n\n\t\tGET('user @reset');\n\t\tconsole.log(GET('user @modified'));  // null\n\t});\n</script>\n```\n\n```js\nWATCH('stock', (path, value) => console.log('watch', value));\n\nwindow.stock = 5;\nconsole.log(GET('stock @update'));   // 5\n// watch 5\n```\n\n## Flag personalizzati\n\nQualsiasi altro nome è un flag personalizzato. Ascoltalo con `ON('@flag name', fn)`. La funzione riceve il path, il valore e il tipo. I flag personalizzati funzionano anche con `EXEC()` ed `EMIT()`, dove l'argomento del path è il nome chiamato.\n\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log('audit:', path, value);\n});\n\nfunction ping() {}\n\nSET('invoice.total @audit', 90);   // audit: invoice.total 90\nGET('invoice.total @audit');\t   // audit: invoice.total 90\nEXEC('ping @audit');\t\t\t   // audit: ping undefined\nEMIT('saved @audit');\t\t\t  // audit: saved undefined\n```\n\n## Aggiungi agli array e unisci gli oggetti\n\n| Sintassi | Effetto |\n| --- | --- |\n| `SET('+path', value)` | Aggiunge il valore all'array, come `PUSH()`. |\n| `PUSH('^path', value)` | Aggiunge il valore all'inizio dell'array. |\n| `SET('~path', object)` | Unisce l'oggetto al valore corrente, come `EXT()`. |\n| `SET('path @extend', object)` | Unisce anch'esso l'oggetto. |\n\n```js\nSET('+tags', 'red');\nSET('+tags', 'green');\nconsole.log(tags);\t\t\t// [\"red\",\"green\"]\n\nPUSH('^tags', 'first');\nconsole.log(tags);\t\t\t// [\"first\",\"red\",\"green\"]\n\nSET('user', { name: 'Ana', age: 30 });\nSET('~user', { age: 31 });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31}\n\nSET('user @extend', { city: 'Rome' });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31,\"city\":\"Rome\"}\n```\n\n## Trasforma un valore\n\nUna freccia dopo il path esegue un'espressione sul valore. Funzionano sia `-->` sia `->`. Con `SET()` il risultato viene memorizzato, mentre con `GET()` il risultato viene restituito e il valore memorizzato resta invariato. L'espressione deve usare la parola `value`. La stessa sintassi funziona nell'attributo `path` di `<ui-bind>`.\n\n```html\n<script>\n\tSET('code --> value.toUpperCase()', 'abc');\n\tconsole.log(code);                     // ABC\n\n\tconsole.log(GET('code --> value.length'));  // 3\n\tconsole.log(GET('code -> value + \"!\"'));    // ABC!\n</script>\n<ui-bind path=\"code --> value.toLowerCase()\" config=\"text\"></ui-bind>\n```\n\n## Attendi un elenco di codici\n\nUn `#name` dopo il path rimanda la scrittura finché non viene caricato l'elenco di codici `name`. Gli elenchi di codici si dichiarano con [CL_INIT()](../../reference/globals/).\n\n```js\nCL_INIT('colors', function(next) {\n\tsetTimeout(() => next(['red', 'green']), 100);\n}, true);\n\nSET('form.color #colors', 'red');\nconsole.log(window.form);\t   // undefined\n\nsetTimeout(function() {\n\tconsole.log(form.color, DEF.cl.colors);   // red [\"red\",\"green\"]\n}, 300);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTY1iM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/flags/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Flagy a modifikátory path","summary":"Zmeň správanie čítania alebo zápisu pridaním flagov a modifikátorov do path.","markdown":"---\ntitle: \"Flagy a modifikátory path\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/flags/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Flagy a modifikátory path\n\n> Zmeň správanie čítania alebo zápisu pridaním flagov a modifikátorov do path.\n\nPath môže niesť ďalšie pokyny. Flagy sa začínajú znakom `@` a nasledujú za path po medzere, napríklad `SET('price @nowatch', 5)`. Modifikátory path sú znaky, ktoré menia to, čo operácia robí, napríklad `SET('+tags', 'red')`. V jednom path môžeš skombinovať viacero flagov.\n\n## Flagy pre stav komponentov\n\nKomponenty si pamätajú, či sa ich používateľ dotkol (`touched`) alebo ich upravil (`modified`). Tieto flagy nastavia tento stav pri zápise hodnoty:\n\n| Flag | Účinok na komponenty na path |\n| --- | --- |\n| `@touch` | Označí ich ako dotknuté. |\n| `@change` | Označí ich ako dotknuté a upravené. |\n| `@modify` | Označí ich ako dotknuté a upravené. |\n| `@reset` | Vymaže stav dotknutia a úpravy. |\n| `@default` | Zapíše predvolenú hodnotu každého komponentu a vymaže stav dotknutia a úpravy. |\n\n```html\n<ui-component id=\"age\" name=\"field\" path=\"person.age\" default=\"18\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar com = FIND('field');\n\t\tvar show = label => console.log(label, com.get(), 'touched=' + com.config.touched, 'modified=' + com.config.modified);\n\n\t\tSET('person.age @touch', 20);\n\t\tshow('@touch');     // @touch 20 touched=true modified=false\n\n\t\tSET('person.age @change', 30);\n\t\tshow('@change');    // @change 30 touched=true modified=true\n\n\t\tSET('person.age @reset', 40);\n\t\tshow('@reset');     // @reset 40 touched=false modified=false\n\n\t\tSET('person.age @default', 50);\n\t\tshow('@default');   // @default 18 touched=false modified=false\n\t});\n</script>\n```\n\n## Flagy pre upozornenia\n\n| Flag | Účinok |\n| --- | --- |\n| `@nowatch` | Nezavolá sledovače daného path. |\n| `@type:N` | Oznámi číslo `N` ako typ zmeny. |\n| `@diff` | Preskočí zápis, keď sa nová hodnota rovná aktuálnej. |\n\n```js\nWATCH('price', (path, value, type) => console.log('watch', value, type));\n\nSET('price', 10);\t\t\t// watch 10 1\nSET('price @nowatch', 20);   // (no output)\nSET('price @type:5', 30);\t// watch 30 5\nSET('price @diff', 30);\t  // (no output, the value is the same)\nSET('price @diff', 40);\t  // watch 40 1\n```\n\nFlag `@nobind` funguje s [REWRITE()](../../reference/globals/), ktoré uloží hodnotu bez aktualizácie komponentov. S týmto flagom sa neaktualizujú ani väzby:\n\n```html\n<ui-bind path=\"note\" config=\"text\"></ui-bind>\n\n<script>\n\tSET('note', 'first');\n\n\tsetTimeout(function() {\n\t\tREWRITE('note @nobind', 'second');\n\t\tconsole.log(note);                                     // second\n\t\tsetTimeout(() => console.log(document.querySelector('ui-bind').textContent), 100);   // first\n\t}, 200);\n</script>\n```\n\n## Flagy na čítanie\n\n| Flag | Čo robí `GET()` |\n| --- | --- |\n| `@clone` | Vráti kópiu hodnoty. |\n| `@modified` | Vráti objekt iba s poľami, ktorých komponenty sú dotknuté a upravené, alebo `null`, keď také nie sú. |\n| `@reset` | Vráti hodnotu a vymaže stav komponentov na path. |\n| `@update` | Vráti hodnotu a potom upozorní to, čo závisí od daného path. |\n\n```html\n<ui-component name=\"field\" path=\"user.name\"></ui-component>\n<ui-component name=\"field\" path=\"user.city\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('user', { name: 'Ana', city: 'Rome' });\n\n\tON('ready', function() {\n\n\t\tvar copy = GET('user @clone');\n\t\tconsole.log(copy === user);          // false\n\n\t\tSET('user.city @change', 'Oslo');\n\t\tconsole.log(GET('user @modified'));  // {\"city\":\"Oslo\"}\n\n\t\tGET('user @reset');\n\t\tconsole.log(GET('user @modified'));  // null\n\t});\n</script>\n```\n\n```js\nWATCH('stock', (path, value) => console.log('watch', value));\n\nwindow.stock = 5;\nconsole.log(GET('stock @update'));   // 5\n// watch 5\n```\n\n## Vlastné flagy\n\nKaždý iný názov je vlastný flag. Počúvaj ho pomocou `ON('@flag name', fn)`. Funkcia dostane path, hodnotu a typ. Vlastné flagy fungujú aj s `EXEC()` a `EMIT()`, kde argumentom path je zavolaný názov.\n\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log('audit:', path, value);\n});\n\nfunction ping() {}\n\nSET('invoice.total @audit', 90);   // audit: invoice.total 90\nGET('invoice.total @audit');\t   // audit: invoice.total 90\nEXEC('ping @audit');\t\t\t   // audit: ping undefined\nEMIT('saved @audit');\t\t\t  // audit: saved undefined\n```\n\n## Pridávaj do polí a zlučuj objekty\n\n| Syntax | Účinok |\n| --- | --- |\n| `SET('+path', value)` | Pridá hodnotu do poľa, podobne ako `PUSH()`. |\n| `PUSH('^path', value)` | Pridá hodnotu na začiatok poľa. |\n| `SET('~path', object)` | Zlúči objekt s aktuálnou hodnotou, podobne ako `EXT()`. |\n| `SET('path @extend', object)` | Tiež zlúči objekt. |\n\n```js\nSET('+tags', 'red');\nSET('+tags', 'green');\nconsole.log(tags);\t\t\t// [\"red\",\"green\"]\n\nPUSH('^tags', 'first');\nconsole.log(tags);\t\t\t// [\"first\",\"red\",\"green\"]\n\nSET('user', { name: 'Ana', age: 30 });\nSET('~user', { age: 31 });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31}\n\nSET('user @extend', { city: 'Rome' });\nconsole.log(user);\t\t\t// {\"name\":\"Ana\",\"age\":31,\"city\":\"Rome\"}\n```\n\n## Transformuj hodnotu\n\nŠípka za path spustí nad hodnotou výraz. Fungujú `-->` aj `->`. So `SET()` sa výsledok uloží a s `GET()` sa výsledok vráti, pričom uložená hodnota zostane rovnaká. Výraz musí používať slovo `value`. Rovnaká syntax funguje v atribúte `path` elementu `<ui-bind>`.\n\n```html\n<script>\n\tSET('code --> value.toUpperCase()', 'abc');\n\tconsole.log(code);                     // ABC\n\n\tconsole.log(GET('code --> value.length'));  // 3\n\tconsole.log(GET('code -> value + \"!\"'));    // ABC!\n</script>\n<ui-bind path=\"code --> value.toLowerCase()\" config=\"text\"></ui-bind>\n```\n\n## Počkaj na zoznam kódov\n\n`#name` za path odloží zápis, kým sa nenačíta zoznam kódov `name`. Zoznamy kódov sa deklarujú pomocou [CL_INIT()](../../reference/globals/).\n\n```js\nCL_INIT('colors', function(next) {\n\tsetTimeout(() => next(['red', 'green']), 100);\n}, true);\n\nSET('form.color #colors', 'red');\nconsole.log(window.form);\t   // undefined\n\nsetTimeout(function() {\n\tconsole.log(form.color, DEF.cl.colors);   // red [\"red\",\"green\"]\n}, 300);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTU1gM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/data-binding/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Data binding","summary":"Connect HTML elements to paths with ui-bind and data-bind, without writing JavaScript.","markdown":"---\ntitle: Data binding\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/data-binding/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Data binding\n\n> Connect HTML elements to paths with ui-bind and data-bind, without writing JavaScript.\n\nData binding connects an HTML element to a [path](../paths/). When the value changes, the element updates by itself. You describe what should happen with short commands, and most pages need no extra JavaScript for it.\n\n## The ui-bind element\n\n`<ui-bind>` takes the path in the `path` attribute and a list of commands in the `config` attribute. Commands are separated by a semicolon, and each one has the form `command:value`.\n\n```html\n<p><ui-bind path=\"user.name\" config=\"text\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:(value, path) => path + ' = ' + value\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:shout\"></ui-bind></p>\n\n<script>\n\tfunction shout(value) {\n\t\treturn value + '!';\n\t}\n\n\tSET('user.name', 'Ana');\n</script>\n```\n\nThe four paragraphs show `Ana`, `ANA`, `user.name = Ana` and `Ana!`. The part after the colon can take these forms:\n\n| Form | Example | Result |\n| --- | --- | --- |\n| Nothing | `text` | The value itself. |\n| Expression | `text:value.toUpperCase()` | The result of the expression. |\n| Arrow function | `text:(value, path) => path + value` | The return value. It also receives the element as the third argument. |\n| Function name | `text:shout` | The return value of the global function `shout(value, path, element)`. |\n\nAn expression must contain the word `value`. Text without it is read as the path of a function, so a fixed string such as `text:'Hello'` is not valid.\n\n## Bind any element\n\nThe `data-bind` and `bind` attributes add a binding to an existing element. The path and the commands are separated by two underscores.\n\n```html\n<div id=\"a\" data-bind=\"user.name__text\"></div>\n<div id=\"b\" bind=\"user.name__text:value.length\"></div>\n<div id=\"c\" data-bind=\"user.name__text__title:'Name: ' + value__.long:value.length > 2\"></div>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Show and hide elements\n\n| Command | When the result is true | CSS class it uses |\n| --- | --- | --- |\n| `show` | The element is displayed, otherwise it is hidden. | `hidden` |\n| `hide` | The element is hidden. | `hidden` |\n| `visible` | The element is visible, otherwise it keeps its space but cannot be seen. | `invisible` |\n| `invisible` | The element keeps its space but cannot be seen. | `invisible` |\n\nA command that starts with a dot toggles that CSS class.\n\n```html\n<ui-bind id=\"a\" path=\"cart.count\" config=\"show:value > 0;text:value + ' items'\"></ui-bind>\n<ui-bind id=\"b\" path=\"cart.count\" config=\"hide:value > 0\">Your cart is empty</ui-bind>\n<ui-bind id=\"c\" path=\"cart.count\" config=\"visible:value > 0\">Checkout</ui-bind>\n<ui-bind id=\"d\" path=\"cart.count\" config=\".full:value >= 3;.empty:value === 0\">Status</ui-bind>\n\n<script>\n\tSET('cart.count', 0);\n</script>\n```\n\nWith a count of `0`, the first element is hidden, the second shows its text, the third is invisible and the fourth has the class `empty`. With a count of `3`, the first shows `3 items` and the fourth has the class `full`.\n\n## Update child elements\n\nAdd a CSS selector after the command to apply it to the elements inside the binding.\n\n```html\n<ui-bind id=\"card\" path=\"user\" config=\"text b:value.name;html em:value.bio;.admin i:value.admin;attr data-id:value.id\">\n\t<b></b> <em></em> <i>Administrator</i>\n</ui-bind>\n\n<script>\n\tSET('user', { id: 7, name: 'Ana', bio: '<u>Engineer</u>', admin: true });\n</script>\n```\n\nThe result is `<b>Ana</b> <em><u>Engineer</u></em> <i class=\"admin\">Administrator</i>`, and the `<ui-bind>` element receives `data-id=\"7\"`.\n\n## Content, attributes and form controls\n\n| Command | Effect |\n| --- | --- |\n| `text` | Sets the text. |\n| `html` | Sets the HTML. |\n| `value` | Sets the value of a form control. |\n| `checked` | Checks or unchecks a checkbox. |\n| `disabled` | Disables the element when the result is true. |\n| `enabled` | Enables the element when the result is true. |\n| `title` | Sets the `title` attribute. |\n| `href` | Sets the `href` attribute. |\n| `src` | Sets the `src` attribute. |\n| `attr name` | Sets the attribute `name`. |\n\n```html\n<a id=\"a\" data-bind=\"link__href:value.url__title:value.name__text:value.name\"></a>\n<img id=\"b\" data-bind=\"link.icon__src__attr alt:value\" />\n<input id=\"c\" data-bind=\"link.name__value\" />\n<input id=\"d\" type=\"checkbox\" data-bind=\"link.active__checked\" />\n<button id=\"e\" data-bind=\"link.active__disabled:!value\">Save</button>\n<button id=\"f\" data-bind=\"link.active__enabled\">Send</button>\n\n<script>\n\tSET('link', { url: '/docs/', name: 'Docs', icon: '/icon.png', active: false });\n</script>\n```\n\nOn a `<ui-bind>` element, `disabled` and `enabled` apply to the components, inputs, text areas, select boxes and buttons inside it.\n\n## Render a template\n\nThe `template` command renders a [Tangular template](../tangular/) placed in a `<script type=\"text/html\">` or `<template>` element inside the binding. The bound value is available as `value`.\n\n```html\n<ui-bind id=\"list\" path=\"todo\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t{{ foreach item in value }}\n\t\t\t<li>{{ item.name }}</li>\n\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n\n<script>\n\tSET('todo', [{ name: 'Write' }, { name: 'Test' }]);\n</script>\n```\n\n## React to clicks and changes\n\n`click` calls a function with the element, the event, the current value and the path. `exec` calls a function each time the value changes.\n\n```html\n<button id=\"save\" data-bind=\"order.id__click:save\">Save</button>\n<ui-bind path=\"order.total\" config=\"exec:ontotal\"></ui-bind>\n\n<script>\n\tfunction save(el, e, value, path) {\n\t\tconsole.log('click', el.attr('id'), e.type, value, path);\n\t}\n\n\tfunction ontotal(value, path, el) {\n\t\tconsole.log('total', value, path);\n\t}\n\n\tSET('order', { id: 100, total: 50 });\n</script>\n```\n\n## Format the output\n\n| Command | Effect |\n| --- | --- |\n| `format:2` | Formats a number with that many decimals. |\n| `format:yyyy-MM-dd` | Formats a date. |\n| `empty` | Shows `---` for an empty value. |\n| `empty:text` | Shows `text` for an empty value. |\n| `default:expression` | Uses the result of the expression when the value is `null` or `undefined`. |\n\nA `!` in front of a command skips it while the value is `null` or `undefined`, so the original content of the element stays visible.\n\n```html\n<p id=\"a\"><ui-bind path=\"p.price\" config=\"text;format:2\"></ui-bind></p>\n<p id=\"b\"><ui-bind path=\"p.date\" config=\"text;format:yyyy-MM-dd\"></ui-bind></p>\n<p id=\"c\"><ui-bind path=\"p.note\" config=\"text;empty\"></ui-bind></p>\n<p id=\"d\"><ui-bind path=\"p.note\" config=\"text;empty:Nothing yet\"></ui-bind></p>\n<p id=\"e\"><ui-bind path=\"p.note\" config=\"text;default:'Not set'\"></ui-bind></p>\n<p id=\"f\"><ui-bind path=\"p.note\" config=\"!text\">Loading</ui-bind></p>\n\n<script>\n\tSET('p', { price: 1234.5, date: new Date(2026, 0, 15), note: null });\n</script>\n```\n\nThe paragraphs show `1 234.50`, `2026-01-15`, `---`, `Nothing yet`, `Not set` and `Loading`.\n\n## Control when a binding updates\n\n| Command | Effect |\n| --- | --- |\n| `track:a,b` | On a binding to an object, reacts only to changes of the listed fields. |\n| `strict` | Ignores changes made to paths below the bound path. |\n| `once` | Runs one time only. |\n| `changes` | Runs only when the value differs from the previous one. |\n| `delay:300` | Waits this many milliseconds. |\n\n```html\n<ui-bind id=\"a\" path=\"user\" config=\"text:value.name;track:name\"></ui-bind>\n<ui-bind id=\"b\" path=\"user\" config=\"text:value.name;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"user.age\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"d\" path=\"user.age\" config=\"exec:onage;changes\"></ui-bind>\n<ui-bind id=\"e\" path=\"user.age\" config=\"text;delay:300\"></ui-bind>\n\n<script>\n\tfunction onage(value) {\n\t\tconsole.log('age changed', value);\n\t}\n\n\tSET('user', { name: 'Ana', age: 30 });\n</script>\n```\n\n## Update hidden elements\n\nCommands that change the content are skipped while `show`, `hide`, `visible` or `invisible` keep the element hidden, and they run again when it appears. A `~` in front of a command runs it anyway.\n\n```html\n<ui-bind id=\"a\" path=\"box\" config=\"show:value.open;text:value.title\"></ui-bind>\n<ui-bind id=\"b\" path=\"box\" config=\"show:value.open;~text:value.title\"></ui-bind>\n\n<script>\n\tSET('box', { open: false, title: 'Hello' });\n</script>\n```\n\nWhile the box is closed, the first element is empty and the second already contains `Hello`.\n\n## Target another element\n\nThe `element` attribute applies the binding to any element selected with a CSS selector. The `child` attribute applies it to an element inside the binding.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\" element=\"#target\"></ui-bind>\n<ui-bind id=\"wrap\" path=\"user.name\" config=\"text\" child=\"b\"><i>Name:</i> <b></b></ui-bind>\n<span id=\"target\"></span>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Pass values to a component\n\n`set` sends a value to a component inside the binding, and `config` reconfigures it. Both are useful for a component that has no path of its own.\n\n```html\n<ui-bind path=\"settings.label\" config=\"set:value.toUpperCase();config:'color:' + value\">\n\t<ui-component name=\"badge\"></ui-component>\n</ui-bind>\n\n<script>\n\tCOMPONENT('badge', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' (' + config.color + ')');\n\t\t};\n\t});\n\n\tSET('settings.label', 'red');\n</script>\n```\n\nThe component renders `RED (red)`.\n\n## Two-way binding\n\nBindings only write to the page. To send user input back to the model, use a component with an input marked with `data-jc-bind`. Typing `Ben` in this box changes `profile.name`, and the paragraph follows.\n\n```html\n<ui-component name=\"textbox\" path=\"profile.name\"></ui-component>\n<p>Hello <ui-bind path=\"profile.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('textbox', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tSET('profile.name', 'Ana');\n</script>\n```\n\n[Creating components](../creating-components/) describes how inputs work inside components.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTU1gM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/data-binding/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Datenbindung","summary":"Verbinde HTML-Elemente mit ui-bind und data-bind mit Paths, ohne JavaScript zu schreiben.","markdown":"---\ntitle: Datenbindung\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/data-binding/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Datenbindung\n\n> Verbinde HTML-Elemente mit ui-bind und data-bind mit Paths, ohne JavaScript zu schreiben.\n\nDie Datenbindung verbindet ein HTML-Element mit einem [Path](../paths/). Ändert sich der Wert, aktualisiert sich das Element von selbst. Was passieren soll, beschreibst du mit kurzen Befehlen, und die meisten Seiten brauchen dafür kein zusätzliches JavaScript.\n\n## Das Element ui-bind\n\n`<ui-bind>` erhält den Path im Attribut `path` und eine Liste von Befehlen im Attribut `config`. Befehle werden durch ein Semikolon getrennt, und jeder hat die Form `command:value`.\n\n```html\n<p><ui-bind path=\"user.name\" config=\"text\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:(value, path) => path + ' = ' + value\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:shout\"></ui-bind></p>\n\n<script>\n\tfunction shout(value) {\n\t\treturn value + '!';\n\t}\n\n\tSET('user.name', 'Ana');\n</script>\n```\n\nDie vier Absätze zeigen `Ana`, `ANA`, `user.name = Ana` und `Ana!`. Der Teil nach dem Doppelpunkt kann diese Formen annehmen:\n\n| Form | Beispiel | Ergebnis |\n| --- | --- | --- |\n| Nichts | `text` | Der Wert selbst. |\n| Ausdruck | `text:value.toUpperCase()` | Das Ergebnis des Ausdrucks. |\n| Pfeilfunktion | `text:(value, path) => path + value` | Der Rückgabewert. Als drittes Argument erhält sie außerdem das Element. |\n| Funktionsname | `text:shout` | Der Rückgabewert der globalen Funktion `shout(value, path, element)`. |\n\nEin Ausdruck muss das Wort `value` enthalten. Text ohne dieses Wort wird als Path einer Funktion gelesen, ein fester String wie `text:'Hello'` ist also nicht gültig.\n\n## Beliebiges Element binden\n\nDie Attribute `data-bind` und `bind` fügen einem vorhandenen Element eine Bindung hinzu. Path und Befehle werden durch zwei Unterstriche getrennt.\n\n```html\n<div id=\"a\" data-bind=\"user.name__text\"></div>\n<div id=\"b\" bind=\"user.name__text:value.length\"></div>\n<div id=\"c\" data-bind=\"user.name__text__title:'Name: ' + value__.long:value.length > 2\"></div>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Elemente ein- und ausblenden\n\n| Befehl | Wenn das Ergebnis wahr ist | Verwendete CSS-Klasse |\n| --- | --- | --- |\n| `show` | Das Element wird angezeigt, andernfalls ist es verborgen. | `hidden` |\n| `hide` | Das Element ist verborgen. | `hidden` |\n| `visible` | Das Element ist sichtbar, andernfalls behält es seinen Platz, ist aber nicht zu sehen. | `invisible` |\n| `invisible` | Das Element behält seinen Platz, ist aber nicht zu sehen. | `invisible` |\n\nEin Befehl, der mit einem Punkt beginnt, schaltet diese CSS-Klasse um.\n\n```html\n<ui-bind id=\"a\" path=\"cart.count\" config=\"show:value > 0;text:value + ' items'\"></ui-bind>\n<ui-bind id=\"b\" path=\"cart.count\" config=\"hide:value > 0\">Your cart is empty</ui-bind>\n<ui-bind id=\"c\" path=\"cart.count\" config=\"visible:value > 0\">Checkout</ui-bind>\n<ui-bind id=\"d\" path=\"cart.count\" config=\".full:value >= 3;.empty:value === 0\">Status</ui-bind>\n\n<script>\n\tSET('cart.count', 0);\n</script>\n```\n\nBei einer Anzahl von `0` ist das erste Element verborgen, das zweite zeigt seinen Text, das dritte ist unsichtbar und das vierte hat die Klasse `empty`. Bei einer Anzahl von `3` zeigt das erste `3 items` und das vierte hat die Klasse `full`.\n\n## Kindelemente aktualisieren\n\nFüge nach dem Befehl einen CSS-Selektor hinzu, um ihn auf die Elemente innerhalb der Bindung anzuwenden.\n\n```html\n<ui-bind id=\"card\" path=\"user\" config=\"text b:value.name;html em:value.bio;.admin i:value.admin;attr data-id:value.id\">\n\t<b></b> <em></em> <i>Administrator</i>\n</ui-bind>\n\n<script>\n\tSET('user', { id: 7, name: 'Ana', bio: '<u>Engineer</u>', admin: true });\n</script>\n```\n\nDas Ergebnis ist `<b>Ana</b> <em><u>Engineer</u></em> <i class=\"admin\">Administrator</i>`, und das Element `<ui-bind>` erhält `data-id=\"7\"`.\n\n## Inhalte, Attribute und Formularelemente\n\n| Befehl | Wirkung |\n| --- | --- |\n| `text` | Setzt den Text. |\n| `html` | Setzt das HTML. |\n| `value` | Setzt den Wert eines Formularelements. |\n| `checked` | Aktiviert oder deaktiviert eine Checkbox. |\n| `disabled` | Deaktiviert das Element, wenn das Ergebnis wahr ist. |\n| `enabled` | Aktiviert das Element, wenn das Ergebnis wahr ist. |\n| `title` | Setzt das Attribut `title`. |\n| `href` | Setzt das Attribut `href`. |\n| `src` | Setzt das Attribut `src`. |\n| `attr name` | Setzt das Attribut `name`. |\n\n```html\n<a id=\"a\" data-bind=\"link__href:value.url__title:value.name__text:value.name\"></a>\n<img id=\"b\" data-bind=\"link.icon__src__attr alt:value\" />\n<input id=\"c\" data-bind=\"link.name__value\" />\n<input id=\"d\" type=\"checkbox\" data-bind=\"link.active__checked\" />\n<button id=\"e\" data-bind=\"link.active__disabled:!value\">Save</button>\n<button id=\"f\" data-bind=\"link.active__enabled\">Send</button>\n\n<script>\n\tSET('link', { url: '/docs/', name: 'Docs', icon: '/icon.png', active: false });\n</script>\n```\n\nBei einem `<ui-bind>`-Element gelten `disabled` und `enabled` für die Komponenten, Eingabefelder, Textbereiche, Auswahlfelder und Buttons darin.\n\n## Template rendern\n\nDer Befehl `template` rendert ein [Tangular-Template](../tangular/), das in einem `<script type=\"text/html\">`- oder `<template>`-Element innerhalb der Bindung steht. Der gebundene Wert steht als `value` zur Verfügung.\n\n```html\n<ui-bind id=\"list\" path=\"todo\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t{{ foreach item in value }}\n\t\t\t<li>{{ item.name }}</li>\n\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n\n<script>\n\tSET('todo', [{ name: 'Write' }, { name: 'Test' }]);\n</script>\n```\n\n## Auf Klicks und Änderungen reagieren\n\n`click` ruft eine Funktion mit dem Element, dem Event, dem aktuellen Wert und dem Path auf. `exec` ruft jedes Mal eine Funktion auf, wenn sich der Wert ändert.\n\n```html\n<button id=\"save\" data-bind=\"order.id__click:save\">Save</button>\n<ui-bind path=\"order.total\" config=\"exec:ontotal\"></ui-bind>\n\n<script>\n\tfunction save(el, e, value, path) {\n\t\tconsole.log('click', el.attr('id'), e.type, value, path);\n\t}\n\n\tfunction ontotal(value, path, el) {\n\t\tconsole.log('total', value, path);\n\t}\n\n\tSET('order', { id: 100, total: 50 });\n</script>\n```\n\n## Ausgabe formatieren\n\n| Befehl | Wirkung |\n| --- | --- |\n| `format:2` | Formatiert eine Zahl mit so vielen Dezimalstellen. |\n| `format:yyyy-MM-dd` | Formatiert ein Datum. |\n| `empty` | Zeigt `---` bei einem leeren Wert. |\n| `empty:text` | Zeigt `text` bei einem leeren Wert. |\n| `default:expression` | Verwendet das Ergebnis des Ausdrucks, wenn der Wert `null` oder `undefined` ist. |\n\nEin `!` vor einem Befehl überspringt ihn, solange der Wert `null` oder `undefined` ist, sodass der ursprüngliche Inhalt des Elements sichtbar bleibt.\n\n```html\n<p id=\"a\"><ui-bind path=\"p.price\" config=\"text;format:2\"></ui-bind></p>\n<p id=\"b\"><ui-bind path=\"p.date\" config=\"text;format:yyyy-MM-dd\"></ui-bind></p>\n<p id=\"c\"><ui-bind path=\"p.note\" config=\"text;empty\"></ui-bind></p>\n<p id=\"d\"><ui-bind path=\"p.note\" config=\"text;empty:Nothing yet\"></ui-bind></p>\n<p id=\"e\"><ui-bind path=\"p.note\" config=\"text;default:'Not set'\"></ui-bind></p>\n<p id=\"f\"><ui-bind path=\"p.note\" config=\"!text\">Loading</ui-bind></p>\n\n<script>\n\tSET('p', { price: 1234.5, date: new Date(2026, 0, 15), note: null });\n</script>\n```\n\nDie Absätze zeigen `1 234.50`, `2026-01-15`, `---`, `Nothing yet`, `Not set` und `Loading`.\n\n## Steuern, wann eine Bindung aktualisiert wird\n\n| Befehl | Wirkung |\n| --- | --- |\n| `track:a,b` | Reagiert bei einer Bindung an ein Objekt nur auf Änderungen der aufgeführten Felder. |\n| `strict` | Ignoriert Änderungen an Paths unterhalb des gebundenen Paths. |\n| `once` | Wird nur ein einziges Mal ausgeführt. |\n| `changes` | Wird nur ausgeführt, wenn sich der Wert vom vorherigen unterscheidet. |\n| `delay:300` | Wartet so viele Millisekunden. |\n\n```html\n<ui-bind id=\"a\" path=\"user\" config=\"text:value.name;track:name\"></ui-bind>\n<ui-bind id=\"b\" path=\"user\" config=\"text:value.name;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"user.age\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"d\" path=\"user.age\" config=\"exec:onage;changes\"></ui-bind>\n<ui-bind id=\"e\" path=\"user.age\" config=\"text;delay:300\"></ui-bind>\n\n<script>\n\tfunction onage(value) {\n\t\tconsole.log('age changed', value);\n\t}\n\n\tSET('user', { name: 'Ana', age: 30 });\n</script>\n```\n\n## Verborgene Elemente aktualisieren\n\nBefehle, die den Inhalt ändern, werden übersprungen, solange `show`, `hide`, `visible` oder `invisible` das Element verbergen, und laufen erneut, sobald es erscheint. Ein `~` vor einem Befehl führt ihn trotzdem aus.\n\n```html\n<ui-bind id=\"a\" path=\"box\" config=\"show:value.open;text:value.title\"></ui-bind>\n<ui-bind id=\"b\" path=\"box\" config=\"show:value.open;~text:value.title\"></ui-bind>\n\n<script>\n\tSET('box', { open: false, title: 'Hello' });\n</script>\n```\n\nSolange die Box geschlossen ist, ist das erste Element leer und das zweite enthält bereits `Hello`.\n\n## Anderes Element ansteuern\n\nDas Attribut `element` wendet die Bindung auf ein beliebiges Element an, das ein CSS-Selektor auswählt. Das Attribut `child` wendet sie auf ein Element innerhalb der Bindung an.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\" element=\"#target\"></ui-bind>\n<ui-bind id=\"wrap\" path=\"user.name\" config=\"text\" child=\"b\"><i>Name:</i> <b></b></ui-bind>\n<span id=\"target\"></span>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Werte an eine Komponente übergeben\n\n`set` sendet einen Wert an eine Komponente innerhalb der Bindung, und `config` konfiguriert sie neu. Beides ist nützlich für eine Komponente ohne eigenen Path.\n\n```html\n<ui-bind path=\"settings.label\" config=\"set:value.toUpperCase();config:'color:' + value\">\n\t<ui-component name=\"badge\"></ui-component>\n</ui-bind>\n\n<script>\n\tCOMPONENT('badge', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' (' + config.color + ')');\n\t\t};\n\t});\n\n\tSET('settings.label', 'red');\n</script>\n```\n\nDie Komponente rendert `RED (red)`.\n\n## Zwei-Wege-Bindung\n\nBindungen schreiben nur in die Seite. Um Benutzereingaben zurück ins Modell zu senden, verwende eine Komponente mit einem Eingabefeld, das mit `data-jc-bind` markiert ist. Tippst du `Ben` in dieses Feld, ändert sich `profile.name`, und der Absatz folgt.\n\n```html\n<ui-component name=\"textbox\" path=\"profile.name\"></ui-component>\n<p>Hello <ui-bind path=\"profile.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('textbox', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tSET('profile.name', 'Ana');\n</script>\n```\n\n[Komponenten erstellen](../creating-components/) beschreibt, wie Eingabefelder in Komponenten funktionieren.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTU1gM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/data-binding/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Enlace de datos","summary":"Conecta elementos HTML con paths mediante ui-bind y data-bind, sin escribir JavaScript.","markdown":"---\ntitle: Enlace de datos\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/data-binding/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Enlace de datos\n\n> Conecta elementos HTML con paths mediante ui-bind y data-bind, sin escribir JavaScript.\n\nEl enlace de datos conecta un elemento HTML con un [path](../paths/). Cuando cambia el valor, el elemento se actualiza solo. Describes lo que debe ocurrir con comandos cortos, y la mayoría de las páginas no necesitan JavaScript adicional para ello.\n\n## El elemento ui-bind\n\n`<ui-bind>` recibe el path en el atributo `path` y una lista de comandos en el atributo `config`. Los comandos se separan con un punto y coma, y cada uno tiene la forma `command:value`.\n\n```html\n<p><ui-bind path=\"user.name\" config=\"text\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:(value, path) => path + ' = ' + value\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:shout\"></ui-bind></p>\n\n<script>\n\tfunction shout(value) {\n\t\treturn value + '!';\n\t}\n\n\tSET('user.name', 'Ana');\n</script>\n```\n\nLos cuatro párrafos muestran `Ana`, `ANA`, `user.name = Ana` y `Ana!`. La parte que sigue a los dos puntos puede tener estas formas:\n\n| Forma | Ejemplo | Resultado |\n| --- | --- | --- |\n| Nada | `text` | El propio valor. |\n| Expresión | `text:value.toUpperCase()` | El resultado de la expresión. |\n| Función flecha | `text:(value, path) => path + value` | El valor devuelto. También recibe el elemento como tercer argumento. |\n| Nombre de función | `text:shout` | El valor devuelto por la función global `shout(value, path, element)`. |\n\nUna expresión debe contener la palabra `value`. Un texto sin ella se interpreta como el path de una función, así que una cadena fija como `text:'Hello'` no es válida.\n\n## Enlazar cualquier elemento\n\nLos atributos `data-bind` y `bind` añaden un enlace a un elemento existente. El path y los comandos se separan con dos guiones bajos.\n\n```html\n<div id=\"a\" data-bind=\"user.name__text\"></div>\n<div id=\"b\" bind=\"user.name__text:value.length\"></div>\n<div id=\"c\" data-bind=\"user.name__text__title:'Name: ' + value__.long:value.length > 2\"></div>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Mostrar y ocultar elementos\n\n| Comando | Cuando el resultado es verdadero | Clase CSS que usa |\n| --- | --- | --- |\n| `show` | El elemento se muestra; en caso contrario, se oculta. | `hidden` |\n| `hide` | El elemento se oculta. | `hidden` |\n| `visible` | El elemento es visible; en caso contrario, conserva su espacio pero no se ve. | `invisible` |\n| `invisible` | El elemento conserva su espacio pero no se ve. | `invisible` |\n\nUn comando que empieza por un punto alterna esa clase CSS.\n\n```html\n<ui-bind id=\"a\" path=\"cart.count\" config=\"show:value > 0;text:value + ' items'\"></ui-bind>\n<ui-bind id=\"b\" path=\"cart.count\" config=\"hide:value > 0\">Your cart is empty</ui-bind>\n<ui-bind id=\"c\" path=\"cart.count\" config=\"visible:value > 0\">Checkout</ui-bind>\n<ui-bind id=\"d\" path=\"cart.count\" config=\".full:value >= 3;.empty:value === 0\">Status</ui-bind>\n\n<script>\n\tSET('cart.count', 0);\n</script>\n```\n\nCon un recuento de `0`, el primer elemento está oculto, el segundo muestra su texto, el tercero es invisible y el cuarto tiene la clase `empty`. Con un recuento de `3`, el primero muestra `3 items` y el cuarto tiene la clase `full`.\n\n## Actualizar elementos hijos\n\nAñade un selector CSS después del comando para aplicarlo a los elementos que hay dentro del enlace.\n\n```html\n<ui-bind id=\"card\" path=\"user\" config=\"text b:value.name;html em:value.bio;.admin i:value.admin;attr data-id:value.id\">\n\t<b></b> <em></em> <i>Administrator</i>\n</ui-bind>\n\n<script>\n\tSET('user', { id: 7, name: 'Ana', bio: '<u>Engineer</u>', admin: true });\n</script>\n```\n\nEl resultado es `<b>Ana</b> <em><u>Engineer</u></em> <i class=\"admin\">Administrator</i>`, y el elemento `<ui-bind>` recibe `data-id=\"7\"`.\n\n## Contenido, atributos y controles de formulario\n\n| Comando | Efecto |\n| --- | --- |\n| `text` | Establece el texto. |\n| `html` | Establece el HTML. |\n| `value` | Establece el valor de un control de formulario. |\n| `checked` | Marca o desmarca una casilla de verificación. |\n| `disabled` | Desactiva el elemento cuando el resultado es verdadero. |\n| `enabled` | Activa el elemento cuando el resultado es verdadero. |\n| `title` | Establece el atributo `title`. |\n| `href` | Establece el atributo `href`. |\n| `src` | Establece el atributo `src`. |\n| `attr name` | Establece el atributo `name`. |\n\n```html\n<a id=\"a\" data-bind=\"link__href:value.url__title:value.name__text:value.name\"></a>\n<img id=\"b\" data-bind=\"link.icon__src__attr alt:value\" />\n<input id=\"c\" data-bind=\"link.name__value\" />\n<input id=\"d\" type=\"checkbox\" data-bind=\"link.active__checked\" />\n<button id=\"e\" data-bind=\"link.active__disabled:!value\">Save</button>\n<button id=\"f\" data-bind=\"link.active__enabled\">Send</button>\n\n<script>\n\tSET('link', { url: '/docs/', name: 'Docs', icon: '/icon.png', active: false });\n</script>\n```\n\nEn un elemento `<ui-bind>`, `disabled` y `enabled` se aplican a los componentes, inputs, áreas de texto, cuadros de selección y botones que contiene.\n\n## Renderizar una plantilla\n\nEl comando `template` renderiza una [plantilla de Tangular](../tangular/) colocada en un elemento `<script type=\"text/html\">` o `<template>` dentro del enlace. El valor enlazado está disponible como `value`.\n\n```html\n<ui-bind id=\"list\" path=\"todo\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t{{ foreach item in value }}\n\t\t\t<li>{{ item.name }}</li>\n\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n\n<script>\n\tSET('todo', [{ name: 'Write' }, { name: 'Test' }]);\n</script>\n```\n\n## Reaccionar a clics y cambios\n\n`click` llama a una función con el elemento, el evento, el valor actual y el path. `exec` llama a una función cada vez que cambia el valor.\n\n```html\n<button id=\"save\" data-bind=\"order.id__click:save\">Save</button>\n<ui-bind path=\"order.total\" config=\"exec:ontotal\"></ui-bind>\n\n<script>\n\tfunction save(el, e, value, path) {\n\t\tconsole.log('click', el.attr('id'), e.type, value, path);\n\t}\n\n\tfunction ontotal(value, path, el) {\n\t\tconsole.log('total', value, path);\n\t}\n\n\tSET('order', { id: 100, total: 50 });\n</script>\n```\n\n## Dar formato a la salida\n\n| Comando | Efecto |\n| --- | --- |\n| `format:2` | Da formato a un número con ese número de decimales. |\n| `format:yyyy-MM-dd` | Da formato a una fecha. |\n| `empty` | Muestra `---` para un valor vacío. |\n| `empty:text` | Muestra `text` para un valor vacío. |\n| `default:expression` | Usa el resultado de la expresión cuando el valor es `null` o `undefined`. |\n\nUn `!` delante de un comando lo omite mientras el valor sea `null` o `undefined`, de modo que el contenido original del elemento sigue visible.\n\n```html\n<p id=\"a\"><ui-bind path=\"p.price\" config=\"text;format:2\"></ui-bind></p>\n<p id=\"b\"><ui-bind path=\"p.date\" config=\"text;format:yyyy-MM-dd\"></ui-bind></p>\n<p id=\"c\"><ui-bind path=\"p.note\" config=\"text;empty\"></ui-bind></p>\n<p id=\"d\"><ui-bind path=\"p.note\" config=\"text;empty:Nothing yet\"></ui-bind></p>\n<p id=\"e\"><ui-bind path=\"p.note\" config=\"text;default:'Not set'\"></ui-bind></p>\n<p id=\"f\"><ui-bind path=\"p.note\" config=\"!text\">Loading</ui-bind></p>\n\n<script>\n\tSET('p', { price: 1234.5, date: new Date(2026, 0, 15), note: null });\n</script>\n```\n\nLos párrafos muestran `1 234.50`, `2026-01-15`, `---`, `Nothing yet`, `Not set` y `Loading`.\n\n## Controlar cuándo se actualiza un enlace\n\n| Comando | Efecto |\n| --- | --- |\n| `track:a,b` | En un enlace a un objeto, reacciona solo a los cambios de los campos indicados. |\n| `strict` | Ignora los cambios hechos en paths por debajo del path enlazado. |\n| `once` | Se ejecuta una sola vez. |\n| `changes` | Se ejecuta solo cuando el valor es distinto del anterior. |\n| `delay:300` | Espera este número de milisegundos. |\n\n```html\n<ui-bind id=\"a\" path=\"user\" config=\"text:value.name;track:name\"></ui-bind>\n<ui-bind id=\"b\" path=\"user\" config=\"text:value.name;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"user.age\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"d\" path=\"user.age\" config=\"exec:onage;changes\"></ui-bind>\n<ui-bind id=\"e\" path=\"user.age\" config=\"text;delay:300\"></ui-bind>\n\n<script>\n\tfunction onage(value) {\n\t\tconsole.log('age changed', value);\n\t}\n\n\tSET('user', { name: 'Ana', age: 30 });\n</script>\n```\n\n## Actualizar elementos ocultos\n\nLos comandos que cambian el contenido se omiten mientras `show`, `hide`, `visible` o `invisible` mantienen oculto el elemento, y se vuelven a ejecutar cuando aparece. Un `~` delante de un comando lo ejecuta de todos modos.\n\n```html\n<ui-bind id=\"a\" path=\"box\" config=\"show:value.open;text:value.title\"></ui-bind>\n<ui-bind id=\"b\" path=\"box\" config=\"show:value.open;~text:value.title\"></ui-bind>\n\n<script>\n\tSET('box', { open: false, title: 'Hello' });\n</script>\n```\n\nMientras la caja está cerrada, el primer elemento está vacío y el segundo ya contiene `Hello`.\n\n## Apuntar a otro elemento\n\nEl atributo `element` aplica el enlace a cualquier elemento seleccionado con un selector CSS. El atributo `child` lo aplica a un elemento que hay dentro del enlace.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\" element=\"#target\"></ui-bind>\n<ui-bind id=\"wrap\" path=\"user.name\" config=\"text\" child=\"b\"><i>Name:</i> <b></b></ui-bind>\n<span id=\"target\"></span>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Pasar valores a un componente\n\n`set` envía un valor a un componente que hay dentro del enlace, y `config` lo reconfigura. Ambos son útiles para un componente que no tiene path propio.\n\n```html\n<ui-bind path=\"settings.label\" config=\"set:value.toUpperCase();config:'color:' + value\">\n\t<ui-component name=\"badge\"></ui-component>\n</ui-bind>\n\n<script>\n\tCOMPONENT('badge', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' (' + config.color + ')');\n\t\t};\n\t});\n\n\tSET('settings.label', 'red');\n</script>\n```\n\nEl componente renderiza `RED (red)`.\n\n## Enlace bidireccional\n\nLos enlaces solo escriben en la página. Para devolver al modelo lo que introduce el usuario, usa un componente con un input marcado con `data-jc-bind`. Al escribir `Ben` en este cuadro cambia `profile.name`, y el párrafo lo sigue.\n\n```html\n<ui-component name=\"textbox\" path=\"profile.name\"></ui-component>\n<p>Hello <ui-bind path=\"profile.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('textbox', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tSET('profile.name', 'Ana');\n</script>\n```\n\n[Crear componentes](../creating-components/) describe cómo funcionan los inputs dentro de los componentes.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTU1gM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/data-binding/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Liaison de données","summary":"Connecte des éléments HTML à des paths avec ui-bind et data-bind, sans écrire de JavaScript.","markdown":"---\ntitle: \"Liaison de données\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/data-binding/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Liaison de données\n\n> Connecte des éléments HTML à des paths avec ui-bind et data-bind, sans écrire de JavaScript.\n\nLa liaison de données connecte un élément HTML à un [path](../paths/). Quand la valeur change, l'élément se met à jour tout seul. Tu décris ce qui doit se passer avec des commandes courtes, et la plupart des pages n'ont besoin d'aucun JavaScript supplémentaire pour cela.\n\n## L'élément ui-bind\n\n`<ui-bind>` prend le path dans l'attribut `path` et une liste de commandes dans l'attribut `config`. Les commandes sont séparées par un point-virgule, et chacune a la forme `command:value`.\n\n```html\n<p><ui-bind path=\"user.name\" config=\"text\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:(value, path) => path + ' = ' + value\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:shout\"></ui-bind></p>\n\n<script>\n\tfunction shout(value) {\n\t\treturn value + '!';\n\t}\n\n\tSET('user.name', 'Ana');\n</script>\n```\n\nLes quatre paragraphes affichent `Ana`, `ANA`, `user.name = Ana` et `Ana!`. La partie située après les deux-points peut prendre ces formes :\n\n| Forme | Exemple | Résultat |\n| --- | --- | --- |\n| Rien | `text` | La valeur elle-même. |\n| Expression | `text:value.toUpperCase()` | Le résultat de l'expression. |\n| Fonction fléchée | `text:(value, path) => path + value` | La valeur renvoyée. Elle reçoit aussi l'élément comme troisième argument. |\n| Nom de fonction | `text:shout` | La valeur renvoyée par la fonction globale `shout(value, path, element)`. |\n\nUne expression doit contenir le mot `value`. Un texte qui ne le contient pas est lu comme le path d'une fonction : une chaîne fixe comme `text:'Hello'` n'est donc pas valide.\n\n## Lier n'importe quel élément\n\nLes attributs `data-bind` et `bind` ajoutent une liaison à un élément existant. Le path et les commandes sont séparés par deux tirets bas.\n\n```html\n<div id=\"a\" data-bind=\"user.name__text\"></div>\n<div id=\"b\" bind=\"user.name__text:value.length\"></div>\n<div id=\"c\" data-bind=\"user.name__text__title:'Name: ' + value__.long:value.length > 2\"></div>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Afficher et masquer des éléments\n\n| Commande | Quand le résultat est vrai | Classe CSS utilisée |\n| --- | --- | --- |\n| `show` | L'élément est affiché, sinon il est masqué. | `hidden` |\n| `hide` | L'élément est masqué. | `hidden` |\n| `visible` | L'élément est visible, sinon il conserve son espace mais ne se voit pas. | `invisible` |\n| `invisible` | L'élément conserve son espace mais ne se voit pas. | `invisible` |\n\nUne commande qui commence par un point bascule cette classe CSS.\n\n```html\n<ui-bind id=\"a\" path=\"cart.count\" config=\"show:value > 0;text:value + ' items'\"></ui-bind>\n<ui-bind id=\"b\" path=\"cart.count\" config=\"hide:value > 0\">Your cart is empty</ui-bind>\n<ui-bind id=\"c\" path=\"cart.count\" config=\"visible:value > 0\">Checkout</ui-bind>\n<ui-bind id=\"d\" path=\"cart.count\" config=\".full:value >= 3;.empty:value === 0\">Status</ui-bind>\n\n<script>\n\tSET('cart.count', 0);\n</script>\n```\n\nAvec un compteur à `0`, le premier élément est masqué, le deuxième affiche son texte, le troisième est invisible et le quatrième a la classe `empty`. Avec un compteur à `3`, le premier affiche `3 items` et le quatrième a la classe `full`.\n\n## Mettre à jour les éléments enfants\n\nAjoute un sélecteur CSS après la commande pour l'appliquer aux éléments situés dans la liaison.\n\n```html\n<ui-bind id=\"card\" path=\"user\" config=\"text b:value.name;html em:value.bio;.admin i:value.admin;attr data-id:value.id\">\n\t<b></b> <em></em> <i>Administrator</i>\n</ui-bind>\n\n<script>\n\tSET('user', { id: 7, name: 'Ana', bio: '<u>Engineer</u>', admin: true });\n</script>\n```\n\nLe résultat est `<b>Ana</b> <em><u>Engineer</u></em> <i class=\"admin\">Administrator</i>`, et l'élément `<ui-bind>` reçoit `data-id=\"7\"`.\n\n## Contenu, attributs et contrôles de formulaire\n\n| Commande | Effet |\n| --- | --- |\n| `text` | Définit le texte. |\n| `html` | Définit le HTML. |\n| `value` | Définit la valeur d'un contrôle de formulaire. |\n| `checked` | Coche ou décoche une case. |\n| `disabled` | Désactive l'élément quand le résultat est vrai. |\n| `enabled` | Active l'élément quand le résultat est vrai. |\n| `title` | Définit l'attribut `title`. |\n| `href` | Définit l'attribut `href`. |\n| `src` | Définit l'attribut `src`. |\n| `attr name` | Définit l'attribut `name`. |\n\n```html\n<a id=\"a\" data-bind=\"link__href:value.url__title:value.name__text:value.name\"></a>\n<img id=\"b\" data-bind=\"link.icon__src__attr alt:value\" />\n<input id=\"c\" data-bind=\"link.name__value\" />\n<input id=\"d\" type=\"checkbox\" data-bind=\"link.active__checked\" />\n<button id=\"e\" data-bind=\"link.active__disabled:!value\">Save</button>\n<button id=\"f\" data-bind=\"link.active__enabled\">Send</button>\n\n<script>\n\tSET('link', { url: '/docs/', name: 'Docs', icon: '/icon.png', active: false });\n</script>\n```\n\nSur un élément `<ui-bind>`, `disabled` et `enabled` s'appliquent aux composants, aux champs de saisie, aux zones de texte, aux listes déroulantes et aux boutons qu'il contient.\n\n## Afficher un modèle\n\nLa commande `template` effectue le rendu d'un [modèle Tangular](../tangular/) placé dans un élément `<script type=\"text/html\">` ou `<template>` à l'intérieur de la liaison. La valeur liée est disponible sous le nom `value`.\n\n```html\n<ui-bind id=\"list\" path=\"todo\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t{{ foreach item in value }}\n\t\t\t<li>{{ item.name }}</li>\n\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n\n<script>\n\tSET('todo', [{ name: 'Write' }, { name: 'Test' }]);\n</script>\n```\n\n## Réagir aux clics et aux modifications\n\n`click` appelle une fonction avec l'élément, l'événement, la valeur actuelle et le path. `exec` appelle une fonction chaque fois que la valeur change.\n\n```html\n<button id=\"save\" data-bind=\"order.id__click:save\">Save</button>\n<ui-bind path=\"order.total\" config=\"exec:ontotal\"></ui-bind>\n\n<script>\n\tfunction save(el, e, value, path) {\n\t\tconsole.log('click', el.attr('id'), e.type, value, path);\n\t}\n\n\tfunction ontotal(value, path, el) {\n\t\tconsole.log('total', value, path);\n\t}\n\n\tSET('order', { id: 100, total: 50 });\n</script>\n```\n\n## Formater la sortie\n\n| Commande | Effet |\n| --- | --- |\n| `format:2` | Formate un nombre avec ce nombre de décimales. |\n| `format:yyyy-MM-dd` | Formate une date. |\n| `empty` | Affiche `---` pour une valeur vide. |\n| `empty:text` | Affiche `text` pour une valeur vide. |\n| `default:expression` | Utilise le résultat de l'expression quand la valeur est `null` ou `undefined`. |\n\nUn `!` devant une commande l'ignore tant que la valeur est `null` ou `undefined` : le contenu d'origine de l'élément reste donc visible.\n\n```html\n<p id=\"a\"><ui-bind path=\"p.price\" config=\"text;format:2\"></ui-bind></p>\n<p id=\"b\"><ui-bind path=\"p.date\" config=\"text;format:yyyy-MM-dd\"></ui-bind></p>\n<p id=\"c\"><ui-bind path=\"p.note\" config=\"text;empty\"></ui-bind></p>\n<p id=\"d\"><ui-bind path=\"p.note\" config=\"text;empty:Nothing yet\"></ui-bind></p>\n<p id=\"e\"><ui-bind path=\"p.note\" config=\"text;default:'Not set'\"></ui-bind></p>\n<p id=\"f\"><ui-bind path=\"p.note\" config=\"!text\">Loading</ui-bind></p>\n\n<script>\n\tSET('p', { price: 1234.5, date: new Date(2026, 0, 15), note: null });\n</script>\n```\n\nLes paragraphes affichent `1 234.50`, `2026-01-15`, `---`, `Nothing yet`, `Not set` et `Loading`.\n\n## Contrôler quand une liaison se met à jour\n\n| Commande | Effet |\n| --- | --- |\n| `track:a,b` | Sur une liaison à un objet, réagit uniquement aux modifications des champs listés. |\n| `strict` | Ignore les modifications apportées aux paths situés sous le path lié. |\n| `once` | S'exécute une seule fois. |\n| `changes` | S'exécute uniquement quand la valeur diffère de la précédente. |\n| `delay:300` | Attend ce nombre de millisecondes. |\n\n```html\n<ui-bind id=\"a\" path=\"user\" config=\"text:value.name;track:name\"></ui-bind>\n<ui-bind id=\"b\" path=\"user\" config=\"text:value.name;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"user.age\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"d\" path=\"user.age\" config=\"exec:onage;changes\"></ui-bind>\n<ui-bind id=\"e\" path=\"user.age\" config=\"text;delay:300\"></ui-bind>\n\n<script>\n\tfunction onage(value) {\n\t\tconsole.log('age changed', value);\n\t}\n\n\tSET('user', { name: 'Ana', age: 30 });\n</script>\n```\n\n## Mettre à jour les éléments masqués\n\nLes commandes qui modifient le contenu sont ignorées tant que `show`, `hide`, `visible` ou `invisible` maintiennent l'élément masqué, et elles s'exécutent à nouveau quand il apparaît. Un `~` devant une commande l'exécute quand même.\n\n```html\n<ui-bind id=\"a\" path=\"box\" config=\"show:value.open;text:value.title\"></ui-bind>\n<ui-bind id=\"b\" path=\"box\" config=\"show:value.open;~text:value.title\"></ui-bind>\n\n<script>\n\tSET('box', { open: false, title: 'Hello' });\n</script>\n```\n\nTant que la boîte est fermée, le premier élément est vide et le second contient déjà `Hello`.\n\n## Cibler un autre élément\n\nL'attribut `element` applique la liaison à n'importe quel élément sélectionné avec un sélecteur CSS. L'attribut `child` l'applique à un élément situé dans la liaison.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\" element=\"#target\"></ui-bind>\n<ui-bind id=\"wrap\" path=\"user.name\" config=\"text\" child=\"b\"><i>Name:</i> <b></b></ui-bind>\n<span id=\"target\"></span>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Transmettre des valeurs à un composant\n\n`set` envoie une valeur à un composant situé dans la liaison, et `config` le reconfigure. Les deux sont utiles pour un composant qui n'a pas de path propre.\n\n```html\n<ui-bind path=\"settings.label\" config=\"set:value.toUpperCase();config:'color:' + value\">\n\t<ui-component name=\"badge\"></ui-component>\n</ui-bind>\n\n<script>\n\tCOMPONENT('badge', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' (' + config.color + ')');\n\t\t};\n\t});\n\n\tSET('settings.label', 'red');\n</script>\n```\n\nLe composant affiche `RED (red)`.\n\n## Liaison bidirectionnelle\n\nLes liaisons écrivent uniquement dans la page. Pour renvoyer la saisie de l'utilisateur vers le modèle de données, utilise un composant avec un champ de saisie marqué par `data-jc-bind`. Saisir `Ben` dans cette zone modifie `profile.name`, et le paragraphe suit.\n\n```html\n<ui-component name=\"textbox\" path=\"profile.name\"></ui-component>\n<p>Hello <ui-bind path=\"profile.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('textbox', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tSET('profile.name', 'Ana');\n</script>\n```\n\n[Créer des composants](../creating-components/) décrit le fonctionnement des champs de saisie dans les composants.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTU1gM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/data-binding/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Associazione dei dati","summary":"Collega gli elementi HTML ai path con ui-bind e data-bind, senza scrivere JavaScript.","markdown":"---\ntitle: Associazione dei dati\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/data-binding/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Associazione dei dati\n\n> Collega gli elementi HTML ai path con ui-bind e data-bind, senza scrivere JavaScript.\n\nL'associazione dei dati collega un elemento HTML a un [path](../paths/). Quando il valore cambia, l'elemento si aggiorna da solo. Descrivi che cosa deve succedere con comandi brevi, e nella maggior parte delle pagine non serve altro JavaScript.\n\n## L'elemento ui-bind\n\n`<ui-bind>` accetta il path nell'attributo `path` e un elenco di comandi nell'attributo `config`. I comandi sono separati da un punto e virgola e ognuno ha la forma `command:value`.\n\n```html\n<p><ui-bind path=\"user.name\" config=\"text\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:(value, path) => path + ' = ' + value\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:shout\"></ui-bind></p>\n\n<script>\n\tfunction shout(value) {\n\t\treturn value + '!';\n\t}\n\n\tSET('user.name', 'Ana');\n</script>\n```\n\nI quattro paragrafi mostrano `Ana`, `ANA`, `user.name = Ana` e `Ana!`. La parte dopo i due punti può assumere queste forme:\n\n| Forma | Esempio | Risultato |\n| --- | --- | --- |\n| Niente | `text` | Il valore stesso. |\n| Espressione | `text:value.toUpperCase()` | Il risultato dell'espressione. |\n| Funzione freccia | `text:(value, path) => path + value` | Il valore restituito. Riceve anche l'elemento come terzo argomento. |\n| Nome di funzione | `text:shout` | Il valore restituito dalla funzione globale `shout(value, path, element)`. |\n\nUn'espressione deve contenere la parola `value`. Un testo senza questa parola viene letto come il path di una funzione, quindi una stringa fissa come `text:'Hello'` non è valida.\n\n## Associa qualsiasi elemento\n\nGli attributi `data-bind` e `bind` aggiungono un'associazione a un elemento esistente. Il path e i comandi sono separati da due trattini bassi.\n\n```html\n<div id=\"a\" data-bind=\"user.name__text\"></div>\n<div id=\"b\" bind=\"user.name__text:value.length\"></div>\n<div id=\"c\" data-bind=\"user.name__text__title:'Name: ' + value__.long:value.length > 2\"></div>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Mostra e nascondi gli elementi\n\n| Comando | Quando il risultato è vero | Classe CSS usata |\n| --- | --- | --- |\n| `show` | L'elemento viene visualizzato, altrimenti è nascosto. | `hidden` |\n| `hide` | L'elemento è nascosto. | `hidden` |\n| `visible` | L'elemento è visibile, altrimenti mantiene il suo spazio ma non si vede. | `invisible` |\n| `invisible` | L'elemento mantiene il suo spazio ma non si vede. | `invisible` |\n\nUn comando che inizia con un punto attiva o disattiva quella classe CSS.\n\n```html\n<ui-bind id=\"a\" path=\"cart.count\" config=\"show:value > 0;text:value + ' items'\"></ui-bind>\n<ui-bind id=\"b\" path=\"cart.count\" config=\"hide:value > 0\">Your cart is empty</ui-bind>\n<ui-bind id=\"c\" path=\"cart.count\" config=\"visible:value > 0\">Checkout</ui-bind>\n<ui-bind id=\"d\" path=\"cart.count\" config=\".full:value >= 3;.empty:value === 0\">Status</ui-bind>\n\n<script>\n\tSET('cart.count', 0);\n</script>\n```\n\nCon un conteggio di `0`, il primo elemento è nascosto, il secondo mostra il suo testo, il terzo è invisibile e il quarto ha la classe `empty`. Con un conteggio di `3`, il primo mostra `3 items` e il quarto ha la classe `full`.\n\n## Aggiorna gli elementi figli\n\nAggiungi un selettore CSS dopo il comando per applicarlo agli elementi all'interno dell'associazione.\n\n```html\n<ui-bind id=\"card\" path=\"user\" config=\"text b:value.name;html em:value.bio;.admin i:value.admin;attr data-id:value.id\">\n\t<b></b> <em></em> <i>Administrator</i>\n</ui-bind>\n\n<script>\n\tSET('user', { id: 7, name: 'Ana', bio: '<u>Engineer</u>', admin: true });\n</script>\n```\n\nIl risultato è `<b>Ana</b> <em><u>Engineer</u></em> <i class=\"admin\">Administrator</i>`, e l'elemento `<ui-bind>` riceve `data-id=\"7\"`.\n\n## Contenuto, attributi e controlli di modulo\n\n| Comando | Effetto |\n| --- | --- |\n| `text` | Imposta il testo. |\n| `html` | Imposta l'HTML. |\n| `value` | Imposta il valore di un controllo di modulo. |\n| `checked` | Seleziona o deseleziona una casella di controllo. |\n| `disabled` | Disabilita l'elemento quando il risultato è vero. |\n| `enabled` | Abilita l'elemento quando il risultato è vero. |\n| `title` | Imposta l'attributo `title`. |\n| `href` | Imposta l'attributo `href`. |\n| `src` | Imposta l'attributo `src`. |\n| `attr name` | Imposta l'attributo `name`. |\n\n```html\n<a id=\"a\" data-bind=\"link__href:value.url__title:value.name__text:value.name\"></a>\n<img id=\"b\" data-bind=\"link.icon__src__attr alt:value\" />\n<input id=\"c\" data-bind=\"link.name__value\" />\n<input id=\"d\" type=\"checkbox\" data-bind=\"link.active__checked\" />\n<button id=\"e\" data-bind=\"link.active__disabled:!value\">Save</button>\n<button id=\"f\" data-bind=\"link.active__enabled\">Send</button>\n\n<script>\n\tSET('link', { url: '/docs/', name: 'Docs', icon: '/icon.png', active: false });\n</script>\n```\n\nSu un elemento `<ui-bind>`, `disabled` ed `enabled` si applicano ai componenti, agli input, alle aree di testo, alle caselle di selezione e ai pulsanti al suo interno.\n\n## Renderizza un template\n\nIl comando `template` renderizza un [template Tangular](../tangular/) inserito in un elemento `<script type=\"text/html\">` o `<template>` all'interno dell'associazione. Il valore associato è disponibile come `value`.\n\n```html\n<ui-bind id=\"list\" path=\"todo\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t{{ foreach item in value }}\n\t\t\t<li>{{ item.name }}</li>\n\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n\n<script>\n\tSET('todo', [{ name: 'Write' }, { name: 'Test' }]);\n</script>\n```\n\n## Reagisci a clic e modifiche\n\n`click` chiama una funzione con l'elemento, l'evento, il valore corrente e il path. `exec` chiama una funzione ogni volta che il valore cambia.\n\n```html\n<button id=\"save\" data-bind=\"order.id__click:save\">Save</button>\n<ui-bind path=\"order.total\" config=\"exec:ontotal\"></ui-bind>\n\n<script>\n\tfunction save(el, e, value, path) {\n\t\tconsole.log('click', el.attr('id'), e.type, value, path);\n\t}\n\n\tfunction ontotal(value, path, el) {\n\t\tconsole.log('total', value, path);\n\t}\n\n\tSET('order', { id: 100, total: 50 });\n</script>\n```\n\n## Formatta l'output\n\n| Comando | Effetto |\n| --- | --- |\n| `format:2` | Formatta un numero con quel numero di decimali. |\n| `format:yyyy-MM-dd` | Formatta una data. |\n| `empty` | Mostra `---` per un valore vuoto. |\n| `empty:text` | Mostra `text` per un valore vuoto. |\n| `default:expression` | Usa il risultato dell'espressione quando il valore è `null` o `undefined`. |\n\nUn `!` davanti a un comando lo salta finché il valore è `null` o `undefined`, quindi il contenuto originale dell'elemento resta visibile.\n\n```html\n<p id=\"a\"><ui-bind path=\"p.price\" config=\"text;format:2\"></ui-bind></p>\n<p id=\"b\"><ui-bind path=\"p.date\" config=\"text;format:yyyy-MM-dd\"></ui-bind></p>\n<p id=\"c\"><ui-bind path=\"p.note\" config=\"text;empty\"></ui-bind></p>\n<p id=\"d\"><ui-bind path=\"p.note\" config=\"text;empty:Nothing yet\"></ui-bind></p>\n<p id=\"e\"><ui-bind path=\"p.note\" config=\"text;default:'Not set'\"></ui-bind></p>\n<p id=\"f\"><ui-bind path=\"p.note\" config=\"!text\">Loading</ui-bind></p>\n\n<script>\n\tSET('p', { price: 1234.5, date: new Date(2026, 0, 15), note: null });\n</script>\n```\n\nI paragrafi mostrano `1 234.50`, `2026-01-15`, `---`, `Nothing yet`, `Not set` e `Loading`.\n\n## Controlla quando si aggiorna un'associazione\n\n| Comando | Effetto |\n| --- | --- |\n| `track:a,b` | In un'associazione a un oggetto, reagisce solo alle modifiche dei campi elencati. |\n| `strict` | Ignora le modifiche fatte ai path sotto il path associato. |\n| `once` | Viene eseguito una sola volta. |\n| `changes` | Viene eseguito solo quando il valore è diverso dal precedente. |\n| `delay:300` | Attende questo numero di millisecondi. |\n\n```html\n<ui-bind id=\"a\" path=\"user\" config=\"text:value.name;track:name\"></ui-bind>\n<ui-bind id=\"b\" path=\"user\" config=\"text:value.name;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"user.age\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"d\" path=\"user.age\" config=\"exec:onage;changes\"></ui-bind>\n<ui-bind id=\"e\" path=\"user.age\" config=\"text;delay:300\"></ui-bind>\n\n<script>\n\tfunction onage(value) {\n\t\tconsole.log('age changed', value);\n\t}\n\n\tSET('user', { name: 'Ana', age: 30 });\n</script>\n```\n\n## Aggiorna gli elementi nascosti\n\nI comandi che modificano il contenuto vengono saltati mentre `show`, `hide`, `visible` o `invisible` mantengono nascosto l'elemento, e vengono rieseguiti quando l'elemento appare. Un `~` davanti a un comando lo esegue comunque.\n\n```html\n<ui-bind id=\"a\" path=\"box\" config=\"show:value.open;text:value.title\"></ui-bind>\n<ui-bind id=\"b\" path=\"box\" config=\"show:value.open;~text:value.title\"></ui-bind>\n\n<script>\n\tSET('box', { open: false, title: 'Hello' });\n</script>\n```\n\nMentre il riquadro è chiuso, il primo elemento è vuoto e il secondo contiene già `Hello`.\n\n## Punta a un altro elemento\n\nL'attributo `element` applica l'associazione a qualsiasi elemento selezionato con un selettore CSS. L'attributo `child` la applica a un elemento all'interno dell'associazione.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\" element=\"#target\"></ui-bind>\n<ui-bind id=\"wrap\" path=\"user.name\" config=\"text\" child=\"b\"><i>Name:</i> <b></b></ui-bind>\n<span id=\"target\"></span>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Passa i valori a un componente\n\n`set` invia un valore a un componente all'interno dell'associazione, e `config` lo riconfigura. Entrambi sono utili per un componente che non ha un proprio path.\n\n```html\n<ui-bind path=\"settings.label\" config=\"set:value.toUpperCase();config:'color:' + value\">\n\t<ui-component name=\"badge\"></ui-component>\n</ui-bind>\n\n<script>\n\tCOMPONENT('badge', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' (' + config.color + ')');\n\t\t};\n\t});\n\n\tSET('settings.label', 'red');\n</script>\n```\n\nIl componente renderizza `RED (red)`.\n\n## Associazione bidirezionale\n\nLe associazioni scrivono solo nella pagina. Per riportare l'input dell'utente nel modello, usa un componente con un input contrassegnato da `data-jc-bind`. Digitando `Ben` in questa casella, `profile.name` cambia e il paragrafo si aggiorna di conseguenza.\n\n```html\n<ui-component name=\"textbox\" path=\"profile.name\"></ui-component>\n<p>Hello <ui-bind path=\"profile.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('textbox', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tSET('profile.name', 'Ana');\n</script>\n```\n\n[Creare componenti](../creating-components/) descrive come funzionano gli input all'interno dei componenti.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTU1gM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/data-binding/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Dátová väzba","summary":"Prepoj elementy HTML s paths pomocou ui-bind a data-bind bez písania JavaScriptu.","markdown":"---\ntitle: \"Dátová väzba\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/data-binding/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Dátová väzba\n\n> Prepoj elementy HTML s paths pomocou ui-bind a data-bind bez písania JavaScriptu.\n\nDátová väzba prepája element HTML s [path](../paths/). Keď sa hodnota zmení, element sa aktualizuje sám. Čo sa má stať, opíšeš krátkymi príkazmi a väčšina stránok na to nepotrebuje ďalší JavaScript.\n\n## Element ui-bind\n\n`<ui-bind>` berie path z atribútu `path` a zoznam príkazov z atribútu `config`. Príkazy sa oddeľujú bodkočiarkou a každý má tvar `command:value`.\n\n```html\n<p><ui-bind path=\"user.name\" config=\"text\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:(value, path) => path + ' = ' + value\"></ui-bind></p>\n<p><ui-bind path=\"user.name\" config=\"text:shout\"></ui-bind></p>\n\n<script>\n\tfunction shout(value) {\n\t\treturn value + '!';\n\t}\n\n\tSET('user.name', 'Ana');\n</script>\n```\n\nŠtyri odseky zobrazia `Ana`, `ANA`, `user.name = Ana` a `Ana!`. Časť za dvojbodkou môže mať tieto tvary:\n\n| Tvar | Príklad | Výsledok |\n| --- | --- | --- |\n| Nič | `text` | Samotná hodnota. |\n| Výraz | `text:value.toUpperCase()` | Výsledok výrazu. |\n| Šípková funkcia | `text:(value, path) => path + value` | Vrátená hodnota. Ako tretí argument dostane aj element. |\n| Názov funkcie | `text:shout` | Návratová hodnota globálnej funkcie `shout(value, path, element)`. |\n\nVýraz musí obsahovať slovo `value`. Text bez neho sa číta ako path funkcie, takže pevný reťazec ako `text:'Hello'` nie je platný.\n\n## Naviaž ľubovoľný element\n\nAtribúty `data-bind` a `bind` pridajú väzbu k existujúcemu elementu. Path a príkazy sa oddeľujú dvoma podčiarkovníkmi.\n\n```html\n<div id=\"a\" data-bind=\"user.name__text\"></div>\n<div id=\"b\" bind=\"user.name__text:value.length\"></div>\n<div id=\"c\" data-bind=\"user.name__text__title:'Name: ' + value__.long:value.length > 2\"></div>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Zobrazuj a skrývaj elementy\n\n| Príkaz | Keď je výsledok pravdivý | Použitá trieda CSS |\n| --- | --- | --- |\n| `show` | Element sa zobrazí, inak je skrytý. | `hidden` |\n| `hide` | Element je skrytý. | `hidden` |\n| `visible` | Element je viditeľný, inak si zachová miesto, ale nie je ho vidieť. | `invisible` |\n| `invisible` | Element si zachová miesto, ale nie je ho vidieť. | `invisible` |\n\nPríkaz, ktorý sa začína bodkou, prepína danú triedu CSS.\n\n```html\n<ui-bind id=\"a\" path=\"cart.count\" config=\"show:value > 0;text:value + ' items'\"></ui-bind>\n<ui-bind id=\"b\" path=\"cart.count\" config=\"hide:value > 0\">Your cart is empty</ui-bind>\n<ui-bind id=\"c\" path=\"cart.count\" config=\"visible:value > 0\">Checkout</ui-bind>\n<ui-bind id=\"d\" path=\"cart.count\" config=\".full:value >= 3;.empty:value === 0\">Status</ui-bind>\n\n<script>\n\tSET('cart.count', 0);\n</script>\n```\n\nPri počte `0` je prvý element skrytý, druhý zobrazuje svoj text, tretí je neviditeľný a štvrtý má triedu `empty`. Pri počte `3` prvý zobrazuje `3 items` a štvrtý má triedu `full`.\n\n## Aktualizuj podradené elementy\n\nPridaj za príkaz selektor CSS a príkaz sa použije na elementy vnútri väzby.\n\n```html\n<ui-bind id=\"card\" path=\"user\" config=\"text b:value.name;html em:value.bio;.admin i:value.admin;attr data-id:value.id\">\n\t<b></b> <em></em> <i>Administrator</i>\n</ui-bind>\n\n<script>\n\tSET('user', { id: 7, name: 'Ana', bio: '<u>Engineer</u>', admin: true });\n</script>\n```\n\nVýsledkom je `<b>Ana</b> <em><u>Engineer</u></em> <i class=\"admin\">Administrator</i>` a element `<ui-bind>` dostane `data-id=\"7\"`.\n\n## Obsah, atribúty a ovládacie prvky formulára\n\n| Príkaz | Účinok |\n| --- | --- |\n| `text` | Nastaví text. |\n| `html` | Nastaví HTML. |\n| `value` | Nastaví hodnotu ovládacieho prvku formulára. |\n| `checked` | Zaškrtne alebo odškrtne zaškrtávacie políčko. |\n| `disabled` | Zakáže element, keď je výsledok pravdivý. |\n| `enabled` | Povolí element, keď je výsledok pravdivý. |\n| `title` | Nastaví atribút `title`. |\n| `href` | Nastaví atribút `href`. |\n| `src` | Nastaví atribút `src`. |\n| `attr name` | Nastaví atribút `name`. |\n\n```html\n<a id=\"a\" data-bind=\"link__href:value.url__title:value.name__text:value.name\"></a>\n<img id=\"b\" data-bind=\"link.icon__src__attr alt:value\" />\n<input id=\"c\" data-bind=\"link.name__value\" />\n<input id=\"d\" type=\"checkbox\" data-bind=\"link.active__checked\" />\n<button id=\"e\" data-bind=\"link.active__disabled:!value\">Save</button>\n<button id=\"f\" data-bind=\"link.active__enabled\">Send</button>\n\n<script>\n\tSET('link', { url: '/docs/', name: 'Docs', icon: '/icon.png', active: false });\n</script>\n```\n\nNa elemente `<ui-bind>` sa `disabled` a `enabled` vzťahujú na komponenty, vstupné polia, textové oblasti, výberové polia a tlačidlá vnútri neho.\n\n## Vykresli šablónu\n\nPríkaz `template` vykreslí [šablónu Tangular](../tangular/) umiestnenú v elemente `<script type=\"text/html\">` alebo `<template>` vnútri väzby. Naviazaná hodnota je dostupná ako `value`.\n\n```html\n<ui-bind id=\"list\" path=\"todo\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t{{ foreach item in value }}\n\t\t\t<li>{{ item.name }}</li>\n\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n\n<script>\n\tSET('todo', [{ name: 'Write' }, { name: 'Test' }]);\n</script>\n```\n\n## Reaguj na kliknutia a zmeny\n\n`click` zavolá funkciu s elementom, udalosťou, aktuálnou hodnotou a path. `exec` zavolá funkciu pri každej zmene hodnoty.\n\n```html\n<button id=\"save\" data-bind=\"order.id__click:save\">Save</button>\n<ui-bind path=\"order.total\" config=\"exec:ontotal\"></ui-bind>\n\n<script>\n\tfunction save(el, e, value, path) {\n\t\tconsole.log('click', el.attr('id'), e.type, value, path);\n\t}\n\n\tfunction ontotal(value, path, el) {\n\t\tconsole.log('total', value, path);\n\t}\n\n\tSET('order', { id: 100, total: 50 });\n</script>\n```\n\n## Naformátuj výstup\n\n| Príkaz | Účinok |\n| --- | --- |\n| `format:2` | Naformátuje číslo na daný počet desatinných miest. |\n| `format:yyyy-MM-dd` | Naformátuje dátum. |\n| `empty` | Pri prázdnej hodnote zobrazí `---`. |\n| `empty:text` | Pri prázdnej hodnote zobrazí `text`. |\n| `default:expression` | Použije výsledok výrazu, keď je hodnota `null` alebo `undefined`. |\n\nZnak `!` pred príkazom ho preskočí, kým je hodnota `null` alebo `undefined`, takže pôvodný obsah elementu zostane viditeľný.\n\n```html\n<p id=\"a\"><ui-bind path=\"p.price\" config=\"text;format:2\"></ui-bind></p>\n<p id=\"b\"><ui-bind path=\"p.date\" config=\"text;format:yyyy-MM-dd\"></ui-bind></p>\n<p id=\"c\"><ui-bind path=\"p.note\" config=\"text;empty\"></ui-bind></p>\n<p id=\"d\"><ui-bind path=\"p.note\" config=\"text;empty:Nothing yet\"></ui-bind></p>\n<p id=\"e\"><ui-bind path=\"p.note\" config=\"text;default:'Not set'\"></ui-bind></p>\n<p id=\"f\"><ui-bind path=\"p.note\" config=\"!text\">Loading</ui-bind></p>\n\n<script>\n\tSET('p', { price: 1234.5, date: new Date(2026, 0, 15), note: null });\n</script>\n```\n\nOdseky zobrazia `1 234.50`, `2026-01-15`, `---`, `Nothing yet`, `Not set` a `Loading`.\n\n## Riaď, kedy sa väzba aktualizuje\n\n| Príkaz | Účinok |\n| --- | --- |\n| `track:a,b` | Pri väzbe na objekt reaguje iba na zmeny uvedených polí. |\n| `strict` | Ignoruje zmeny v paths pod naviazaným path. |\n| `once` | Spustí sa iba raz. |\n| `changes` | Spustí sa iba vtedy, keď sa hodnota líši od predchádzajúcej. |\n| `delay:300` | Počká tento počet milisekúnd. |\n\n```html\n<ui-bind id=\"a\" path=\"user\" config=\"text:value.name;track:name\"></ui-bind>\n<ui-bind id=\"b\" path=\"user\" config=\"text:value.name;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"user.age\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"d\" path=\"user.age\" config=\"exec:onage;changes\"></ui-bind>\n<ui-bind id=\"e\" path=\"user.age\" config=\"text;delay:300\"></ui-bind>\n\n<script>\n\tfunction onage(value) {\n\t\tconsole.log('age changed', value);\n\t}\n\n\tSET('user', { name: 'Ana', age: 30 });\n</script>\n```\n\n## Aktualizuj skryté elementy\n\nPríkazy, ktoré menia obsah, sa preskakujú, kým `show`, `hide`, `visible` alebo `invisible` držia element skrytý, a znova sa spustia, keď sa objaví. Znak `~` pred príkazom ho spustí aj tak.\n\n```html\n<ui-bind id=\"a\" path=\"box\" config=\"show:value.open;text:value.title\"></ui-bind>\n<ui-bind id=\"b\" path=\"box\" config=\"show:value.open;~text:value.title\"></ui-bind>\n\n<script>\n\tSET('box', { open: false, title: 'Hello' });\n</script>\n```\n\nKým je box zatvorený, prvý element je prázdny a druhý už obsahuje `Hello`.\n\n## Zacieľ iný element\n\nAtribút `element` použije väzbu na ľubovoľný element vybraný selektorom CSS. Atribút `child` ju použije na element vnútri väzby.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\" element=\"#target\"></ui-bind>\n<ui-bind id=\"wrap\" path=\"user.name\" config=\"text\" child=\"b\"><i>Name:</i> <b></b></ui-bind>\n<span id=\"target\"></span>\n\n<script>\n\tSET('user.name', 'Ana');\n</script>\n```\n\n## Odovzdaj hodnoty komponentu\n\n`set` pošle hodnotu komponentu vnútri väzby a `config` ho prekonfiguruje. Oba sú užitočné pre komponent, ktorý nemá vlastný path.\n\n```html\n<ui-bind path=\"settings.label\" config=\"set:value.toUpperCase();config:'color:' + value\">\n\t<ui-component name=\"badge\"></ui-component>\n</ui-bind>\n\n<script>\n\tCOMPONENT('badge', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' (' + config.color + ')');\n\t\t};\n\t});\n\n\tSET('settings.label', 'red');\n</script>\n```\n\nKomponent vykreslí `RED (red)`.\n\n## Obojsmerná väzba\n\nVäzby iba zapisujú na stránku. Ak chceš poslať vstup používateľa späť do modelu, použi komponent so vstupným poľom označeným `data-jc-bind`. Keď do tohto poľa napíšeš `Ben`, zmení sa `profile.name` a odsek ho nasleduje.\n\n```html\n<ui-component name=\"textbox\" path=\"profile.name\"></ui-component>\n<p>Hello <ui-bind path=\"profile.name\" config=\"text\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('textbox', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n\n\tSET('profile.name', 'Ana');\n</script>\n```\n\nAko fungujú vstupné polia vnútri komponentov, opisuje časť [Vytváranie komponentov](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammU322M61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/scopes/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Scopes","summary":"Give a part of the page its own base path, so the same markup can work with different data.","markdown":"---\ntitle: Scopes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/scopes/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Scopes\n\n> Give a part of the page its own base path, so the same markup can work with different data.\n\nA scope gives a part of the page its own base path. Inside it, the `?` character stands for that path. The same markup can then be reused with different data, and a block of the page does not need to know where its data is stored.\n\n## Create a scope\n\nWrap the markup in a `<ui-plugin>` element and start the inner paths with `?`.\n\n```html\n<ui-plugin path=\"billing\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<ui-plugin path=\"shipping\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(self.path + ' = ' + value);\n\t\t};\n\t});\n\n\tSET('billing', { name: 'Ana', vat: 'A1' });\n\tSET('shipping', { name: 'Ben', vat: 'B2' });\n</script>\n```\n\nThe first block shows `Ana billing.vat = A1` and the second `Ben shipping.vat = B2`. Using `?` outside a scope is an error: the browser console shows the warning `Missing <ui-plugin>` and the binding is not created.\n\n## Nested scopes\n\nA scope inside another scope extends the path of its parent. A `!` in front of the name makes the scope isolated, so it ignores the parent. `?1` refers to the parent scope, `?2` to the parent of the parent, and so on.\n\n```html\n<ui-plugin id=\"order\" path=\"order\">\n\t<ui-plugin id=\"address\" path=\"address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t\t<ui-bind id=\"ref\" path=\"?1.ref\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n\t<ui-plugin id=\"shared\" path=\"!shared\">\n\t\t<ui-bind id=\"note\" path=\"?.note\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n\n<script>\n\tSET('order', { ref: 'R-1', address: { city: 'Rome' } });\n\tSET('shared.note', 'Isolated');\n</script>\n```\n\n| Element | Path of the scope |\n| --- | --- |\n| `<ui-plugin path=\"order\">` | `order` |\n| `<ui-plugin path=\"address\">` inside it | `order.address` |\n| `<ui-plugin path=\"!shared\">` inside it | `shared` |\n\nIn the example `?.city` reads `order.address.city`, and `?1.ref` reads `order.ref`.\n\n## Configure a scope\n\n| Attribute or setting | Effect |\n| --- | --- |\n| `path=\"?\"` | Generates a unique name for the scope. |\n| `default=\"{ ... }\"` | Stores this value at the path of the scope when the scope is created. |\n| `config=\"init:name\"` | Calls the global function `name(path, element)` when the scope is created. |\n| `config=\"aclass:1\"` | Adds the path of the scope as a CSS class on the element. |\n| `config=\"class:name\"` | Toggles a CSS class on the element shortly after it is created. |\n\n```html\n<ui-plugin path=\"?\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"login\" default=\"{ user: 'guest', remember: false }\" config=\"init:loginready;aclass:1;class:ready\">\n\t<ui-bind id=\"b\" path=\"?.user\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tfunction loginready(path, element) {\n\t\tconsole.log('init', path, element.prop('tagName'));\n\t}\n</script>\n```\n\nThe second scope stores `{\"user\":\"guest\",\"remember\":false}` in `login`, and its element receives the classes `login` and `ready`.\n\n## Use an existing element as a scope\n\nThe attributes `scope`, `plugin` and `data-scope` turn any element into a scope.\n\n```html\n<section scope=\"panel\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</section>\n\n<div plugin=\"sidebar\">\n\t<ui-bind id=\"b\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<div data-scope=\"footer\">\n\t<ui-bind id=\"c\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<script>\n\tSET('panel.title', 'Panel');\n\tSET('sidebar.title', 'Sidebar');\n\tSET('footer.title', 'Footer');\n</script>\n```\n\n## Work with a scope in code\n\n`$(element).scope()` returns the scope that an element belongs to. Paths given to its methods are relative to the scope.\n\n```html\n<ui-plugin id=\"panel\" path=\"form\">\n\t<ui-component name=\"field\" path=\"?.name\"></ui-component>\n\t<ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar scope = $('#panel').scope();\n\n\t\tconsole.log(scope.path);                // form\n\t\tconsole.log(scope.makepath('?.name'));  // form.name\n\n\t\tscope.watch('name', (path, value) => console.log('watch', path, value));\n\n\t\tscope.set('name', 'Ana');               // watch form.name Ana\n\t\tscope.set('city', 'Rome');\n\t\tconsole.log(scope.get('name'));         // Ana\n\t\tconsole.log(scope.get());               // {\"name\":\"Ana\",\"city\":\"Rome\"}\n\n\t\tscope.push('tags', 'new');\n\t\tconsole.log(form.tags);                 // [\"new\"]\n\n\t\tconsole.log(scope.FIND('field').path);  // form.name\n\t});\n</script>\n```\n\n| Member | Description |\n| --- | --- |\n| `path` | The full path of the scope. |\n| `element` | The element of the scope, as a jQuery object. |\n| `parent` | The parent scope. |\n| `makepath(path)` | Replaces `?` with the path of the scope. |\n| `get([path])` | Reads a value. Without a path it returns the whole object. |\n| `set(path, value)` | Writes a value. |\n| `push(path, value)` | Adds a value to an array. |\n| `update(path)` | Notifies the dependents of a path. |\n| `watch(path, fn, [init])` | Watches a path. |\n| `FIND(selector)` | Finds a component inside the scope. |\n| `SETTER(selector, method, ...)` | Calls a method of the components inside the scope. |\n\nThe [Scope](../../reference/scope/) reference lists all the members.\n\n## Connect a plugin\n\nA [plugin](../plugins/) with the same name as the scope holds the logic of that part of the page. Inside the scope, `?/name` refers to a function of the plugin, and `?` in the code of the plugin stands for its path.\n\n```html\n<ui-plugin path=\"contact\">\n\t<button id=\"save\" data-bind=\"?.name__click:?/save\">Save</button>\n\t<ui-bind id=\"label\" path=\"?.name\" config=\"text:?/format\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tPLUGIN('contact', function(exports) {\n\n\t\texports.format = function(value) {\n\t\t\treturn (value || '').toUpperCase();\n\t\t};\n\n\t\texports.save = function(el, e, value, path) {\n\t\t\tconsole.log('saving', value, 'from', path);\n\t\t\tSET('?.saved', true);\n\t\t};\n\t});\n\n\tSET('contact.name', 'Ana');\n</script>\n```\n\nThe label shows `ANA`. Clicking the button prints `saving Ana from contact.name` and stores `true` in `contact.saved`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammU322M61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/scopes/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Scopes","summary":"Gib einem Teil der Seite einen eigenen Basis-Path, damit dasselbe Markup mit unterschiedlichen Daten arbeiten kann.","markdown":"---\ntitle: Scopes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/scopes/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Scopes\n\n> Gib einem Teil der Seite einen eigenen Basis-Path, damit dasselbe Markup mit unterschiedlichen Daten arbeiten kann.\n\nEin Scope gibt einem Teil der Seite einen eigenen Basis-Path. Innerhalb des Scopes steht das Zeichen `?` für diesen Path. So kannst du dasselbe Markup mit anderen Daten wiederverwenden, und ein Block der Seite muss nicht wissen, wo seine Daten gespeichert sind.\n\n## Einen Scope erstellen\n\nUmschließe das Markup mit einem `<ui-plugin>`-Element und beginne die inneren Paths mit `?`.\n\n```html\n<ui-plugin path=\"billing\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<ui-plugin path=\"shipping\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(self.path + ' = ' + value);\n\t\t};\n\t});\n\n\tSET('billing', { name: 'Ana', vat: 'A1' });\n\tSET('shipping', { name: 'Ben', vat: 'B2' });\n</script>\n```\n\nDer erste Block zeigt `Ana billing.vat = A1` und der zweite `Ben shipping.vat = B2`. Außerhalb eines Scopes ist `?` ein Fehler: Die Browserkonsole zeigt die Warnung `Missing <ui-plugin>`, und die Bindung wird nicht erstellt.\n\n## Verschachtelte Scopes\n\nEin Scope innerhalb eines anderen Scopes erweitert den Path seines übergeordneten Scopes. Ein `!` vor dem Namen macht den Scope isoliert, sodass er den übergeordneten Scope ignoriert. `?1` verweist auf den übergeordneten Scope, `?2` auf dessen übergeordneten Scope und so weiter.\n\n```html\n<ui-plugin id=\"order\" path=\"order\">\n\t<ui-plugin id=\"address\" path=\"address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t\t<ui-bind id=\"ref\" path=\"?1.ref\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n\t<ui-plugin id=\"shared\" path=\"!shared\">\n\t\t<ui-bind id=\"note\" path=\"?.note\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n\n<script>\n\tSET('order', { ref: 'R-1', address: { city: 'Rome' } });\n\tSET('shared.note', 'Isolated');\n</script>\n```\n\n| Element | Path des Scopes |\n| --- | --- |\n| `<ui-plugin path=\"order\">` | `order` |\n| `<ui-plugin path=\"address\">` darin | `order.address` |\n| `<ui-plugin path=\"!shared\">` darin | `shared` |\n\nIm Beispiel liest `?.city` den Wert `order.address.city` und `?1.ref` den Wert `order.ref`.\n\n## Einen Scope konfigurieren\n\n| Attribut oder Einstellung | Wirkung |\n| --- | --- |\n| `path=\"?\"` | Erzeugt einen eindeutigen Namen für den Scope. |\n| `default=\"{ ... }\"` | Speichert diesen Wert beim Erstellen des Scopes unter dessen Path. |\n| `config=\"init:name\"` | Ruft beim Erstellen des Scopes die globale Funktion `name(path, element)` auf. |\n| `config=\"aclass:1\"` | Fügt dem Element den Path des Scopes als CSS-Klasse hinzu. |\n| `config=\"class:name\"` | Schaltet kurz nach dem Erstellen eine CSS-Klasse am Element um. |\n\n```html\n<ui-plugin path=\"?\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"login\" default=\"{ user: 'guest', remember: false }\" config=\"init:loginready;aclass:1;class:ready\">\n\t<ui-bind id=\"b\" path=\"?.user\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tfunction loginready(path, element) {\n\t\tconsole.log('init', path, element.prop('tagName'));\n\t}\n</script>\n```\n\nDer zweite Scope speichert `{\"user\":\"guest\",\"remember\":false}` in `login`, und sein Element erhält die Klassen `login` und `ready`.\n\n## Ein vorhandenes Element als Scope verwenden\n\nDie Attribute `scope`, `plugin` und `data-scope` machen aus jedem Element einen Scope.\n\n```html\n<section scope=\"panel\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</section>\n\n<div plugin=\"sidebar\">\n\t<ui-bind id=\"b\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<div data-scope=\"footer\">\n\t<ui-bind id=\"c\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<script>\n\tSET('panel.title', 'Panel');\n\tSET('sidebar.title', 'Sidebar');\n\tSET('footer.title', 'Footer');\n</script>\n```\n\n## Im Code mit einem Scope arbeiten\n\n`$(element).scope()` gibt den Scope zurück, zu dem ein Element gehört. Paths, die du seinen Methoden übergibst, sind relativ zum Scope.\n\n```html\n<ui-plugin id=\"panel\" path=\"form\">\n\t<ui-component name=\"field\" path=\"?.name\"></ui-component>\n\t<ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar scope = $('#panel').scope();\n\n\t\tconsole.log(scope.path);                // form\n\t\tconsole.log(scope.makepath('?.name'));  // form.name\n\n\t\tscope.watch('name', (path, value) => console.log('watch', path, value));\n\n\t\tscope.set('name', 'Ana');               // watch form.name Ana\n\t\tscope.set('city', 'Rome');\n\t\tconsole.log(scope.get('name'));         // Ana\n\t\tconsole.log(scope.get());               // {\"name\":\"Ana\",\"city\":\"Rome\"}\n\n\t\tscope.push('tags', 'new');\n\t\tconsole.log(form.tags);                 // [\"new\"]\n\n\t\tconsole.log(scope.FIND('field').path);  // form.name\n\t});\n</script>\n```\n\n| Member | Beschreibung |\n| --- | --- |\n| `path` | Der vollständige Path des Scopes. |\n| `element` | Das Element des Scopes als jQuery-Objekt. |\n| `parent` | Der übergeordnete Scope. |\n| `makepath(path)` | Ersetzt `?` durch den Path des Scopes. |\n| `get([path])` | Liest einen Wert. Ohne Path gibt die Methode das gesamte Objekt zurück. |\n| `set(path, value)` | Schreibt einen Wert. |\n| `push(path, value)` | Fügt einem Array einen Wert hinzu. |\n| `update(path)` | Benachrichtigt alles, was von einem Path abhängt. |\n| `watch(path, fn, [init])` | Überwacht einen Path. |\n| `FIND(selector)` | Sucht eine Komponente innerhalb des Scopes. |\n| `SETTER(selector, method, ...)` | Ruft eine Methode der Komponenten innerhalb des Scopes auf. |\n\nDie Referenz zu [Scope](../../reference/scope/) führt alle Member auf.\n\n## Ein Plugin anbinden\n\nEin [Plugin](../plugins/) mit demselben Namen wie der Scope enthält die Logik dieses Seitenteils. Innerhalb des Scopes verweist `?/name` auf eine Funktion des Plugins, und im Code des Plugins steht `?` für seinen Path.\n\n```html\n<ui-plugin path=\"contact\">\n\t<button id=\"save\" data-bind=\"?.name__click:?/save\">Save</button>\n\t<ui-bind id=\"label\" path=\"?.name\" config=\"text:?/format\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tPLUGIN('contact', function(exports) {\n\n\t\texports.format = function(value) {\n\t\t\treturn (value || '').toUpperCase();\n\t\t};\n\n\t\texports.save = function(el, e, value, path) {\n\t\t\tconsole.log('saving', value, 'from', path);\n\t\t\tSET('?.saved', true);\n\t\t};\n\t});\n\n\tSET('contact.name', 'Ana');\n</script>\n```\n\nDas Label zeigt `ANA`. Ein Klick auf die Schaltfläche gibt `saving Ana from contact.name` aus und speichert `true` in `contact.saved`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammU322M61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/scopes/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Scopes","summary":"Da a una parte de la página su propio path base, para que el mismo marcado pueda trabajar con datos distintos.","markdown":"---\ntitle: Scopes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/scopes/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Scopes\n\n> Da a una parte de la página su propio path base, para que el mismo marcado pueda trabajar con datos distintos.\n\nUn scope da a una parte de la página su propio path base. Dentro de él, el carácter `?` representa ese path. Así puedes reutilizar el mismo marcado con datos distintos, y un bloque de la página no necesita saber dónde se guardan sus datos.\n\n## Crear un scope\n\nEnvuelve el marcado en un elemento `<ui-plugin>` y empieza los paths interiores con `?`.\n\n```html\n<ui-plugin path=\"billing\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<ui-plugin path=\"shipping\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(self.path + ' = ' + value);\n\t\t};\n\t});\n\n\tSET('billing', { name: 'Ana', vat: 'A1' });\n\tSET('shipping', { name: 'Ben', vat: 'B2' });\n</script>\n```\n\nEl primer bloque muestra `Ana billing.vat = A1` y el segundo `Ben shipping.vat = B2`. Usar `?` fuera de un scope es un error: la consola del navegador muestra el aviso `Missing <ui-plugin>` y el enlace no se crea.\n\n## Scopes anidados\n\nUn scope dentro de otro amplía el path de su padre. Un `!` delante del nombre aísla el scope, de modo que ignora al padre. `?1` hace referencia al scope padre, `?2` al padre del padre, y así sucesivamente.\n\n```html\n<ui-plugin id=\"order\" path=\"order\">\n\t<ui-plugin id=\"address\" path=\"address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t\t<ui-bind id=\"ref\" path=\"?1.ref\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n\t<ui-plugin id=\"shared\" path=\"!shared\">\n\t\t<ui-bind id=\"note\" path=\"?.note\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n\n<script>\n\tSET('order', { ref: 'R-1', address: { city: 'Rome' } });\n\tSET('shared.note', 'Isolated');\n</script>\n```\n\n| Elemento | Path del scope |\n| --- | --- |\n| `<ui-plugin path=\"order\">` | `order` |\n| `<ui-plugin path=\"address\">` dentro de él | `order.address` |\n| `<ui-plugin path=\"!shared\">` dentro de él | `shared` |\n\nEn el ejemplo, `?.city` lee `order.address.city` y `?1.ref` lee `order.ref`.\n\n## Configurar un scope\n\n| Atributo o ajuste | Efecto |\n| --- | --- |\n| `path=\"?\"` | Genera un nombre único para el scope. |\n| `default=\"{ ... }\"` | Guarda este valor en el path del scope cuando se crea el scope. |\n| `config=\"init:name\"` | Llama a la función global `name(path, element)` cuando se crea el scope. |\n| `config=\"aclass:1\"` | Añade el path del scope como clase CSS del elemento. |\n| `config=\"class:name\"` | Alterna una clase CSS en el elemento poco después de crearse. |\n\n```html\n<ui-plugin path=\"?\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"login\" default=\"{ user: 'guest', remember: false }\" config=\"init:loginready;aclass:1;class:ready\">\n\t<ui-bind id=\"b\" path=\"?.user\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tfunction loginready(path, element) {\n\t\tconsole.log('init', path, element.prop('tagName'));\n\t}\n</script>\n```\n\nEl segundo scope guarda `{\"user\":\"guest\",\"remember\":false}` en `login`, y su elemento recibe las clases `login` y `ready`.\n\n## Usar un elemento existente como scope\n\nLos atributos `scope`, `plugin` y `data-scope` convierten cualquier elemento en un scope.\n\n```html\n<section scope=\"panel\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</section>\n\n<div plugin=\"sidebar\">\n\t<ui-bind id=\"b\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<div data-scope=\"footer\">\n\t<ui-bind id=\"c\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<script>\n\tSET('panel.title', 'Panel');\n\tSET('sidebar.title', 'Sidebar');\n\tSET('footer.title', 'Footer');\n</script>\n```\n\n## Trabajar con un scope desde el código\n\n`$(element).scope()` devuelve el scope al que pertenece un elemento. Los paths que pasas a sus métodos son relativos al scope.\n\n```html\n<ui-plugin id=\"panel\" path=\"form\">\n\t<ui-component name=\"field\" path=\"?.name\"></ui-component>\n\t<ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar scope = $('#panel').scope();\n\n\t\tconsole.log(scope.path);                // form\n\t\tconsole.log(scope.makepath('?.name'));  // form.name\n\n\t\tscope.watch('name', (path, value) => console.log('watch', path, value));\n\n\t\tscope.set('name', 'Ana');               // watch form.name Ana\n\t\tscope.set('city', 'Rome');\n\t\tconsole.log(scope.get('name'));         // Ana\n\t\tconsole.log(scope.get());               // {\"name\":\"Ana\",\"city\":\"Rome\"}\n\n\t\tscope.push('tags', 'new');\n\t\tconsole.log(form.tags);                 // [\"new\"]\n\n\t\tconsole.log(scope.FIND('field').path);  // form.name\n\t});\n</script>\n```\n\n| Miembro | Descripción |\n| --- | --- |\n| `path` | El path completo del scope. |\n| `element` | El elemento del scope, como objeto jQuery. |\n| `parent` | El scope padre. |\n| `makepath(path)` | Sustituye `?` por el path del scope. |\n| `get([path])` | Lee un valor. Sin path, devuelve el objeto completo. |\n| `set(path, value)` | Escribe un valor. |\n| `push(path, value)` | Añade un valor a un array. |\n| `update(path)` | Notifica a los dependientes de un path. |\n| `watch(path, fn, [init])` | Observa un path. |\n| `FIND(selector)` | Busca un componente dentro del scope. |\n| `SETTER(selector, method, ...)` | Llama a un método de los componentes que hay dentro del scope. |\n\nLa referencia de [Scope](../../reference/scope/) enumera todos los miembros.\n\n## Conectar un plugin\n\nUn [plugin](../plugins/) con el mismo nombre que el scope contiene la lógica de esa parte de la página. Dentro del scope, `?/name` hace referencia a una función del plugin, y `?` en el código del plugin representa su path.\n\n```html\n<ui-plugin path=\"contact\">\n\t<button id=\"save\" data-bind=\"?.name__click:?/save\">Save</button>\n\t<ui-bind id=\"label\" path=\"?.name\" config=\"text:?/format\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tPLUGIN('contact', function(exports) {\n\n\t\texports.format = function(value) {\n\t\t\treturn (value || '').toUpperCase();\n\t\t};\n\n\t\texports.save = function(el, e, value, path) {\n\t\t\tconsole.log('saving', value, 'from', path);\n\t\t\tSET('?.saved', true);\n\t\t};\n\t});\n\n\tSET('contact.name', 'Ana');\n</script>\n```\n\nLa etiqueta muestra `ANA`. Al hacer clic en el botón se imprime `saving Ana from contact.name` y se guarda `true` en `contact.saved`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammU322M61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/scopes/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Scopes","summary":"Donne à une partie de la page son propre path de base, pour que le même balisage puisse fonctionner avec des données différentes.","markdown":"---\ntitle: Scopes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/scopes/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Scopes\n\n> Donne à une partie de la page son propre path de base, pour que le même balisage puisse fonctionner avec des données différentes.\n\nUn scope donne à une partie de la page son propre path de base. À l'intérieur, le caractère `?` représente ce path. Tu peux ainsi réutiliser le même balisage avec des données différentes, et un bloc de la page n'a pas besoin de savoir où ses données sont stockées.\n\n## Créer un scope\n\nEnveloppe le balisage dans un élément `<ui-plugin>` et commence les paths internes par `?`.\n\n```html\n<ui-plugin path=\"billing\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<ui-plugin path=\"shipping\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(self.path + ' = ' + value);\n\t\t};\n\t});\n\n\tSET('billing', { name: 'Ana', vat: 'A1' });\n\tSET('shipping', { name: 'Ben', vat: 'B2' });\n</script>\n```\n\nLe premier bloc affiche `Ana billing.vat = A1` et le second `Ben shipping.vat = B2`. Utiliser `?` hors d'un scope est une erreur : la console du navigateur affiche l'avertissement `Missing <ui-plugin>` et la liaison n'est pas créée.\n\n## Scopes imbriqués\n\nUn scope placé dans un autre scope prolonge le path de son parent. Un `!` devant le nom isole le scope, qui ignore alors son parent. `?1` désigne le scope parent, `?2` le parent du parent, et ainsi de suite.\n\n```html\n<ui-plugin id=\"order\" path=\"order\">\n\t<ui-plugin id=\"address\" path=\"address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t\t<ui-bind id=\"ref\" path=\"?1.ref\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n\t<ui-plugin id=\"shared\" path=\"!shared\">\n\t\t<ui-bind id=\"note\" path=\"?.note\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n\n<script>\n\tSET('order', { ref: 'R-1', address: { city: 'Rome' } });\n\tSET('shared.note', 'Isolated');\n</script>\n```\n\n| Élément | Path du scope |\n| --- | --- |\n| `<ui-plugin path=\"order\">` | `order` |\n| `<ui-plugin path=\"address\">` à l'intérieur | `order.address` |\n| `<ui-plugin path=\"!shared\">` à l'intérieur | `shared` |\n\nDans l'exemple, `?.city` lit `order.address.city` et `?1.ref` lit `order.ref`.\n\n## Configurer un scope\n\n| Attribut ou réglage | Effet |\n| --- | --- |\n| `path=\"?\"` | Génère un nom unique pour le scope. |\n| `default=\"{ ... }\"` | Stocke cette valeur dans le path du scope à la création du scope. |\n| `config=\"init:name\"` | Appelle la fonction globale `name(path, element)` à la création du scope. |\n| `config=\"aclass:1\"` | Ajoute le path du scope comme classe CSS sur l'élément. |\n| `config=\"class:name\"` | Bascule une classe CSS sur l'élément peu après sa création. |\n\n```html\n<ui-plugin path=\"?\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"login\" default=\"{ user: 'guest', remember: false }\" config=\"init:loginready;aclass:1;class:ready\">\n\t<ui-bind id=\"b\" path=\"?.user\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tfunction loginready(path, element) {\n\t\tconsole.log('init', path, element.prop('tagName'));\n\t}\n</script>\n```\n\nLe second scope stocke `{\"user\":\"guest\",\"remember\":false}` dans `login`, et son élément reçoit les classes `login` et `ready`.\n\n## Utiliser un élément existant comme scope\n\nLes attributs `scope`, `plugin` et `data-scope` transforment n'importe quel élément en scope.\n\n```html\n<section scope=\"panel\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</section>\n\n<div plugin=\"sidebar\">\n\t<ui-bind id=\"b\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<div data-scope=\"footer\">\n\t<ui-bind id=\"c\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<script>\n\tSET('panel.title', 'Panel');\n\tSET('sidebar.title', 'Sidebar');\n\tSET('footer.title', 'Footer');\n</script>\n```\n\n## Manipuler un scope dans le code\n\n`$(element).scope()` renvoie le scope auquel appartient un élément. Les paths passés à ses méthodes sont relatifs au scope.\n\n```html\n<ui-plugin id=\"panel\" path=\"form\">\n\t<ui-component name=\"field\" path=\"?.name\"></ui-component>\n\t<ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar scope = $('#panel').scope();\n\n\t\tconsole.log(scope.path);                // form\n\t\tconsole.log(scope.makepath('?.name'));  // form.name\n\n\t\tscope.watch('name', (path, value) => console.log('watch', path, value));\n\n\t\tscope.set('name', 'Ana');               // watch form.name Ana\n\t\tscope.set('city', 'Rome');\n\t\tconsole.log(scope.get('name'));         // Ana\n\t\tconsole.log(scope.get());               // {\"name\":\"Ana\",\"city\":\"Rome\"}\n\n\t\tscope.push('tags', 'new');\n\t\tconsole.log(form.tags);                 // [\"new\"]\n\n\t\tconsole.log(scope.FIND('field').path);  // form.name\n\t});\n</script>\n```\n\n| Membre | Description |\n| --- | --- |\n| `path` | Le path complet du scope. |\n| `element` | L'élément du scope, sous forme d'objet jQuery. |\n| `parent` | Le scope parent. |\n| `makepath(path)` | Remplace `?` par le path du scope. |\n| `get([path])` | Lit une valeur. Sans path, renvoie l'objet entier. |\n| `set(path, value)` | Écrit une valeur. |\n| `push(path, value)` | Ajoute une valeur à un tableau. |\n| `update(path)` | Notifie les dépendants d'un path. |\n| `watch(path, fn, [init])` | Observe un path. |\n| `FIND(selector)` | Trouve un composant dans le scope. |\n| `SETTER(selector, method, ...)` | Appelle une méthode des composants du scope. |\n\nLa référence [Scope](../../reference/scope/) liste tous les membres.\n\n## Connecter un plugin\n\nUn [plugin](../plugins/) portant le même nom que le scope contient la logique de cette partie de la page. Dans le scope, `?/name` désigne une fonction du plugin, et `?` représente son path dans le code du plugin.\n\n```html\n<ui-plugin path=\"contact\">\n\t<button id=\"save\" data-bind=\"?.name__click:?/save\">Save</button>\n\t<ui-bind id=\"label\" path=\"?.name\" config=\"text:?/format\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tPLUGIN('contact', function(exports) {\n\n\t\texports.format = function(value) {\n\t\t\treturn (value || '').toUpperCase();\n\t\t};\n\n\t\texports.save = function(el, e, value, path) {\n\t\t\tconsole.log('saving', value, 'from', path);\n\t\t\tSET('?.saved', true);\n\t\t};\n\t});\n\n\tSET('contact.name', 'Ana');\n</script>\n```\n\nLe libellé affiche `ANA`. Un clic sur le bouton affiche `saving Ana from contact.name` et stocke `true` dans `contact.saved`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammU322M61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/scopes/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Scope","summary":"Assegna a una parte della pagina un proprio path di base, così lo stesso markup può lavorare con dati diversi.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/scopes/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Scope\n\n> Assegna a una parte della pagina un proprio path di base, così lo stesso markup può lavorare con dati diversi.\n\nUno scope assegna a una parte della pagina un proprio path di base. Al suo interno, il carattere `?` rappresenta quel path. Puoi così riutilizzare lo stesso markup con dati diversi, e un blocco della pagina non ha bisogno di sapere dove sono memorizzati i suoi dati.\n\n## Creare uno scope\n\nRacchiudi il markup in un elemento `<ui-plugin>` e fai iniziare i path interni con `?`.\n\n```html\n<ui-plugin path=\"billing\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<ui-plugin path=\"shipping\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(self.path + ' = ' + value);\n\t\t};\n\t});\n\n\tSET('billing', { name: 'Ana', vat: 'A1' });\n\tSET('shipping', { name: 'Ben', vat: 'B2' });\n</script>\n```\n\nIl primo blocco mostra `Ana billing.vat = A1` e il secondo `Ben shipping.vat = B2`. Usare `?` fuori da uno scope è un errore: la console del browser mostra l'avviso `Missing <ui-plugin>` e l'associazione non viene creata.\n\n## Scope annidati\n\nUno scope dentro un altro scope estende il path del genitore. Un `!` davanti al nome rende lo scope isolato, quindi ignora il genitore. `?1` si riferisce allo scope genitore, `?2` al genitore del genitore, e così via.\n\n```html\n<ui-plugin id=\"order\" path=\"order\">\n\t<ui-plugin id=\"address\" path=\"address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t\t<ui-bind id=\"ref\" path=\"?1.ref\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n\t<ui-plugin id=\"shared\" path=\"!shared\">\n\t\t<ui-bind id=\"note\" path=\"?.note\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n\n<script>\n\tSET('order', { ref: 'R-1', address: { city: 'Rome' } });\n\tSET('shared.note', 'Isolated');\n</script>\n```\n\n| Elemento | Path dello scope |\n| --- | --- |\n| `<ui-plugin path=\"order\">` | `order` |\n| `<ui-plugin path=\"address\">` al suo interno | `order.address` |\n| `<ui-plugin path=\"!shared\">` al suo interno | `shared` |\n\nNell'esempio `?.city` legge `order.address.city` e `?1.ref` legge `order.ref`.\n\n## Configurare uno scope\n\n| Attributo o impostazione | Effetto |\n| --- | --- |\n| `path=\"?\"` | Genera un nome univoco per lo scope. |\n| `default=\"{ ... }\"` | Memorizza questo valore nel path dello scope quando lo scope viene creato. |\n| `config=\"init:name\"` | Chiama la funzione globale `name(path, element)` quando lo scope viene creato. |\n| `config=\"aclass:1\"` | Aggiunge il path dello scope come classe CSS dell'elemento. |\n| `config=\"class:name\"` | Attiva o disattiva una classe CSS sull'elemento poco dopo la sua creazione. |\n\n```html\n<ui-plugin path=\"?\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"login\" default=\"{ user: 'guest', remember: false }\" config=\"init:loginready;aclass:1;class:ready\">\n\t<ui-bind id=\"b\" path=\"?.user\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tfunction loginready(path, element) {\n\t\tconsole.log('init', path, element.prop('tagName'));\n\t}\n</script>\n```\n\nIl secondo scope memorizza `{\"user\":\"guest\",\"remember\":false}` in `login` e il suo elemento riceve le classi `login` e `ready`.\n\n## Usare un elemento esistente come scope\n\nGli attributi `scope`, `plugin` e `data-scope` trasformano qualsiasi elemento in uno scope.\n\n```html\n<section scope=\"panel\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</section>\n\n<div plugin=\"sidebar\">\n\t<ui-bind id=\"b\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<div data-scope=\"footer\">\n\t<ui-bind id=\"c\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<script>\n\tSET('panel.title', 'Panel');\n\tSET('sidebar.title', 'Sidebar');\n\tSET('footer.title', 'Footer');\n</script>\n```\n\n## Lavorare con uno scope nel codice\n\n`$(element).scope()` restituisce lo scope a cui appartiene un elemento. I path passati ai suoi metodi sono relativi allo scope.\n\n```html\n<ui-plugin id=\"panel\" path=\"form\">\n\t<ui-component name=\"field\" path=\"?.name\"></ui-component>\n\t<ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar scope = $('#panel').scope();\n\n\t\tconsole.log(scope.path);                // form\n\t\tconsole.log(scope.makepath('?.name'));  // form.name\n\n\t\tscope.watch('name', (path, value) => console.log('watch', path, value));\n\n\t\tscope.set('name', 'Ana');               // watch form.name Ana\n\t\tscope.set('city', 'Rome');\n\t\tconsole.log(scope.get('name'));         // Ana\n\t\tconsole.log(scope.get());               // {\"name\":\"Ana\",\"city\":\"Rome\"}\n\n\t\tscope.push('tags', 'new');\n\t\tconsole.log(form.tags);                 // [\"new\"]\n\n\t\tconsole.log(scope.FIND('field').path);  // form.name\n\t});\n</script>\n```\n\n| Membro | Descrizione |\n| --- | --- |\n| `path` | Il path completo dello scope. |\n| `element` | L'elemento dello scope, come oggetto jQuery. |\n| `parent` | Lo scope genitore. |\n| `makepath(path)` | Sostituisce `?` con il path dello scope. |\n| `get([path])` | Legge un valore. Senza path restituisce l'intero oggetto. |\n| `set(path, value)` | Scrive un valore. |\n| `push(path, value)` | Aggiunge un valore a un array. |\n| `update(path)` | Notifica i dipendenti di un path. |\n| `watch(path, fn, [init])` | Osserva un path. |\n| `FIND(selector)` | Trova un componente all'interno dello scope. |\n| `SETTER(selector, method, ...)` | Chiama un metodo dei componenti all'interno dello scope. |\n\nIl riferimento [Scope](../../reference/scope/) elenca tutti i membri.\n\n## Collegare un plugin\n\nUn [plugin](../plugins/) con lo stesso nome dello scope contiene la logica di quella parte della pagina. All'interno dello scope, `?/name` si riferisce a una funzione del plugin, e `?` nel codice del plugin rappresenta il suo path.\n\n```html\n<ui-plugin path=\"contact\">\n\t<button id=\"save\" data-bind=\"?.name__click:?/save\">Save</button>\n\t<ui-bind id=\"label\" path=\"?.name\" config=\"text:?/format\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tPLUGIN('contact', function(exports) {\n\n\t\texports.format = function(value) {\n\t\t\treturn (value || '').toUpperCase();\n\t\t};\n\n\t\texports.save = function(el, e, value, path) {\n\t\t\tconsole.log('saving', value, 'from', path);\n\t\t\tSET('?.saved', true);\n\t\t};\n\t});\n\n\tSET('contact.name', 'Ana');\n</script>\n```\n\nL'etichetta mostra `ANA`. Facendo clic sul pulsante viene stampato `saving Ana from contact.name` e viene memorizzato `true` in `contact.saved`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammU322M61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/scopes/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Scopes","summary":"Daj časti stránky vlastný základný path, aby rovnaké značky mohli pracovať s rôznymi dátami.","markdown":"---\ntitle: Scopes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/scopes/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Scopes\n\n> Daj časti stránky vlastný základný path, aby rovnaké značky mohli pracovať s rôznymi dátami.\n\nScope dáva časti stránky vlastný základný path. Znak `?` v ňom zastupuje tento path. Rovnaké značky potom môžeš znova použiť s inými dátami a blok stránky nemusí vedieť, kde sú jeho dáta uložené.\n\n## Vytvor scope\n\nObaľ značky do elementu `<ui-plugin>` a vnútorné paths začni znakom `?`.\n\n```html\n<ui-plugin path=\"billing\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<ui-plugin path=\"shipping\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n\t<ui-component name=\"field\" path=\"?.vat\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(self.path + ' = ' + value);\n\t\t};\n\t});\n\n\tSET('billing', { name: 'Ana', vat: 'A1' });\n\tSET('shipping', { name: 'Ben', vat: 'B2' });\n</script>\n```\n\nPrvý blok zobrazí `Ana billing.vat = A1` a druhý `Ben shipping.vat = B2`. Použitie `?` mimo scope je chyba: konzola prehliadača zobrazí upozornenie `Missing <ui-plugin>` a väzba sa nevytvorí.\n\n## Vnorené scopes\n\nScope vnútri iného scope rozširuje path svojho rodiča. Znak `!` pred názvom robí scope izolovaným, takže rodiča ignoruje. `?1` odkazuje na rodičovský scope, `?2` na rodiča rodiča a tak ďalej.\n\n```html\n<ui-plugin id=\"order\" path=\"order\">\n\t<ui-plugin id=\"address\" path=\"address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t\t<ui-bind id=\"ref\" path=\"?1.ref\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n\t<ui-plugin id=\"shared\" path=\"!shared\">\n\t\t<ui-bind id=\"note\" path=\"?.note\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n\n<script>\n\tSET('order', { ref: 'R-1', address: { city: 'Rome' } });\n\tSET('shared.note', 'Isolated');\n</script>\n```\n\n| Element | Path scope |\n| --- | --- |\n| `<ui-plugin path=\"order\">` | `order` |\n| `<ui-plugin path=\"address\">` vnútri neho | `order.address` |\n| `<ui-plugin path=\"!shared\">` vnútri neho | `shared` |\n\nV príklade `?.city` číta `order.address.city` a `?1.ref` číta `order.ref`.\n\n## Nastav scope\n\n| Atribút alebo nastavenie | Účinok |\n| --- | --- |\n| `path=\"?\"` | Vygeneruje pre scope jedinečný názov. |\n| `default=\"{ ... }\"` | Pri vytvorení scope uloží túto hodnotu do jeho path. |\n| `config=\"init:name\"` | Pri vytvorení scope zavolá globálnu funkciu `name(path, element)`. |\n| `config=\"aclass:1\"` | Pridá path scope na element ako CSS triedu. |\n| `config=\"class:name\"` | Krátko po vytvorení prepne CSS triedu na elemente. |\n\n```html\n<ui-plugin path=\"?\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"login\" default=\"{ user: 'guest', remember: false }\" config=\"init:loginready;aclass:1;class:ready\">\n\t<ui-bind id=\"b\" path=\"?.user\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tfunction loginready(path, element) {\n\t\tconsole.log('init', path, element.prop('tagName'));\n\t}\n</script>\n```\n\nDruhý scope uloží `{\"user\":\"guest\",\"remember\":false}` do `login` a jeho element dostane triedy `login` a `ready`.\n\n## Použi existujúci element ako scope\n\nAtribúty `scope`, `plugin` a `data-scope` premenia ľubovoľný element na scope.\n\n```html\n<section scope=\"panel\">\n\t<ui-bind id=\"a\" path=\"?.title\" config=\"text\"></ui-bind>\n</section>\n\n<div plugin=\"sidebar\">\n\t<ui-bind id=\"b\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<div data-scope=\"footer\">\n\t<ui-bind id=\"c\" path=\"?.title\" config=\"text\"></ui-bind>\n</div>\n\n<script>\n\tSET('panel.title', 'Panel');\n\tSET('sidebar.title', 'Sidebar');\n\tSET('footer.title', 'Footer');\n</script>\n```\n\n## Práca so scope v kóde\n\n`$(element).scope()` vráti scope, do ktorého element patrí. Paths, ktoré odovzdáš jeho metódam, sú relatívne voči scope.\n\n```html\n<ui-plugin id=\"panel\" path=\"form\">\n\t<ui-component name=\"field\" path=\"?.name\"></ui-component>\n\t<ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tvar scope = $('#panel').scope();\n\n\t\tconsole.log(scope.path);                // form\n\t\tconsole.log(scope.makepath('?.name'));  // form.name\n\n\t\tscope.watch('name', (path, value) => console.log('watch', path, value));\n\n\t\tscope.set('name', 'Ana');               // watch form.name Ana\n\t\tscope.set('city', 'Rome');\n\t\tconsole.log(scope.get('name'));         // Ana\n\t\tconsole.log(scope.get());               // {\"name\":\"Ana\",\"city\":\"Rome\"}\n\n\t\tscope.push('tags', 'new');\n\t\tconsole.log(form.tags);                 // [\"new\"]\n\n\t\tconsole.log(scope.FIND('field').path);  // form.name\n\t});\n</script>\n```\n\n| Člen | Popis |\n| --- | --- |\n| `path` | Úplný path scope. |\n| `element` | Element scope ako objekt jQuery. |\n| `parent` | Rodičovský scope. |\n| `makepath(path)` | Nahradí `?` za path scope. |\n| `get([path])` | Prečíta hodnotu. Bez path vráti celý objekt. |\n| `set(path, value)` | Zapíše hodnotu. |\n| `push(path, value)` | Pridá hodnotu do poľa. |\n| `update(path)` | Upozorní všetko, čo od daného path závisí. |\n| `watch(path, fn, [init])` | Sleduje path. |\n| `FIND(selector)` | Nájde komponent vnútri scope. |\n| `SETTER(selector, method, ...)` | Zavolá metódu komponentov vnútri scope. |\n\nReferencia [Scope](../../reference/scope/) uvádza všetkých členov.\n\n## Pripoj plugin\n\n[Plugin](../plugins/) s rovnakým názvom ako scope obsahuje logiku tejto časti stránky. Vnútri scope odkazuje `?/name` na funkciu pluginu a `?` v kóde pluginu zastupuje jeho path.\n\n```html\n<ui-plugin path=\"contact\">\n\t<button id=\"save\" data-bind=\"?.name__click:?/save\">Save</button>\n\t<ui-bind id=\"label\" path=\"?.name\" config=\"text:?/format\"></ui-bind>\n</ui-plugin>\n\n<script>\n\tPLUGIN('contact', function(exports) {\n\n\t\texports.format = function(value) {\n\t\t\treturn (value || '').toUpperCase();\n\t\t};\n\n\t\texports.save = function(el, e, value, path) {\n\t\t\tconsole.log('saving', value, 'from', path);\n\t\t\tSET('?.saved', true);\n\t\t};\n\t});\n\n\tSET('contact.name', 'Ana');\n</script>\n```\n\nŠtítok zobrazí `ANA`. Kliknutie na tlačidlo vypíše `saving Ana from contact.name` a uloží `true` do `contact.saved`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUD28M61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/virtual-bindings/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Virtual bindings","summary":"Render detached HTML and repeated rows from a private model, outside the global data.","markdown":"---\ntitle: Virtual bindings\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/virtual-bindings/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Virtual bindings\n\n> Render detached HTML and repeated rows from a private model, outside the global data.\n\nA virtual binding connects a piece of HTML to a private model instead of a global [path](../paths/). It suits repeated content such as table rows, list items and cards, where each item has its own data.\n\n## Bind a piece of HTML\n\n[VBIND()](../../reference/globals/) creates the HTML and returns a binder object. Paths inside it start with a dot and are relative to the model. A dot alone stands for the whole model. The commands are the same as in [Data binding](../data-binding/).\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div class=\"card\"><h3 data-bind=\".name__text\"></h3><span data-bind=\".age__text__.senior:value >= 65\"></span></div>');\n\n\t$('#host').append(card.element);\n\n\tcard.set({ name: 'Ana', age: 70 });\n\tconsole.log(card.element.find('h3').text());          // Ana\n\tconsole.log(card.element.find('span').text());        // 70\n\tconsole.log(card.element.find('span').attr('class')); // senior\n</script>\n```\n\nThe binder is not attached to the page by itself. Add `card.element`, a jQuery object, wherever you need it.\n\n## Update the model\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><b data-bind=\".name__text\"></b> <i data-bind=\".__text:value.name + \\' (\\' + value.age + \\')\\'\"></i></div>');\n\n\t$('#host').append(card.element);\n\tcard.set({ name: 'Ana', age: 30 });\n\tconsole.log(card.element.text());   // Ana Ana (30)\n\n\tcard.set('age', 31);\n\tconsole.log(card.get('age'));       // 31\n\tconsole.log(card.element.text());   // Ana Ana (31)\n\n\tcard.get().name = 'Ben';\n\tcard.upd('name');\n\tconsole.log(card.element.text());   // Ben Ben (31)\n\n\tconsole.log(card.get());            // {\"name\":\"Ben\",\"age\":31}\n</script>\n```\n\n| Member | Description |\n| --- | --- |\n| `element` | The HTML of the binder, as a jQuery object. |\n| `set(model)` | Replaces the model and redraws all bindings. |\n| `set(path, value)` | Changes one field and redraws the bindings that depend on it. |\n| `get([path])` | Reads the model or one field. |\n| `upd([path])` | Redraws after you changed the model directly. |\n| `on(event, [selector], fn)` | Adds an event listener to the element. |\n| `remove()` | Removes the element and its listeners. |\n\n## Handle events and remove the binder\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><button>Open</button></div>');\n\n\tcard.on('click', 'button', function() {\n\t\tconsole.log('clicked');\n\t});\n\n\t$('#host').append(card.element);\n\tcard.element.find('button').click();   // clicked\n\n\tcard.remove();\n\tconsole.log($('#host').html());        // (empty)\n</script>\n```\n\n## Render a list\n\n[VBINDARRAY()](../../reference/globals/) repeats one template for each item of an array and appends the rows to a target element. Each row receives a `data-index` attribute. When you set a new array, existing rows are reused, extra rows are removed and only rows whose data changed are redrawn.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li><b data-bind=\".name__text\"></b> <span data-bind=\".price__text__format:2\"></span></li>', '#list');\n\n\trows.set([{ name: 'Tea', price: 2 }, { name: 'Milk', price: 1.5 }]);\n\tconsole.log($('#list').text());     // Tea 2.00Milk 1.50\n\n\trows.set(1, { name: 'Soy milk', price: 2.25 });\n\tconsole.log($('#list').text());     // Tea 2.00Soy milk 2.25\n\n\trows.get(0).price = 3;\n\trows.upd(0);\n\tconsole.log($('#list').text());     // Tea 3.00Soy milk 2.25\n\n\trows.set([{ name: 'Water', price: 1 }]);\n\tconsole.log($('#list').text());     // Water 1.00\n\tconsole.log(rows.items.length);     // 1\n\n\tconsole.log($('#list li').attr('data-index'));  // 0\n</script>\n```\n\n| Member | Description |\n| --- | --- |\n| `items` | The binders of the rows. |\n| `set(array)` | Renders the array. |\n| `set(index, item)` | Replaces one row. |\n| `get([index])` | Reads the array or one item. |\n| `upd([index])` | Redraws one row, or every row, after you changed the data directly. |\n| `remove()` | Removes all rows. |\n\n## Bind a list to a path\n\nThe `vbindarray` command connects a list to a global path. Put the row in a `<template>` or `<script type=\"text/html\">` element inside the binding. Inside a row, `el.vbind()` returns the binder of the row, and its `index` property is the position of the row.\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"products\" config=\"vbindarray\">\n\t\t<template>\n\t\t\t<li><span data-bind=\".name__text\"></span> <button data-bind=\".id__click:remove\">Remove</button></li>\n\t\t</template>\n\t</ui-bind>\n</ul>\n\n<script>\n\tfunction remove(el, e, id) {\n\t\tvar index = el.vbind().index;\n\t\tconsole.log('remove', id, 'at', index);\n\t\tproducts.splice(index, 1);\n\t\tUPD('products');\n\t}\n\n\tSET('products', [{ id: 1, name: 'Tea' }, { id: 2, name: 'Milk' }, { id: 3, name: 'Soy' }]);\n</script>\n```\n\nClicking `Remove` in the second row prints `remove 2 at 1`, and the list keeps `Tea` and `Soy`.\n\n## Format values with row methods\n\nA value that starts with a dot calls a method of the list object.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li data-bind=\".price__text:.money\"></li>', '#list');\n\n\trows.money = function(value) {\n\t\treturn value.format(2) + ' EUR';\n\t};\n\n\trows.set([{ price: 10 }, { price: 2.5 }]);\n\tconsole.log($('#list').text());   // 10.00 EUR2.50 EUR\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUD28M61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/virtual-bindings/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Virtuelle Bindungen","summary":"Rendere losgelöstes HTML und wiederholte Zeilen aus einem privaten Modell, außerhalb der globalen Daten.","markdown":"---\ntitle: Virtuelle Bindungen\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/virtual-bindings/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Virtuelle Bindungen\n\n> Rendere losgelöstes HTML und wiederholte Zeilen aus einem privaten Modell, außerhalb der globalen Daten.\n\nEine virtuelle Bindung verbindet ein Stück HTML mit einem privaten Modell statt mit einem globalen [Path](../paths/). Das eignet sich für wiederholte Inhalte wie Tabellenzeilen, Listeneinträge und Karten, bei denen jeder Eintrag eigene Daten hat.\n\n## Ein Stück HTML binden\n\n[VBIND()](../../reference/globals/) erstellt das HTML und gibt ein Binder-Objekt zurück. Paths darin beginnen mit einem Punkt und sind relativ zum Modell. Ein einzelner Punkt steht für das gesamte Modell. Die Befehle sind dieselben wie bei der [Datenbindung](../data-binding/).\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div class=\"card\"><h3 data-bind=\".name__text\"></h3><span data-bind=\".age__text__.senior:value >= 65\"></span></div>');\n\n\t$('#host').append(card.element);\n\n\tcard.set({ name: 'Ana', age: 70 });\n\tconsole.log(card.element.find('h3').text());          // Ana\n\tconsole.log(card.element.find('span').text());        // 70\n\tconsole.log(card.element.find('span').attr('class')); // senior\n</script>\n```\n\nDer Binder wird nicht von selbst in die Seite eingefügt. Füge `card.element`, ein jQuery-Objekt, dort ein, wo du es brauchst.\n\n## Das Modell aktualisieren\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><b data-bind=\".name__text\"></b> <i data-bind=\".__text:value.name + \\' (\\' + value.age + \\')\\'\"></i></div>');\n\n\t$('#host').append(card.element);\n\tcard.set({ name: 'Ana', age: 30 });\n\tconsole.log(card.element.text());   // Ana Ana (30)\n\n\tcard.set('age', 31);\n\tconsole.log(card.get('age'));       // 31\n\tconsole.log(card.element.text());   // Ana Ana (31)\n\n\tcard.get().name = 'Ben';\n\tcard.upd('name');\n\tconsole.log(card.element.text());   // Ben Ben (31)\n\n\tconsole.log(card.get());            // {\"name\":\"Ben\",\"age\":31}\n</script>\n```\n\n| Member | Beschreibung |\n| --- | --- |\n| `element` | Das HTML des Binders als jQuery-Objekt. |\n| `set(model)` | Ersetzt das Modell und zeichnet alle Bindungen neu. |\n| `set(path, value)` | Ändert ein Feld und zeichnet die davon abhängigen Bindungen neu. |\n| `get([path])` | Liest das Modell oder ein Feld. |\n| `upd([path])` | Zeichnet neu, nachdem du das Modell direkt geändert hast. |\n| `on(event, [selector], fn)` | Fügt dem Element einen Event-Listener hinzu. |\n| `remove()` | Entfernt das Element und seine Listener. |\n\n## Events verarbeiten und den Binder entfernen\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><button>Open</button></div>');\n\n\tcard.on('click', 'button', function() {\n\t\tconsole.log('clicked');\n\t});\n\n\t$('#host').append(card.element);\n\tcard.element.find('button').click();   // clicked\n\n\tcard.remove();\n\tconsole.log($('#host').html());        // (empty)\n</script>\n```\n\n## Eine Liste rendern\n\n[VBINDARRAY()](../../reference/globals/) wiederholt ein Template für jeden Eintrag eines Arrays und hängt die Zeilen an ein Zielelement an. Jede Zeile erhält ein `data-index`-Attribut. Wenn du ein neues Array setzt, werden vorhandene Zeilen wiederverwendet, überzählige entfernt und nur Zeilen neu gezeichnet, deren Daten sich geändert haben.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li><b data-bind=\".name__text\"></b> <span data-bind=\".price__text__format:2\"></span></li>', '#list');\n\n\trows.set([{ name: 'Tea', price: 2 }, { name: 'Milk', price: 1.5 }]);\n\tconsole.log($('#list').text());     // Tea 2.00Milk 1.50\n\n\trows.set(1, { name: 'Soy milk', price: 2.25 });\n\tconsole.log($('#list').text());     // Tea 2.00Soy milk 2.25\n\n\trows.get(0).price = 3;\n\trows.upd(0);\n\tconsole.log($('#list').text());     // Tea 3.00Soy milk 2.25\n\n\trows.set([{ name: 'Water', price: 1 }]);\n\tconsole.log($('#list').text());     // Water 1.00\n\tconsole.log(rows.items.length);     // 1\n\n\tconsole.log($('#list li').attr('data-index'));  // 0\n</script>\n```\n\n| Member | Beschreibung |\n| --- | --- |\n| `items` | Die Binder der Zeilen. |\n| `set(array)` | Rendert das Array. |\n| `set(index, item)` | Ersetzt eine Zeile. |\n| `get([index])` | Liest das Array oder einen Eintrag. |\n| `upd([index])` | Zeichnet eine Zeile oder alle Zeilen neu, nachdem du die Daten direkt geändert hast. |\n| `remove()` | Entfernt alle Zeilen. |\n\n## Eine Liste an einen Path binden\n\nDer Befehl `vbindarray` verbindet eine Liste mit einem globalen Path. Lege die Zeile in einem `<template>`- oder `<script type=\"text/html\">`-Element innerhalb der Bindung ab. Innerhalb einer Zeile gibt `el.vbind()` den Binder der Zeile zurück, und seine Eigenschaft `index` ist die Position der Zeile.\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"products\" config=\"vbindarray\">\n\t\t<template>\n\t\t\t<li><span data-bind=\".name__text\"></span> <button data-bind=\".id__click:remove\">Remove</button></li>\n\t\t</template>\n\t</ui-bind>\n</ul>\n\n<script>\n\tfunction remove(el, e, id) {\n\t\tvar index = el.vbind().index;\n\t\tconsole.log('remove', id, 'at', index);\n\t\tproducts.splice(index, 1);\n\t\tUPD('products');\n\t}\n\n\tSET('products', [{ id: 1, name: 'Tea' }, { id: 2, name: 'Milk' }, { id: 3, name: 'Soy' }]);\n</script>\n```\n\nEin Klick auf `Remove` in der zweiten Zeile gibt `remove 2 at 1` aus, und die Liste behält `Tea` und `Soy`.\n\n## Werte mit Zeilenmethoden formatieren\n\nEin Wert, der mit einem Punkt beginnt, ruft eine Methode des Listenobjekts auf.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li data-bind=\".price__text:.money\"></li>', '#list');\n\n\trows.money = function(value) {\n\t\treturn value.format(2) + ' EUR';\n\t};\n\n\trows.set([{ price: 10 }, { price: 2.5 }]);\n\tconsole.log($('#list').text());   // 10.00 EUR2.50 EUR\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUD28M61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/virtual-bindings/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Enlaces virtuales","summary":"Renderiza HTML independiente y filas repetidas a partir de un modelo privado, fuera de los datos globales.","markdown":"---\ntitle: Enlaces virtuales\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/virtual-bindings/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Enlaces virtuales\n\n> Renderiza HTML independiente y filas repetidas a partir de un modelo privado, fuera de los datos globales.\n\nUn enlace virtual conecta un fragmento de HTML con un modelo privado en lugar de con un [path](../paths/) global. Es adecuado para contenido repetido, como filas de tabla, elementos de lista y tarjetas, donde cada elemento tiene sus propios datos.\n\n## Enlazar un fragmento de HTML\n\n[VBIND()](../../reference/globals/) crea el HTML y devuelve un objeto binder. Los paths que contiene empiezan por un punto y son relativos al modelo. Un punto solo representa el modelo completo. Los comandos son los mismos que en [Enlace de datos](../data-binding/).\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div class=\"card\"><h3 data-bind=\".name__text\"></h3><span data-bind=\".age__text__.senior:value >= 65\"></span></div>');\n\n\t$('#host').append(card.element);\n\n\tcard.set({ name: 'Ana', age: 70 });\n\tconsole.log(card.element.find('h3').text());          // Ana\n\tconsole.log(card.element.find('span').text());        // 70\n\tconsole.log(card.element.find('span').attr('class')); // senior\n</script>\n```\n\nEl binder no se añade a la página por sí solo. Coloca `card.element`, un objeto jQuery, donde lo necesites.\n\n## Actualizar el modelo\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><b data-bind=\".name__text\"></b> <i data-bind=\".__text:value.name + \\' (\\' + value.age + \\')\\'\"></i></div>');\n\n\t$('#host').append(card.element);\n\tcard.set({ name: 'Ana', age: 30 });\n\tconsole.log(card.element.text());   // Ana Ana (30)\n\n\tcard.set('age', 31);\n\tconsole.log(card.get('age'));       // 31\n\tconsole.log(card.element.text());   // Ana Ana (31)\n\n\tcard.get().name = 'Ben';\n\tcard.upd('name');\n\tconsole.log(card.element.text());   // Ben Ben (31)\n\n\tconsole.log(card.get());            // {\"name\":\"Ben\",\"age\":31}\n</script>\n```\n\n| Miembro | Descripción |\n| --- | --- |\n| `element` | El HTML del binder, como objeto jQuery. |\n| `set(model)` | Sustituye el modelo y vuelve a dibujar todos los enlaces. |\n| `set(path, value)` | Cambia un campo y vuelve a dibujar los enlaces que dependen de él. |\n| `get([path])` | Lee el modelo o un campo. |\n| `upd([path])` | Vuelve a dibujar después de que hayas cambiado el modelo directamente. |\n| `on(event, [selector], fn)` | Añade un listener de eventos al elemento. |\n| `remove()` | Elimina el elemento y sus listeners. |\n\n## Gestionar eventos y eliminar el binder\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><button>Open</button></div>');\n\n\tcard.on('click', 'button', function() {\n\t\tconsole.log('clicked');\n\t});\n\n\t$('#host').append(card.element);\n\tcard.element.find('button').click();   // clicked\n\n\tcard.remove();\n\tconsole.log($('#host').html());        // (empty)\n</script>\n```\n\n## Renderizar una lista\n\n[VBINDARRAY()](../../reference/globals/) repite una plantilla para cada elemento de un array y añade las filas a un elemento de destino. Cada fila recibe un atributo `data-index`. Cuando asignas un array nuevo, las filas existentes se reutilizan, las sobrantes se eliminan y solo se vuelven a dibujar las filas cuyos datos han cambiado.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li><b data-bind=\".name__text\"></b> <span data-bind=\".price__text__format:2\"></span></li>', '#list');\n\n\trows.set([{ name: 'Tea', price: 2 }, { name: 'Milk', price: 1.5 }]);\n\tconsole.log($('#list').text());     // Tea 2.00Milk 1.50\n\n\trows.set(1, { name: 'Soy milk', price: 2.25 });\n\tconsole.log($('#list').text());     // Tea 2.00Soy milk 2.25\n\n\trows.get(0).price = 3;\n\trows.upd(0);\n\tconsole.log($('#list').text());     // Tea 3.00Soy milk 2.25\n\n\trows.set([{ name: 'Water', price: 1 }]);\n\tconsole.log($('#list').text());     // Water 1.00\n\tconsole.log(rows.items.length);     // 1\n\n\tconsole.log($('#list li').attr('data-index'));  // 0\n</script>\n```\n\n| Miembro | Descripción |\n| --- | --- |\n| `items` | Los binders de las filas. |\n| `set(array)` | Renderiza el array. |\n| `set(index, item)` | Sustituye una fila. |\n| `get([index])` | Lee el array o un elemento. |\n| `upd([index])` | Vuelve a dibujar una fila, o todas, después de que hayas cambiado los datos directamente. |\n| `remove()` | Elimina todas las filas. |\n\n## Enlazar una lista a un path\n\nEl comando `vbindarray` conecta una lista con un path global. Coloca la fila en un elemento `<template>` o `<script type=\"text/html\">` dentro del enlace. Dentro de una fila, `el.vbind()` devuelve el binder de la fila, y su propiedad `index` es la posición de la fila.\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"products\" config=\"vbindarray\">\n\t\t<template>\n\t\t\t<li><span data-bind=\".name__text\"></span> <button data-bind=\".id__click:remove\">Remove</button></li>\n\t\t</template>\n\t</ui-bind>\n</ul>\n\n<script>\n\tfunction remove(el, e, id) {\n\t\tvar index = el.vbind().index;\n\t\tconsole.log('remove', id, 'at', index);\n\t\tproducts.splice(index, 1);\n\t\tUPD('products');\n\t}\n\n\tSET('products', [{ id: 1, name: 'Tea' }, { id: 2, name: 'Milk' }, { id: 3, name: 'Soy' }]);\n</script>\n```\n\nAl hacer clic en `Remove` en la segunda fila se imprime `remove 2 at 1`, y la lista conserva `Tea` y `Soy`.\n\n## Dar formato a los valores con métodos de fila\n\nUn valor que empieza por un punto llama a un método del objeto de la lista.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li data-bind=\".price__text:.money\"></li>', '#list');\n\n\trows.money = function(value) {\n\t\treturn value.format(2) + ' EUR';\n\t};\n\n\trows.set([{ price: 10 }, { price: 2.5 }]);\n\tconsole.log($('#list').text());   // 10.00 EUR2.50 EUR\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUD28M61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/virtual-bindings/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Liaisons virtuelles","summary":"Affiche du HTML détaché et des lignes répétées à partir d'un modèle de données privé, en dehors des données globales.","markdown":"---\ntitle: Liaisons virtuelles\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/virtual-bindings/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Liaisons virtuelles\n\n> Affiche du HTML détaché et des lignes répétées à partir d'un modèle de données privé, en dehors des données globales.\n\nUne liaison virtuelle relie un fragment de HTML à un modèle de données privé plutôt qu'à un [path](../paths/) global. Elle convient au contenu répété, comme les lignes de tableau, les éléments de liste et les cartes, où chaque élément a ses propres données.\n\n## Lier un fragment de HTML\n\n[VBIND()](../../reference/globals/) crée le HTML et renvoie un objet binder. À l'intérieur, les paths commencent par un point et sont relatifs au modèle de données. Un point seul représente le modèle de données entier. Les commandes sont les mêmes que dans [Liaison de données](../data-binding/).\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div class=\"card\"><h3 data-bind=\".name__text\"></h3><span data-bind=\".age__text__.senior:value >= 65\"></span></div>');\n\n\t$('#host').append(card.element);\n\n\tcard.set({ name: 'Ana', age: 70 });\n\tconsole.log(card.element.find('h3').text());          // Ana\n\tconsole.log(card.element.find('span').text());        // 70\n\tconsole.log(card.element.find('span').attr('class')); // senior\n</script>\n```\n\nLe binder n'est pas attaché à la page automatiquement. Ajoute `card.element`, un objet jQuery, à l'endroit voulu.\n\n## Mettre à jour le modèle de données\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><b data-bind=\".name__text\"></b> <i data-bind=\".__text:value.name + \\' (\\' + value.age + \\')\\'\"></i></div>');\n\n\t$('#host').append(card.element);\n\tcard.set({ name: 'Ana', age: 30 });\n\tconsole.log(card.element.text());   // Ana Ana (30)\n\n\tcard.set('age', 31);\n\tconsole.log(card.get('age'));       // 31\n\tconsole.log(card.element.text());   // Ana Ana (31)\n\n\tcard.get().name = 'Ben';\n\tcard.upd('name');\n\tconsole.log(card.element.text());   // Ben Ben (31)\n\n\tconsole.log(card.get());            // {\"name\":\"Ben\",\"age\":31}\n</script>\n```\n\n| Membre | Description |\n| --- | --- |\n| `element` | Le HTML du binder, sous forme d'objet jQuery. |\n| `set(model)` | Remplace le modèle de données et redessine toutes les liaisons. |\n| `set(path, value)` | Modifie un champ et redessine les liaisons qui en dépendent. |\n| `get([path])` | Lit le modèle de données ou un champ. |\n| `upd([path])` | Redessine après une modification directe du modèle de données. |\n| `on(event, [selector], fn)` | Ajoute un écouteur d'événement à l'élément. |\n| `remove()` | Supprime l'élément et ses écouteurs. |\n\n## Gérer les événements et supprimer le binder\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><button>Open</button></div>');\n\n\tcard.on('click', 'button', function() {\n\t\tconsole.log('clicked');\n\t});\n\n\t$('#host').append(card.element);\n\tcard.element.find('button').click();   // clicked\n\n\tcard.remove();\n\tconsole.log($('#host').html());        // (empty)\n</script>\n```\n\n## Afficher une liste\n\n[VBINDARRAY()](../../reference/globals/) répète un modèle pour chaque élément d'un tableau et ajoute les lignes à un élément cible. Chaque ligne reçoit un attribut `data-index`. Quand tu définis un nouveau tableau, les lignes existantes sont réutilisées, les lignes en trop sont supprimées et seules les lignes dont les données ont changé sont redessinées.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li><b data-bind=\".name__text\"></b> <span data-bind=\".price__text__format:2\"></span></li>', '#list');\n\n\trows.set([{ name: 'Tea', price: 2 }, { name: 'Milk', price: 1.5 }]);\n\tconsole.log($('#list').text());     // Tea 2.00Milk 1.50\n\n\trows.set(1, { name: 'Soy milk', price: 2.25 });\n\tconsole.log($('#list').text());     // Tea 2.00Soy milk 2.25\n\n\trows.get(0).price = 3;\n\trows.upd(0);\n\tconsole.log($('#list').text());     // Tea 3.00Soy milk 2.25\n\n\trows.set([{ name: 'Water', price: 1 }]);\n\tconsole.log($('#list').text());     // Water 1.00\n\tconsole.log(rows.items.length);     // 1\n\n\tconsole.log($('#list li').attr('data-index'));  // 0\n</script>\n```\n\n| Membre | Description |\n| --- | --- |\n| `items` | Les binders des lignes. |\n| `set(array)` | Affiche le tableau. |\n| `set(index, item)` | Remplace une ligne. |\n| `get([index])` | Lit le tableau ou un élément. |\n| `upd([index])` | Redessine une ligne, ou toutes les lignes, après une modification directe des données. |\n| `remove()` | Supprime toutes les lignes. |\n\n## Lier une liste à un path\n\nLa commande `vbindarray` relie une liste à un path global. Place la ligne dans un élément `<template>` ou `<script type=\"text/html\">` à l'intérieur de la liaison. Dans une ligne, `el.vbind()` renvoie le binder de la ligne, et sa propriété `index` indique la position de la ligne.\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"products\" config=\"vbindarray\">\n\t\t<template>\n\t\t\t<li><span data-bind=\".name__text\"></span> <button data-bind=\".id__click:remove\">Remove</button></li>\n\t\t</template>\n\t</ui-bind>\n</ul>\n\n<script>\n\tfunction remove(el, e, id) {\n\t\tvar index = el.vbind().index;\n\t\tconsole.log('remove', id, 'at', index);\n\t\tproducts.splice(index, 1);\n\t\tUPD('products');\n\t}\n\n\tSET('products', [{ id: 1, name: 'Tea' }, { id: 2, name: 'Milk' }, { id: 3, name: 'Soy' }]);\n</script>\n```\n\nUn clic sur `Remove` dans la deuxième ligne affiche `remove 2 at 1`, et la liste conserve `Tea` et `Soy`.\n\n## Formater les valeurs avec des méthodes de ligne\n\nUne valeur qui commence par un point appelle une méthode de l'objet liste.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li data-bind=\".price__text:.money\"></li>', '#list');\n\n\trows.money = function(value) {\n\t\treturn value.format(2) + ' EUR';\n\t};\n\n\trows.set([{ price: 10 }, { price: 2.5 }]);\n\tconsole.log($('#list').text());   // 10.00 EUR2.50 EUR\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUD28M61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/virtual-bindings/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Associazioni virtuali","summary":"Renderizza HTML separato e righe ripetute a partire da un modello privato, fuori dai dati globali.","markdown":"---\ntitle: Associazioni virtuali\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/virtual-bindings/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Associazioni virtuali\n\n> Renderizza HTML separato e righe ripetute a partire da un modello privato, fuori dai dati globali.\n\nUn'associazione virtuale collega un frammento di HTML a un modello privato anziché a un [path](../paths/) globale. È adatta ai contenuti ripetuti come righe di tabella, elementi di elenco e schede, in cui ogni elemento ha i propri dati.\n\n## Associare un frammento di HTML\n\n[VBIND()](../../reference/globals/) crea l'HTML e restituisce un oggetto binder. I path al suo interno iniziano con un punto e sono relativi al modello. Un punto da solo rappresenta l'intero modello. I comandi sono gli stessi di [Associazione dei dati](../data-binding/).\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div class=\"card\"><h3 data-bind=\".name__text\"></h3><span data-bind=\".age__text__.senior:value >= 65\"></span></div>');\n\n\t$('#host').append(card.element);\n\n\tcard.set({ name: 'Ana', age: 70 });\n\tconsole.log(card.element.find('h3').text());          // Ana\n\tconsole.log(card.element.find('span').text());        // 70\n\tconsole.log(card.element.find('span').attr('class')); // senior\n</script>\n```\n\nIl binder non viene aggiunto alla pagina da solo. Inserisci `card.element`, un oggetto jQuery, dove ti serve.\n\n## Aggiornare il modello\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><b data-bind=\".name__text\"></b> <i data-bind=\".__text:value.name + \\' (\\' + value.age + \\')\\'\"></i></div>');\n\n\t$('#host').append(card.element);\n\tcard.set({ name: 'Ana', age: 30 });\n\tconsole.log(card.element.text());   // Ana Ana (30)\n\n\tcard.set('age', 31);\n\tconsole.log(card.get('age'));       // 31\n\tconsole.log(card.element.text());   // Ana Ana (31)\n\n\tcard.get().name = 'Ben';\n\tcard.upd('name');\n\tconsole.log(card.element.text());   // Ben Ben (31)\n\n\tconsole.log(card.get());            // {\"name\":\"Ben\",\"age\":31}\n</script>\n```\n\n| Membro | Descrizione |\n| --- | --- |\n| `element` | L'HTML del binder, come oggetto jQuery. |\n| `set(model)` | Sostituisce il modello e ridisegna tutte le associazioni. |\n| `set(path, value)` | Modifica un campo e ridisegna le associazioni che dipendono da esso. |\n| `get([path])` | Legge il modello o un campo. |\n| `upd([path])` | Ridisegna dopo che hai modificato direttamente il modello. |\n| `on(event, [selector], fn)` | Aggiunge un listener di eventi all'elemento. |\n| `remove()` | Rimuove l'elemento e i suoi listener. |\n\n## Gestire gli eventi e rimuovere il binder\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><button>Open</button></div>');\n\n\tcard.on('click', 'button', function() {\n\t\tconsole.log('clicked');\n\t});\n\n\t$('#host').append(card.element);\n\tcard.element.find('button').click();   // clicked\n\n\tcard.remove();\n\tconsole.log($('#host').html());        // (empty)\n</script>\n```\n\n## Renderizzare un elenco\n\n[VBINDARRAY()](../../reference/globals/) ripete un template per ogni elemento di un array e aggiunge le righe a un elemento di destinazione. Ogni riga riceve un attributo `data-index`. Quando imposti un nuovo array, le righe esistenti vengono riutilizzate, quelle in eccesso vengono rimosse e vengono ridisegnate solo le righe i cui dati sono cambiati.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li><b data-bind=\".name__text\"></b> <span data-bind=\".price__text__format:2\"></span></li>', '#list');\n\n\trows.set([{ name: 'Tea', price: 2 }, { name: 'Milk', price: 1.5 }]);\n\tconsole.log($('#list').text());     // Tea 2.00Milk 1.50\n\n\trows.set(1, { name: 'Soy milk', price: 2.25 });\n\tconsole.log($('#list').text());     // Tea 2.00Soy milk 2.25\n\n\trows.get(0).price = 3;\n\trows.upd(0);\n\tconsole.log($('#list').text());     // Tea 3.00Soy milk 2.25\n\n\trows.set([{ name: 'Water', price: 1 }]);\n\tconsole.log($('#list').text());     // Water 1.00\n\tconsole.log(rows.items.length);     // 1\n\n\tconsole.log($('#list li').attr('data-index'));  // 0\n</script>\n```\n\n| Membro | Descrizione |\n| --- | --- |\n| `items` | I binder delle righe. |\n| `set(array)` | Renderizza l'array. |\n| `set(index, item)` | Sostituisce una riga. |\n| `get([index])` | Legge l'array o un elemento. |\n| `upd([index])` | Ridisegna una riga, o tutte le righe, dopo che hai modificato direttamente i dati. |\n| `remove()` | Rimuove tutte le righe. |\n\n## Associare un elenco a un path\n\nIl comando `vbindarray` collega un elenco a un path globale. Inserisci la riga in un elemento `<template>` o `<script type=\"text/html\">` all'interno dell'associazione. All'interno di una riga, `el.vbind()` restituisce il binder della riga, e la sua proprietà `index` è la posizione della riga.\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"products\" config=\"vbindarray\">\n\t\t<template>\n\t\t\t<li><span data-bind=\".name__text\"></span> <button data-bind=\".id__click:remove\">Remove</button></li>\n\t\t</template>\n\t</ui-bind>\n</ul>\n\n<script>\n\tfunction remove(el, e, id) {\n\t\tvar index = el.vbind().index;\n\t\tconsole.log('remove', id, 'at', index);\n\t\tproducts.splice(index, 1);\n\t\tUPD('products');\n\t}\n\n\tSET('products', [{ id: 1, name: 'Tea' }, { id: 2, name: 'Milk' }, { id: 3, name: 'Soy' }]);\n</script>\n```\n\nFacendo clic su `Remove` nella seconda riga viene stampato `remove 2 at 1`, e l'elenco mantiene `Tea` e `Soy`.\n\n## Formattare i valori con i metodi di riga\n\nUn valore che inizia con un punto chiama un metodo dell'oggetto elenco.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li data-bind=\".price__text:.money\"></li>', '#list');\n\n\trows.money = function(value) {\n\t\treturn value.format(2) + ' EUR';\n\t};\n\n\trows.set([{ price: 10 }, { price: 2.5 }]);\n\tconsole.log($('#list').text());   // 10.00 EUR2.50 EUR\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUD28M61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/virtual-bindings/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Virtuálne väzby","summary":"Vykresli samostatné HTML a opakované riadky zo súkromného modelu, mimo globálnych dát.","markdown":"---\ntitle: \"Virtuálne väzby\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/virtual-bindings/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Virtuálne väzby\n\n> Vykresli samostatné HTML a opakované riadky zo súkromného modelu, mimo globálnych dát.\n\nVirtuálna väzba spája kus HTML so súkromným modelom namiesto globálneho [path](../paths/). Hodí sa na opakovaný obsah, ako sú riadky tabuľky, položky zoznamu a karty, kde má každá položka vlastné dáta.\n\n## Naviaž kus HTML\n\n[VBIND()](../../reference/globals/) vytvorí HTML a vráti objekt binder. Paths v ňom začínajú bodkou a sú relatívne voči modelu. Samotná bodka zastupuje celý model. Príkazy sú rovnaké ako v časti [Dátová väzba](../data-binding/).\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div class=\"card\"><h3 data-bind=\".name__text\"></h3><span data-bind=\".age__text__.senior:value >= 65\"></span></div>');\n\n\t$('#host').append(card.element);\n\n\tcard.set({ name: 'Ana', age: 70 });\n\tconsole.log(card.element.find('h3').text());          // Ana\n\tconsole.log(card.element.find('span').text());        // 70\n\tconsole.log(card.element.find('span').attr('class')); // senior\n</script>\n```\n\nBinder sa k stránke sám nepripojí. Pridaj `card.element`, objekt jQuery, tam, kde ho potrebuješ.\n\n## Aktualizuj model\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><b data-bind=\".name__text\"></b> <i data-bind=\".__text:value.name + \\' (\\' + value.age + \\')\\'\"></i></div>');\n\n\t$('#host').append(card.element);\n\tcard.set({ name: 'Ana', age: 30 });\n\tconsole.log(card.element.text());   // Ana Ana (30)\n\n\tcard.set('age', 31);\n\tconsole.log(card.get('age'));       // 31\n\tconsole.log(card.element.text());   // Ana Ana (31)\n\n\tcard.get().name = 'Ben';\n\tcard.upd('name');\n\tconsole.log(card.element.text());   // Ben Ben (31)\n\n\tconsole.log(card.get());            // {\"name\":\"Ben\",\"age\":31}\n</script>\n```\n\n| Člen | Popis |\n| --- | --- |\n| `element` | HTML bindera ako objekt jQuery. |\n| `set(model)` | Nahradí model a prekreslí všetky väzby. |\n| `set(path, value)` | Zmení jedno pole a prekreslí väzby, ktoré od neho závisia. |\n| `get([path])` | Prečíta model alebo jedno pole. |\n| `upd([path])` | Prekreslí väzby po tom, čo si model zmenil priamo. |\n| `on(event, [selector], fn)` | Pridá na element poslucháča udalosti. |\n| `remove()` | Odstráni element a jeho poslucháčov. |\n\n## Spracuj udalosti a odstráň binder\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tvar card = VBIND('<div><button>Open</button></div>');\n\n\tcard.on('click', 'button', function() {\n\t\tconsole.log('clicked');\n\t});\n\n\t$('#host').append(card.element);\n\tcard.element.find('button').click();   // clicked\n\n\tcard.remove();\n\tconsole.log($('#host').html());        // (empty)\n</script>\n```\n\n## Vykresli zoznam\n\n[VBINDARRAY()](../../reference/globals/) zopakuje jednu šablónu pre každú položku poľa a pripojí riadky k cieľovému elementu. Každý riadok dostane atribút `data-index`. Keď nastavíš nové pole, existujúce riadky sa použijú znova, nadbytočné sa odstránia a prekreslia sa iba riadky, ktorých dáta sa zmenili.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li><b data-bind=\".name__text\"></b> <span data-bind=\".price__text__format:2\"></span></li>', '#list');\n\n\trows.set([{ name: 'Tea', price: 2 }, { name: 'Milk', price: 1.5 }]);\n\tconsole.log($('#list').text());     // Tea 2.00Milk 1.50\n\n\trows.set(1, { name: 'Soy milk', price: 2.25 });\n\tconsole.log($('#list').text());     // Tea 2.00Soy milk 2.25\n\n\trows.get(0).price = 3;\n\trows.upd(0);\n\tconsole.log($('#list').text());     // Tea 3.00Soy milk 2.25\n\n\trows.set([{ name: 'Water', price: 1 }]);\n\tconsole.log($('#list').text());     // Water 1.00\n\tconsole.log(rows.items.length);     // 1\n\n\tconsole.log($('#list li').attr('data-index'));  // 0\n</script>\n```\n\n| Člen | Popis |\n| --- | --- |\n| `items` | Bindery riadkov. |\n| `set(array)` | Vykreslí pole. |\n| `set(index, item)` | Nahradí jeden riadok. |\n| `get([index])` | Prečíta pole alebo jednu položku. |\n| `upd([index])` | Prekreslí jeden riadok alebo všetky riadky po tom, čo si dáta zmenil priamo. |\n| `remove()` | Odstráni všetky riadky. |\n\n## Naviaž zoznam na path\n\nPríkaz `vbindarray` spojí zoznam s globálnym path. Riadok vlož do elementu `<template>` alebo `<script type=\"text/html\">` vnútri väzby. Vnútri riadku vráti `el.vbind()` binder riadku a jeho vlastnosť `index` udáva pozíciu riadku.\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"products\" config=\"vbindarray\">\n\t\t<template>\n\t\t\t<li><span data-bind=\".name__text\"></span> <button data-bind=\".id__click:remove\">Remove</button></li>\n\t\t</template>\n\t</ui-bind>\n</ul>\n\n<script>\n\tfunction remove(el, e, id) {\n\t\tvar index = el.vbind().index;\n\t\tconsole.log('remove', id, 'at', index);\n\t\tproducts.splice(index, 1);\n\t\tUPD('products');\n\t}\n\n\tSET('products', [{ id: 1, name: 'Tea' }, { id: 2, name: 'Milk' }, { id: 3, name: 'Soy' }]);\n</script>\n```\n\nKliknutie na `Remove` v druhom riadku vypíše `remove 2 at 1` a v zozname zostanú `Tea` a `Soy`.\n\n## Formátuj hodnoty metódami riadku\n\nHodnota, ktorá začína bodkou, volá metódu objektu zoznamu.\n\n```html\n<ul id=\"list\"></ul>\n\n<script>\n\tvar rows = VBINDARRAY('<li data-bind=\".price__text:.money\"></li>', '#list');\n\n\trows.money = function(value) {\n\t\treturn value.format(2) + ' EUR';\n\t};\n\n\trows.set([{ price: 10 }, { price: 2.5 }]);\n\tconsole.log($('#list').text());   // 10.00 EUR2.50 EUR\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammUA26M61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/using-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Using components","summary":"Place components on a page, configure them, and find and control them from code.","markdown":"---\ntitle: Using components\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/using-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Using components\n\n> Place components on a page, configure them, and find and control them from code.\n\nA component is a reusable piece of UI. This guide shows how to place and control components that already exist. To write your own, read [Creating components](../creating-components/).\n\n## Place a component\n\n```html\n<ui-component name=\"stat\" path=\"sales.today\" config=\"label:Sales today;unit:EUR\"></ui-component>\n\n<script>\n\tCOMPONENT('stat', 'label:Value;unit:', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.label + ': ' + value + ' ' + config.unit);\n\t\t};\n\t});\n\n\tSET('sales.today', 1250);\n</script>\n```\n\nThe element renders `Sales today: 1250 EUR`.\n\n| Attribute | Description |\n| --- | --- |\n| `name` | The name of the component. |\n| `path` | The [path](../paths/) of the value the component works with. |\n| `config` | The configuration of this instance. |\n| `default` | A JavaScript expression with the default value. |\n\n## Write the configuration\n\nThe configuration is a list of `key:value` pairs separated by semicolons. Numbers and the words `true` and `false` become real numbers and booleans. Write `\\;` and `\\:` to use these characters in a value. URLs that start with `http://`, `https://`, `ws://` or `wss://` need no escaping.\n\n```html\n<ui-component name=\"show\" config=\"title:Report;size:12;ratio:1.5;open:true;url:https://example.com/a;note:one\\;two;time:10\\:30\"></ui-component>\n\n<script>\n\tCOMPONENT('show', function(self, config) {\n\t\tself.make = function() {\n\t\t\tconsole.log(config.title, config.size, config.ratio, config.open, config.url, config.note, config.time);\n\t\t\tconsole.log(typeof config.size, typeof config.open);\n\t\t};\n\t});\n</script>\n```\n\nThe component prints `Report 12 1.5 true https://example.com/a one;two 10:30`, and then `number boolean`.\n\n## Use the data attribute\n\nThe `data---` attribute places a component on any element. It joins the name, path, configuration and default value with two underscores.\n\n```html\n<div id=\"a\" data---=\"tag__label.text__color:red__'Default text'\"></div>\n\n<script>\n\tCOMPONENT('tag', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ': ' + value);\n\t\t};\n\t});\n</script>\n```\n\nCall [COMPILE()](../../reference/globals/) after you insert elements with this attribute into a running page.\n\n## Set a default value\n\nWhen the path has no value, the component stores the result of the `default` expression. Text needs quotes inside the expression. [DEFAULT()](../../reference/globals/) restores the default values of all the components below a path.\n\n```html\n<ui-component name=\"field\" path=\"form.city\" default=\"'Rome'\"></ui-component>\n<ui-component name=\"field\" path=\"form.size\" default=\"10\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\n\t\tSET('form', { city: 'Oslo', size: 20 });\n\t\tDEFAULT('form');\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\t});\n</script>\n```\n\n## Special configuration keys\n\n| Key | Effect |\n| --- | --- |\n| `$id:name` | Sets the identifier used by `FIND('#name')`. |\n| `$class:name` | Toggles a CSS class on the element. |\n| `$assign:path` | Stores the component instance at a path. |\n| `$init:name` | Calls the global function `name(component)` when the component is ready. |\n\n```html\n<ui-component id=\"el\" name=\"panel\" config=\"$id:main;$class:highlight;$assign:panels.main;$init:onpanel\"></ui-component>\n\n<script>\n\tCOMPONENT('panel', function(self) {});\n\n\tfunction onpanel(com) {\n\t\tconsole.log('init', com.id);\n\t}\n\n\tON('ready', function() {\n\t\tconsole.log(FIND('#main').name);  // panel\n\t\tconsole.log(document.getElementById('el').className);\n\t});\n</script>\n```\n\n## Link a setting to a path\n\nA `=` in front of a key reads the setting from a path and updates the component each time that path changes.\n\n```html\n<ui-component name=\"heading\" config=\"=title:page.title;level:2\"></ui-component>\n\n<script>\n\tCOMPONENT('heading', function(self, config) {\n\t\tself.configure = function(key, value) {\n\t\t\tif (key === 'title')\n\t\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tSET('page.title', 'Draft');\n</script>\n```\n\nThe element shows `Draft`, and it shows `Published` after `SET('page.title', 'Published')`.\n\n## Find and control components\n\n[FIND()](../../reference/globals/) returns a component. With `true` as the second argument it returns an array of all the matches. [SETTER()](../../reference/globals/) calls a method on all the matches, and [RECONFIGURE()](../../reference/globals/) changes their configuration.\n\n```html\n<ui-component name=\"alert\" path=\"msg.a\" config=\"$id:first\"></ui-component>\n<ui-component name=\"alert\" path=\"msg.b\"></ui-component>\n\n<script>\n\tCOMPONENT('alert', function(self, config) {\n\n\t\tself.flash = function(text) {\n\t\t\tconsole.log(self.path, 'flash', text);\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'color' && !init)\n\t\t\t\tconsole.log(self.path, 'color', value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tconsole.log(FIND('alert').path);          // msg.a\n\t\tconsole.log(FIND('alert', true).length);  // 2\n\t\tconsole.log(FIND('.msg.b').path);         // msg.b\n\t\tconsole.log(FIND('#first').path);         // msg.a\n\t\tconsole.log(FIND('alert[msg.b]').path);   // msg.b\n\n\t\tSETTER('#first', 'flash', 'one');         // msg.a flash one\n\t\tSETTER('.msg.b/flash', 'two');            // msg.b flash two\n\t\tSETTER('alert/flash', 'all');             // msg.a flash all, msg.b flash all\n\n\t\tRECONFIGURE('#first', 'color:red');       // msg.a color red\n\t});\n</script>\n```\n\n| Selector | Finds components |\n| --- | --- |\n| `name` | With this name. |\n| `.path` | With this path. |\n| `#id` | With this identifier. |\n| `name[path]` | With this name and path. |\n\n## Send a command\n\n[CMD()](../../reference/globals/) runs a named command in every component that registered it, so the caller needs no selector.\n\n```html\n<ui-component name=\"box\" path=\"a\"></ui-component>\n<ui-component name=\"box\" path=\"b\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.command('refresh', function(reason) {\n\t\t\tconsole.log(self.path, 'refresh:', reason);\n\t\t});\n\t});\n\n\tON('ready', function() {\n\t\tCMD('refresh', 'manual');\n\t\t// a refresh: manual\n\t\t// b refresh: manual\n\t});\n</script>\n```\n\n## Add components at runtime\n\nA `<ui-component>` element added to the page starts by itself. [ADD()](../../reference/globals/) creates one from a string with the name, path and configuration.\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tCOMPONENT('tag', 'color:gray', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ' ' + value);\n\t\t};\n\t});\n\n\tSET('label', 'new');\n\n\tsetTimeout(function() {\n\n\t\tADD('tag__label__color:green', '#host');\n\t\t$('#host').append('<ui-component name=\"tag\" path=\"label\" config=\"color:blue\"></ui-component>');\n\n\t}, 300);\n</script>\n```\n\nThe host element ends up with `green new` and `blue new`.\n\n## Load a component on demand\n\nA name with the `LAZY` prefix leaves the component uninitialized until the first `SETTER()` call for it.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\n\tCOMPONENT('dialog', function(self) {\n\n\t\tself.make = function() {\n\t\t\tconsole.log('dialog created');\n\t\t};\n\n\t\tself.open = function(title) {\n\t\t\tconsole.log('open', title);\n\t\t};\n\t});\n\n\tsetTimeout(function() {\n\t\tconsole.log(FIND('dialog') == null);   // true\n\t\tSETTER('dialog/open', 'Help');         // dialog created, open Help\n\t}, 500);\n</script>\n```\n\n## Use several versions\n\nA component name can carry a version after `@`. The element receives the class `jc-v` followed by the version.\n\n```html\n<ui-component id=\"old\" name=\"widget@1\"></ui-component>\n<ui-component id=\"new\" name=\"widget@2\"></ui-component>\n\n<script>\n\tCOMPONENT('widget@1', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n\n\tCOMPONENT('widget@2', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n</script>\n```\n\n## Style the state of a component\n\nThe library keeps these classes on the element of the component, so you can style each state with CSS:\n\n| Class | Present when |\n| --- | --- |\n| `ui-touched` | The user interacted with the component. |\n| `ui-modified` | The value was changed through the component. |\n| `ui-invalid` | The validation of the component failed. |\n| `ui-disabled` | The configuration contains `disabled:true`. |\n\n```html\n<ui-component id=\"name\" name=\"required\" path=\"form.name\"></ui-component>\n\n<script>\n\tCOMPONENT('required', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn !!value;\n\t\t};\n\t});\n</script>\n```\n\nAn empty field starts with `ui-invalid`. After the user types, it has `ui-modified` and `ui-touched`. `RESET('form')` clears them again.\n\n## React to creation and removal\n\n`ON('@name', fn)` runs when a component with that name is created, and `ON('#id', fn)` does the same for an identifier. `element.ui` and `$(element).component()` return the instance of an element. [FREE()](../../reference/globals/) makes the library clean up removed elements right away, which calls their `destroy` function.\n\n```html\n<ui-component id=\"a\" name=\"temp\"></ui-component>\n\n<script>\n\tCOMPONENT('temp', function(self) {\n\t\tself.destroy = function() {\n\t\t\tconsole.log('destroyed');\n\t\t};\n\t});\n\n\tON('@temp', com => console.log('created', com.name));\n\n\tON('ready', function() {\n\t\tconsole.log(document.getElementById('a').ui.name);   // temp\n\t\tconsole.log($('#a').component().name);               // temp\n\n\t\t$('#a').remove();\n\t\tFREE();                                              // destroyed\n\t});\n</script>\n```\n\n## Components that are not on the page\n\nWhen a page uses a component that is not declared, the library downloads it from the address in `DEF.fallback`, by default `https://cdn.componentator.com/j-{0}.html`, where `{0}` is the lowercase name of the component. Set `DEF.fallback` to an empty string to turn this off.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammUA26M61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/using-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Komponenten verwenden","summary":"Platziere Komponenten auf einer Seite, konfiguriere sie und finde und steuere sie aus dem Code.","markdown":"---\ntitle: Komponenten verwenden\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/using-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Komponenten verwenden\n\n> Platziere Komponenten auf einer Seite, konfiguriere sie und finde und steuere sie aus dem Code.\n\nEine Komponente ist ein wiederverwendbares Stück Benutzeroberfläche. Dieser Leitfaden zeigt, wie du vorhandene Komponenten platzierst und steuerst. Wie du eigene schreibst, erfährst du unter [Komponenten erstellen](../creating-components/).\n\n## Eine Komponente platzieren\n\n```html\n<ui-component name=\"stat\" path=\"sales.today\" config=\"label:Sales today;unit:EUR\"></ui-component>\n\n<script>\n\tCOMPONENT('stat', 'label:Value;unit:', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.label + ': ' + value + ' ' + config.unit);\n\t\t};\n\t});\n\n\tSET('sales.today', 1250);\n</script>\n```\n\nDas Element rendert `Sales today: 1250 EUR`.\n\n| Attribut | Beschreibung |\n| --- | --- |\n| `name` | Der Name der Komponente. |\n| `path` | Der [Path](../paths/) des Werts, mit dem die Komponente arbeitet. |\n| `config` | Die Konfiguration dieser Instanz. |\n| `default` | Ein JavaScript-Ausdruck mit dem Standardwert. |\n\n## Die Konfiguration schreiben\n\nDie Konfiguration ist eine Liste von `key:value`-Paaren, getrennt durch Semikolons. Zahlen und die Wörter `true` und `false` werden zu echten Zahlen und booleschen Werten. Schreibe `\\;` und `\\:`, um diese Zeichen in einem Wert zu verwenden. URLs, die mit `http://`, `https://`, `ws://` oder `wss://` beginnen, musst du nicht maskieren.\n\n```html\n<ui-component name=\"show\" config=\"title:Report;size:12;ratio:1.5;open:true;url:https://example.com/a;note:one\\;two;time:10\\:30\"></ui-component>\n\n<script>\n\tCOMPONENT('show', function(self, config) {\n\t\tself.make = function() {\n\t\t\tconsole.log(config.title, config.size, config.ratio, config.open, config.url, config.note, config.time);\n\t\t\tconsole.log(typeof config.size, typeof config.open);\n\t\t};\n\t});\n</script>\n```\n\nDie Komponente gibt `Report 12 1.5 true https://example.com/a one;two 10:30` aus und danach `number boolean`.\n\n## Das data-Attribut verwenden\n\nDas Attribut `data---` platziert eine Komponente auf einem beliebigen Element. Es verbindet Name, Path, Konfiguration und Standardwert mit zwei Unterstrichen.\n\n```html\n<div id=\"a\" data---=\"tag__label.text__color:red__'Default text'\"></div>\n\n<script>\n\tCOMPONENT('tag', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ': ' + value);\n\t\t};\n\t});\n</script>\n```\n\nRufe [COMPILE()](../../reference/globals/) auf, nachdem du Elemente mit diesem Attribut in eine laufende Seite eingefügt hast.\n\n## Einen Standardwert festlegen\n\nHat der Path keinen Wert, speichert die Komponente das Ergebnis des `default`-Ausdrucks. Text braucht innerhalb des Ausdrucks Anführungszeichen. [DEFAULT()](../../reference/globals/) stellt die Standardwerte aller Komponenten unterhalb eines Paths wieder her.\n\n```html\n<ui-component name=\"field\" path=\"form.city\" default=\"'Rome'\"></ui-component>\n<ui-component name=\"field\" path=\"form.size\" default=\"10\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\n\t\tSET('form', { city: 'Oslo', size: 20 });\n\t\tDEFAULT('form');\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\t});\n</script>\n```\n\n## Spezielle Konfigurationsschlüssel\n\n| Schlüssel | Wirkung |\n| --- | --- |\n| `$id:name` | Legt die Kennung fest, die `FIND('#name')` verwendet. |\n| `$class:name` | Schaltet eine CSS-Klasse am Element um. |\n| `$assign:path` | Speichert die Instanz der Komponente unter einem Path. |\n| `$init:name` | Ruft die globale Funktion `name(component)` auf, sobald die Komponente bereit ist. |\n\n```html\n<ui-component id=\"el\" name=\"panel\" config=\"$id:main;$class:highlight;$assign:panels.main;$init:onpanel\"></ui-component>\n\n<script>\n\tCOMPONENT('panel', function(self) {});\n\n\tfunction onpanel(com) {\n\t\tconsole.log('init', com.id);\n\t}\n\n\tON('ready', function() {\n\t\tconsole.log(FIND('#main').name);  // panel\n\t\tconsole.log(document.getElementById('el').className);\n\t});\n</script>\n```\n\n## Eine Einstellung mit einem Path verknüpfen\n\nEin `=` vor einem Schlüssel liest die Einstellung aus einem Path und aktualisiert die Komponente bei jeder Änderung dieses Paths.\n\n```html\n<ui-component name=\"heading\" config=\"=title:page.title;level:2\"></ui-component>\n\n<script>\n\tCOMPONENT('heading', function(self, config) {\n\t\tself.configure = function(key, value) {\n\t\t\tif (key === 'title')\n\t\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tSET('page.title', 'Draft');\n</script>\n```\n\nDas Element zeigt `Draft` und nach `SET('page.title', 'Published')` dann `Published`.\n\n## Komponenten finden und steuern\n\n[FIND()](../../reference/globals/) gibt eine Komponente zurück. Mit `true` als zweitem Argument erhältst du ein Array aller Treffer. [SETTER()](../../reference/globals/) ruft eine Methode auf allen Treffern auf, und [RECONFIGURE()](../../reference/globals/) ändert ihre Konfiguration.\n\n```html\n<ui-component name=\"alert\" path=\"msg.a\" config=\"$id:first\"></ui-component>\n<ui-component name=\"alert\" path=\"msg.b\"></ui-component>\n\n<script>\n\tCOMPONENT('alert', function(self, config) {\n\n\t\tself.flash = function(text) {\n\t\t\tconsole.log(self.path, 'flash', text);\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'color' && !init)\n\t\t\t\tconsole.log(self.path, 'color', value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tconsole.log(FIND('alert').path);          // msg.a\n\t\tconsole.log(FIND('alert', true).length);  // 2\n\t\tconsole.log(FIND('.msg.b').path);         // msg.b\n\t\tconsole.log(FIND('#first').path);         // msg.a\n\t\tconsole.log(FIND('alert[msg.b]').path);   // msg.b\n\n\t\tSETTER('#first', 'flash', 'one');         // msg.a flash one\n\t\tSETTER('.msg.b/flash', 'two');            // msg.b flash two\n\t\tSETTER('alert/flash', 'all');             // msg.a flash all, msg.b flash all\n\n\t\tRECONFIGURE('#first', 'color:red');       // msg.a color red\n\t});\n</script>\n```\n\n| Selektor | Findet Komponenten |\n| --- | --- |\n| `name` | Mit diesem Namen. |\n| `.path` | Mit diesem Path. |\n| `#id` | Mit dieser Kennung. |\n| `name[path]` | Mit diesem Namen und Path. |\n\n## Einen Befehl senden\n\n[CMD()](../../reference/globals/) führt einen benannten Befehl in jeder Komponente aus, die ihn registriert hat. Der Aufrufer braucht daher keinen Selektor.\n\n```html\n<ui-component name=\"box\" path=\"a\"></ui-component>\n<ui-component name=\"box\" path=\"b\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.command('refresh', function(reason) {\n\t\t\tconsole.log(self.path, 'refresh:', reason);\n\t\t});\n\t});\n\n\tON('ready', function() {\n\t\tCMD('refresh', 'manual');\n\t\t// a refresh: manual\n\t\t// b refresh: manual\n\t});\n</script>\n```\n\n## Komponenten zur Laufzeit hinzufügen\n\nEin `<ui-component>`-Element, das du der Seite hinzufügst, startet von selbst. [ADD()](../../reference/globals/) erstellt eines aus einem String mit Name, Path und Konfiguration.\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tCOMPONENT('tag', 'color:gray', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ' ' + value);\n\t\t};\n\t});\n\n\tSET('label', 'new');\n\n\tsetTimeout(function() {\n\n\t\tADD('tag__label__color:green', '#host');\n\t\t$('#host').append('<ui-component name=\"tag\" path=\"label\" config=\"color:blue\"></ui-component>');\n\n\t}, 300);\n</script>\n```\n\nDas Host-Element enthält am Ende `green new` und `blue new`.\n\n## Eine Komponente bei Bedarf laden\n\nEin Name mit dem Präfix `LAZY` lässt die Komponente uninitialisiert, bis zum ersten `SETTER()`-Aufruf für sie.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\n\tCOMPONENT('dialog', function(self) {\n\n\t\tself.make = function() {\n\t\t\tconsole.log('dialog created');\n\t\t};\n\n\t\tself.open = function(title) {\n\t\t\tconsole.log('open', title);\n\t\t};\n\t});\n\n\tsetTimeout(function() {\n\t\tconsole.log(FIND('dialog') == null);   // true\n\t\tSETTER('dialog/open', 'Help');         // dialog created, open Help\n\t}, 500);\n</script>\n```\n\n## Mehrere Versionen verwenden\n\nEin Komponentenname kann nach `@` eine Version tragen. Das Element erhält die Klasse `jc-v`, gefolgt von der Version.\n\n```html\n<ui-component id=\"old\" name=\"widget@1\"></ui-component>\n<ui-component id=\"new\" name=\"widget@2\"></ui-component>\n\n<script>\n\tCOMPONENT('widget@1', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n\n\tCOMPONENT('widget@2', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n</script>\n```\n\n## Den Zustand einer Komponente gestalten\n\nDie Bibliothek hält diese Klassen am Element der Komponente aktuell, sodass du jeden Zustand mit CSS gestalten kannst:\n\n| Klasse | Vorhanden, wenn |\n| --- | --- |\n| `ui-touched` | Der Benutzer mit der Komponente interagiert hat. |\n| `ui-modified` | Der Wert über die Komponente geändert wurde. |\n| `ui-invalid` | Die Validierung der Komponente fehlgeschlagen ist. |\n| `ui-disabled` | Die Konfiguration `disabled:true` enthält. |\n\n```html\n<ui-component id=\"name\" name=\"required\" path=\"form.name\"></ui-component>\n\n<script>\n\tCOMPONENT('required', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn !!value;\n\t\t};\n\t});\n</script>\n```\n\nEin leeres Feld beginnt mit `ui-invalid`. Nachdem der Benutzer etwas eingegeben hat, trägt es `ui-modified` und `ui-touched`. `RESET('form')` entfernt diese Klassen wieder.\n\n## Auf Erstellen und Entfernen reagieren\n\n`ON('@name', fn)` wird ausgeführt, wenn eine Komponente mit diesem Namen erstellt wird, und `ON('#id', fn)` tut dasselbe für eine Kennung. `element.ui` und `$(element).component()` geben die Instanz eines Elements zurück. [FREE()](../../reference/globals/) lässt die Bibliothek entfernte Elemente sofort aufräumen und ruft dabei deren `destroy`-Funktion auf.\n\n```html\n<ui-component id=\"a\" name=\"temp\"></ui-component>\n\n<script>\n\tCOMPONENT('temp', function(self) {\n\t\tself.destroy = function() {\n\t\t\tconsole.log('destroyed');\n\t\t};\n\t});\n\n\tON('@temp', com => console.log('created', com.name));\n\n\tON('ready', function() {\n\t\tconsole.log(document.getElementById('a').ui.name);   // temp\n\t\tconsole.log($('#a').component().name);               // temp\n\n\t\t$('#a').remove();\n\t\tFREE();                                              // destroyed\n\t});\n</script>\n```\n\n## Komponenten, die nicht auf der Seite vorhanden sind\n\nVerwendet eine Seite eine nicht deklarierte Komponente, lädt die Bibliothek sie von der Adresse in `DEF.fallback` herunter, standardmäßig `https://cdn.componentator.com/j-{0}.html`, wobei `{0}` der kleingeschriebene Name der Komponente ist. Setze `DEF.fallback` auf einen leeren String, um das abzuschalten.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammUA26M61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/using-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Usar componentes","summary":"Coloca componentes en una página, configúralos y búscalos y contrólalos desde el código.","markdown":"---\ntitle: Usar componentes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/using-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Usar componentes\n\n> Coloca componentes en una página, configúralos y búscalos y contrólalos desde el código.\n\nUn componente es una pieza reutilizable de la interfaz. Esta guía te muestra cómo colocar y controlar componentes que ya existen. Para escribir los tuyos, lee [Crear componentes](../creating-components/).\n\n## Colocar un componente\n\n```html\n<ui-component name=\"stat\" path=\"sales.today\" config=\"label:Sales today;unit:EUR\"></ui-component>\n\n<script>\n\tCOMPONENT('stat', 'label:Value;unit:', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.label + ': ' + value + ' ' + config.unit);\n\t\t};\n\t});\n\n\tSET('sales.today', 1250);\n</script>\n```\n\nEl elemento renderiza `Sales today: 1250 EUR`.\n\n| Atributo | Descripción |\n| --- | --- |\n| `name` | El nombre del componente. |\n| `path` | El [path](../paths/) del valor con el que trabaja el componente. |\n| `config` | La configuración de esta instancia. |\n| `default` | Una expresión JavaScript con el valor predeterminado. |\n\n## Escribir la configuración\n\nLa configuración es una lista de pares `key:value` separados por punto y coma. Los números y las palabras `true` y `false` se convierten en números y booleanos reales. Escribe `\\;` y `\\:` para usar estos caracteres en un valor. Las URL que empiezan por `http://`, `https://`, `ws://` o `wss://` no necesitan escape.\n\n```html\n<ui-component name=\"show\" config=\"title:Report;size:12;ratio:1.5;open:true;url:https://example.com/a;note:one\\;two;time:10\\:30\"></ui-component>\n\n<script>\n\tCOMPONENT('show', function(self, config) {\n\t\tself.make = function() {\n\t\t\tconsole.log(config.title, config.size, config.ratio, config.open, config.url, config.note, config.time);\n\t\t\tconsole.log(typeof config.size, typeof config.open);\n\t\t};\n\t});\n</script>\n```\n\nEl componente imprime `Report 12 1.5 true https://example.com/a one;two 10:30` y, a continuación, `number boolean`.\n\n## Usar el atributo data\n\nEl atributo `data---` coloca un componente en cualquier elemento. Une el nombre, el path, la configuración y el valor predeterminado con dos guiones bajos.\n\n```html\n<div id=\"a\" data---=\"tag__label.text__color:red__'Default text'\"></div>\n\n<script>\n\tCOMPONENT('tag', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ': ' + value);\n\t\t};\n\t});\n</script>\n```\n\nLlama a [COMPILE()](../../reference/globals/) después de insertar elementos con este atributo en una página que ya está en marcha.\n\n## Definir un valor predeterminado\n\nCuando el path no tiene valor, el componente guarda el resultado de la expresión `default`. El texto necesita comillas dentro de la expresión. [DEFAULT()](../../reference/globals/) restaura los valores predeterminados de todos los componentes que hay bajo un path.\n\n```html\n<ui-component name=\"field\" path=\"form.city\" default=\"'Rome'\"></ui-component>\n<ui-component name=\"field\" path=\"form.size\" default=\"10\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\n\t\tSET('form', { city: 'Oslo', size: 20 });\n\t\tDEFAULT('form');\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\t});\n</script>\n```\n\n## Claves especiales de configuración\n\n| Clave | Efecto |\n| --- | --- |\n| `$id:name` | Define el identificador que usa `FIND('#name')`. |\n| `$class:name` | Alterna una clase CSS en el elemento. |\n| `$assign:path` | Guarda la instancia del componente en un path. |\n| `$init:name` | Llama a la función global `name(component)` cuando el componente está listo. |\n\n```html\n<ui-component id=\"el\" name=\"panel\" config=\"$id:main;$class:highlight;$assign:panels.main;$init:onpanel\"></ui-component>\n\n<script>\n\tCOMPONENT('panel', function(self) {});\n\n\tfunction onpanel(com) {\n\t\tconsole.log('init', com.id);\n\t}\n\n\tON('ready', function() {\n\t\tconsole.log(FIND('#main').name);  // panel\n\t\tconsole.log(document.getElementById('el').className);\n\t});\n</script>\n```\n\n## Vincular un ajuste a un path\n\nUn `=` delante de una clave lee el ajuste desde un path y actualiza el componente cada vez que ese path cambia.\n\n```html\n<ui-component name=\"heading\" config=\"=title:page.title;level:2\"></ui-component>\n\n<script>\n\tCOMPONENT('heading', function(self, config) {\n\t\tself.configure = function(key, value) {\n\t\t\tif (key === 'title')\n\t\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tSET('page.title', 'Draft');\n</script>\n```\n\nEl elemento muestra `Draft`, y muestra `Published` después de `SET('page.title', 'Published')`.\n\n## Buscar y controlar componentes\n\n[FIND()](../../reference/globals/) devuelve un componente. Con `true` como segundo argumento devuelve un array con todas las coincidencias. [SETTER()](../../reference/globals/) llama a un método en todas las coincidencias, y [RECONFIGURE()](../../reference/globals/) cambia su configuración.\n\n```html\n<ui-component name=\"alert\" path=\"msg.a\" config=\"$id:first\"></ui-component>\n<ui-component name=\"alert\" path=\"msg.b\"></ui-component>\n\n<script>\n\tCOMPONENT('alert', function(self, config) {\n\n\t\tself.flash = function(text) {\n\t\t\tconsole.log(self.path, 'flash', text);\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'color' && !init)\n\t\t\t\tconsole.log(self.path, 'color', value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tconsole.log(FIND('alert').path);          // msg.a\n\t\tconsole.log(FIND('alert', true).length);  // 2\n\t\tconsole.log(FIND('.msg.b').path);         // msg.b\n\t\tconsole.log(FIND('#first').path);         // msg.a\n\t\tconsole.log(FIND('alert[msg.b]').path);   // msg.b\n\n\t\tSETTER('#first', 'flash', 'one');         // msg.a flash one\n\t\tSETTER('.msg.b/flash', 'two');            // msg.b flash two\n\t\tSETTER('alert/flash', 'all');             // msg.a flash all, msg.b flash all\n\n\t\tRECONFIGURE('#first', 'color:red');       // msg.a color red\n\t});\n</script>\n```\n\n| Selector | Busca componentes |\n| --- | --- |\n| `name` | Con este nombre. |\n| `.path` | Con este path. |\n| `#id` | Con este identificador. |\n| `name[path]` | Con este nombre y este path. |\n\n## Enviar un comando\n\n[CMD()](../../reference/globals/) ejecuta un comando con nombre en cada componente que lo haya registrado, así que quien llama no necesita ningún selector.\n\n```html\n<ui-component name=\"box\" path=\"a\"></ui-component>\n<ui-component name=\"box\" path=\"b\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.command('refresh', function(reason) {\n\t\t\tconsole.log(self.path, 'refresh:', reason);\n\t\t});\n\t});\n\n\tON('ready', function() {\n\t\tCMD('refresh', 'manual');\n\t\t// a refresh: manual\n\t\t// b refresh: manual\n\t});\n</script>\n```\n\n## Añadir componentes en tiempo de ejecución\n\nUn elemento `<ui-component>` añadido a la página se inicia por sí solo. [ADD()](../../reference/globals/) crea uno a partir de una cadena con el nombre, el path y la configuración.\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tCOMPONENT('tag', 'color:gray', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ' ' + value);\n\t\t};\n\t});\n\n\tSET('label', 'new');\n\n\tsetTimeout(function() {\n\n\t\tADD('tag__label__color:green', '#host');\n\t\t$('#host').append('<ui-component name=\"tag\" path=\"label\" config=\"color:blue\"></ui-component>');\n\n\t}, 300);\n</script>\n```\n\nEl elemento contenedor termina con `green new` y `blue new`.\n\n## Cargar un componente bajo demanda\n\nUn nombre con el prefijo `LAZY` deja el componente sin inicializar hasta la primera llamada a `SETTER()` dirigida a él.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\n\tCOMPONENT('dialog', function(self) {\n\n\t\tself.make = function() {\n\t\t\tconsole.log('dialog created');\n\t\t};\n\n\t\tself.open = function(title) {\n\t\t\tconsole.log('open', title);\n\t\t};\n\t});\n\n\tsetTimeout(function() {\n\t\tconsole.log(FIND('dialog') == null);   // true\n\t\tSETTER('dialog/open', 'Help');         // dialog created, open Help\n\t}, 500);\n</script>\n```\n\n## Usar varias versiones\n\nEl nombre de un componente puede llevar una versión después de `@`. El elemento recibe la clase `jc-v` seguida de la versión.\n\n```html\n<ui-component id=\"old\" name=\"widget@1\"></ui-component>\n<ui-component id=\"new\" name=\"widget@2\"></ui-component>\n\n<script>\n\tCOMPONENT('widget@1', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n\n\tCOMPONENT('widget@2', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n</script>\n```\n\n## Dar estilo al estado de un componente\n\nLa biblioteca mantiene estas clases en el elemento del componente, de modo que puedes dar estilo a cada estado con CSS:\n\n| Clase | Presente cuando |\n| --- | --- |\n| `ui-touched` | El usuario ha interactuado con el componente. |\n| `ui-modified` | El valor se ha cambiado a través del componente. |\n| `ui-invalid` | La validación del componente ha fallado. |\n| `ui-disabled` | La configuración contiene `disabled:true`. |\n\n```html\n<ui-component id=\"name\" name=\"required\" path=\"form.name\"></ui-component>\n\n<script>\n\tCOMPONENT('required', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn !!value;\n\t\t};\n\t});\n</script>\n```\n\nUn campo vacío empieza con `ui-invalid`. Cuando el usuario escribe, tiene `ui-modified` y `ui-touched`. `RESET('form')` las vuelve a quitar.\n\n## Reaccionar a la creación y la eliminación\n\n`ON('@name', fn)` se ejecuta cuando se crea un componente con ese nombre, y `ON('#id', fn)` hace lo mismo para un identificador. `element.ui` y `$(element).component()` devuelven la instancia de un elemento. [FREE()](../../reference/globals/) hace que la biblioteca limpie de inmediato los elementos eliminados, lo que llama a su función `destroy`.\n\n```html\n<ui-component id=\"a\" name=\"temp\"></ui-component>\n\n<script>\n\tCOMPONENT('temp', function(self) {\n\t\tself.destroy = function() {\n\t\t\tconsole.log('destroyed');\n\t\t};\n\t});\n\n\tON('@temp', com => console.log('created', com.name));\n\n\tON('ready', function() {\n\t\tconsole.log(document.getElementById('a').ui.name);   // temp\n\t\tconsole.log($('#a').component().name);               // temp\n\n\t\t$('#a').remove();\n\t\tFREE();                                              // destroyed\n\t});\n</script>\n```\n\n## Componentes que no están en la página\n\nCuando una página usa un componente que no está declarado, la biblioteca lo descarga desde la dirección de `DEF.fallback`, que por defecto es `https://cdn.componentator.com/j-{0}.html`, donde `{0}` es el nombre del componente en minúsculas. Asigna una cadena vacía a `DEF.fallback` para desactivarlo.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammUA26M61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/using-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Utiliser les composants","summary":"Place des composants sur une page, configure-les, puis trouve-les et contrôle-les depuis le code.","markdown":"---\ntitle: Utiliser les composants\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/using-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Utiliser les composants\n\n> Place des composants sur une page, configure-les, puis trouve-les et contrôle-les depuis le code.\n\nUn composant est un élément d'interface réutilisable. Ce guide montre comment placer et contrôler des composants qui existent déjà. Pour écrire les tiens, lis [Créer des composants](../creating-components/).\n\n## Placer un composant\n\n```html\n<ui-component name=\"stat\" path=\"sales.today\" config=\"label:Sales today;unit:EUR\"></ui-component>\n\n<script>\n\tCOMPONENT('stat', 'label:Value;unit:', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.label + ': ' + value + ' ' + config.unit);\n\t\t};\n\t});\n\n\tSET('sales.today', 1250);\n</script>\n```\n\nL'élément affiche `Sales today: 1250 EUR`.\n\n| Attribut | Description |\n| --- | --- |\n| `name` | Le nom du composant. |\n| `path` | Le [path](../paths/) de la valeur que le composant utilise. |\n| `config` | La configuration de cette instance. |\n| `default` | Une expression JavaScript contenant la valeur par défaut. |\n\n## Écrire la configuration\n\nLa configuration est une liste de paires `key:value` séparées par des points-virgules. Les nombres et les mots `true` et `false` deviennent de vrais nombres et booléens. Écris `\\;` et `\\:` pour utiliser ces caractères dans une valeur. Les URL qui commencent par `http://`, `https://`, `ws://` ou `wss://` n'ont pas besoin d'échappement.\n\n```html\n<ui-component name=\"show\" config=\"title:Report;size:12;ratio:1.5;open:true;url:https://example.com/a;note:one\\;two;time:10\\:30\"></ui-component>\n\n<script>\n\tCOMPONENT('show', function(self, config) {\n\t\tself.make = function() {\n\t\t\tconsole.log(config.title, config.size, config.ratio, config.open, config.url, config.note, config.time);\n\t\t\tconsole.log(typeof config.size, typeof config.open);\n\t\t};\n\t});\n</script>\n```\n\nLe composant affiche `Report 12 1.5 true https://example.com/a one;two 10:30`, puis `number boolean`.\n\n## Utiliser l'attribut data\n\nL'attribut `data---` place un composant sur n'importe quel élément. Il réunit le nom, le path, la configuration et la valeur par défaut, séparés par deux tirets bas.\n\n```html\n<div id=\"a\" data---=\"tag__label.text__color:red__'Default text'\"></div>\n\n<script>\n\tCOMPONENT('tag', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ': ' + value);\n\t\t};\n\t});\n</script>\n```\n\nAppelle [COMPILE()](../../reference/globals/) après avoir inséré des éléments portant cet attribut dans une page en cours d'exécution.\n\n## Définir une valeur par défaut\n\nQuand le path n'a pas de valeur, le composant stocke le résultat de l'expression `default`. Dans l'expression, le texte doit être entre guillemets. [DEFAULT()](../../reference/globals/) rétablit les valeurs par défaut de tous les composants situés sous un path.\n\n```html\n<ui-component name=\"field\" path=\"form.city\" default=\"'Rome'\"></ui-component>\n<ui-component name=\"field\" path=\"form.size\" default=\"10\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\n\t\tSET('form', { city: 'Oslo', size: 20 });\n\t\tDEFAULT('form');\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\t});\n</script>\n```\n\n## Clés de configuration spéciales\n\n| Clé | Effet |\n| --- | --- |\n| `$id:name` | Définit l'identifiant utilisé par `FIND('#name')`. |\n| `$class:name` | Bascule une classe CSS sur l'élément. |\n| `$assign:path` | Stocke l'instance du composant dans un path. |\n| `$init:name` | Appelle la fonction globale `name(component)` quand le composant est prêt. |\n\n```html\n<ui-component id=\"el\" name=\"panel\" config=\"$id:main;$class:highlight;$assign:panels.main;$init:onpanel\"></ui-component>\n\n<script>\n\tCOMPONENT('panel', function(self) {});\n\n\tfunction onpanel(com) {\n\t\tconsole.log('init', com.id);\n\t}\n\n\tON('ready', function() {\n\t\tconsole.log(FIND('#main').name);  // panel\n\t\tconsole.log(document.getElementById('el').className);\n\t});\n</script>\n```\n\n## Relier un réglage à un path\n\nUn `=` devant une clé lit le réglage depuis un path et met à jour le composant à chaque changement de ce path.\n\n```html\n<ui-component name=\"heading\" config=\"=title:page.title;level:2\"></ui-component>\n\n<script>\n\tCOMPONENT('heading', function(self, config) {\n\t\tself.configure = function(key, value) {\n\t\t\tif (key === 'title')\n\t\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tSET('page.title', 'Draft');\n</script>\n```\n\nL'élément affiche `Draft`, puis `Published` après `SET('page.title', 'Published')`.\n\n## Trouver et contrôler les composants\n\n[FIND()](../../reference/globals/) renvoie un composant. Avec `true` comme deuxième argument, il renvoie un tableau de toutes les correspondances. [SETTER()](../../reference/globals/) appelle une méthode sur toutes les correspondances, et [RECONFIGURE()](../../reference/globals/) modifie leur configuration.\n\n```html\n<ui-component name=\"alert\" path=\"msg.a\" config=\"$id:first\"></ui-component>\n<ui-component name=\"alert\" path=\"msg.b\"></ui-component>\n\n<script>\n\tCOMPONENT('alert', function(self, config) {\n\n\t\tself.flash = function(text) {\n\t\t\tconsole.log(self.path, 'flash', text);\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'color' && !init)\n\t\t\t\tconsole.log(self.path, 'color', value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tconsole.log(FIND('alert').path);          // msg.a\n\t\tconsole.log(FIND('alert', true).length);  // 2\n\t\tconsole.log(FIND('.msg.b').path);         // msg.b\n\t\tconsole.log(FIND('#first').path);         // msg.a\n\t\tconsole.log(FIND('alert[msg.b]').path);   // msg.b\n\n\t\tSETTER('#first', 'flash', 'one');         // msg.a flash one\n\t\tSETTER('.msg.b/flash', 'two');            // msg.b flash two\n\t\tSETTER('alert/flash', 'all');             // msg.a flash all, msg.b flash all\n\n\t\tRECONFIGURE('#first', 'color:red');       // msg.a color red\n\t});\n</script>\n```\n\n| Sélecteur | Trouve les composants |\n| --- | --- |\n| `name` | Portant ce nom. |\n| `.path` | Ayant ce path. |\n| `#id` | Ayant cet identifiant. |\n| `name[path]` | Ayant ce nom et ce path. |\n\n## Envoyer une commande\n\n[CMD()](../../reference/globals/) exécute une commande nommée dans chaque composant qui l'a enregistrée : l'appelant n'a donc besoin d'aucun sélecteur.\n\n```html\n<ui-component name=\"box\" path=\"a\"></ui-component>\n<ui-component name=\"box\" path=\"b\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.command('refresh', function(reason) {\n\t\t\tconsole.log(self.path, 'refresh:', reason);\n\t\t});\n\t});\n\n\tON('ready', function() {\n\t\tCMD('refresh', 'manual');\n\t\t// a refresh: manual\n\t\t// b refresh: manual\n\t});\n</script>\n```\n\n## Ajouter des composants à l'exécution\n\nUn élément `<ui-component>` ajouté à la page démarre tout seul. [ADD()](../../reference/globals/) en crée un à partir d'une chaîne contenant le nom, le path et la configuration.\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tCOMPONENT('tag', 'color:gray', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ' ' + value);\n\t\t};\n\t});\n\n\tSET('label', 'new');\n\n\tsetTimeout(function() {\n\n\t\tADD('tag__label__color:green', '#host');\n\t\t$('#host').append('<ui-component name=\"tag\" path=\"label\" config=\"color:blue\"></ui-component>');\n\n\t}, 300);\n</script>\n```\n\nL'élément hôte contient au final `green new` et `blue new`.\n\n## Charger un composant à la demande\n\nUn nom précédé du préfixe `LAZY` laisse le composant non initialisé jusqu'au premier appel de `SETTER()` qui le concerne.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\n\tCOMPONENT('dialog', function(self) {\n\n\t\tself.make = function() {\n\t\t\tconsole.log('dialog created');\n\t\t};\n\n\t\tself.open = function(title) {\n\t\t\tconsole.log('open', title);\n\t\t};\n\t});\n\n\tsetTimeout(function() {\n\t\tconsole.log(FIND('dialog') == null);   // true\n\t\tSETTER('dialog/open', 'Help');         // dialog created, open Help\n\t}, 500);\n</script>\n```\n\n## Utiliser plusieurs versions\n\nUn nom de composant peut porter une version après `@`. L'élément reçoit la classe `jc-v` suivie de la version.\n\n```html\n<ui-component id=\"old\" name=\"widget@1\"></ui-component>\n<ui-component id=\"new\" name=\"widget@2\"></ui-component>\n\n<script>\n\tCOMPONENT('widget@1', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n\n\tCOMPONENT('widget@2', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n</script>\n```\n\n## Styliser l'état d'un composant\n\nLa bibliothèque maintient ces classes sur l'élément du composant, ce qui te permet de styliser chaque état en CSS :\n\n| Classe | Présente quand |\n| --- | --- |\n| `ui-touched` | L'utilisateur a interagi avec le composant. |\n| `ui-modified` | La valeur a été modifiée via le composant. |\n| `ui-invalid` | La validation du composant a échoué. |\n| `ui-disabled` | La configuration contient `disabled:true`. |\n\n```html\n<ui-component id=\"name\" name=\"required\" path=\"form.name\"></ui-component>\n\n<script>\n\tCOMPONENT('required', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn !!value;\n\t\t};\n\t});\n</script>\n```\n\nUn champ vide démarre avec `ui-invalid`. Une fois que l'utilisateur a saisi du texte, il a `ui-modified` et `ui-touched`. `RESET('form')` les efface de nouveau.\n\n## Réagir à la création et à la suppression\n\n`ON('@name', fn)` s'exécute quand un composant portant ce nom est créé, et `ON('#id', fn)` fait de même pour un identifiant. `element.ui` et `$(element).component()` renvoient l'instance d'un élément. [FREE()](../../reference/globals/) demande à la bibliothèque de nettoyer immédiatement les éléments supprimés, ce qui appelle leur fonction `destroy`.\n\n```html\n<ui-component id=\"a\" name=\"temp\"></ui-component>\n\n<script>\n\tCOMPONENT('temp', function(self) {\n\t\tself.destroy = function() {\n\t\t\tconsole.log('destroyed');\n\t\t};\n\t});\n\n\tON('@temp', com => console.log('created', com.name));\n\n\tON('ready', function() {\n\t\tconsole.log(document.getElementById('a').ui.name);   // temp\n\t\tconsole.log($('#a').component().name);               // temp\n\n\t\t$('#a').remove();\n\t\tFREE();                                              // destroyed\n\t});\n</script>\n```\n\n## Composants absents de la page\n\nQuand une page utilise un composant qui n'est pas déclaré, la bibliothèque le télécharge depuis l'adresse indiquée dans `DEF.fallback`, par défaut `https://cdn.componentator.com/j-{0}.html`, où `{0}` est le nom du composant en minuscules. Donne à `DEF.fallback` la valeur d'une chaîne vide pour désactiver ce comportement.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammUA26M61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/using-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Usare i componenti","summary":"Inserisci i componenti in una pagina, configurali, trovali e controllali dal codice.","markdown":"---\ntitle: Usare i componenti\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/using-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Usare i componenti\n\n> Inserisci i componenti in una pagina, configurali, trovali e controllali dal codice.\n\nUn componente è un elemento riutilizzabile dell'interfaccia. Questa guida mostra come inserire e controllare componenti già esistenti. Per scriverne di tuoi, leggi [Creare componenti](../creating-components/).\n\n## Inserire un componente\n\n```html\n<ui-component name=\"stat\" path=\"sales.today\" config=\"label:Sales today;unit:EUR\"></ui-component>\n\n<script>\n\tCOMPONENT('stat', 'label:Value;unit:', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.label + ': ' + value + ' ' + config.unit);\n\t\t};\n\t});\n\n\tSET('sales.today', 1250);\n</script>\n```\n\nL'elemento visualizza `Sales today: 1250 EUR`.\n\n| Attributo | Descrizione |\n| --- | --- |\n| `name` | Il nome del componente. |\n| `path` | Il [path](../paths/) del valore con cui lavora il componente. |\n| `config` | La configurazione di questa istanza. |\n| `default` | Un'espressione JavaScript con il valore predefinito. |\n\n## Scrivere la configurazione\n\nLa configurazione è un elenco di coppie `key:value` separate da punti e virgola. I numeri e le parole `true` e `false` diventano veri numeri e booleani. Scrivi `\\;` e `\\:` per usare questi caratteri in un valore. Gli URL che iniziano con `http://`, `https://`, `ws://` o `wss://` non richiedono l'escape.\n\n```html\n<ui-component name=\"show\" config=\"title:Report;size:12;ratio:1.5;open:true;url:https://example.com/a;note:one\\;two;time:10\\:30\"></ui-component>\n\n<script>\n\tCOMPONENT('show', function(self, config) {\n\t\tself.make = function() {\n\t\t\tconsole.log(config.title, config.size, config.ratio, config.open, config.url, config.note, config.time);\n\t\t\tconsole.log(typeof config.size, typeof config.open);\n\t\t};\n\t});\n</script>\n```\n\nIl componente stampa `Report 12 1.5 true https://example.com/a one;two 10:30` e poi `number boolean`.\n\n## Usare l'attributo data\n\nL'attributo `data---` inserisce un componente in qualsiasi elemento. Unisce nome, path, configurazione e valore predefinito con due trattini bassi.\n\n```html\n<div id=\"a\" data---=\"tag__label.text__color:red__'Default text'\"></div>\n\n<script>\n\tCOMPONENT('tag', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ': ' + value);\n\t\t};\n\t});\n</script>\n```\n\nChiama [COMPILE()](../../reference/globals/) dopo aver inserito elementi con questo attributo in una pagina già in esecuzione.\n\n## Impostare un valore predefinito\n\nQuando il path non ha un valore, il componente memorizza il risultato dell'espressione `default`. Il testo richiede le virgolette all'interno dell'espressione. [DEFAULT()](../../reference/globals/) ripristina i valori predefiniti di tutti i componenti sotto un path.\n\n```html\n<ui-component name=\"field\" path=\"form.city\" default=\"'Rome'\"></ui-component>\n<ui-component name=\"field\" path=\"form.size\" default=\"10\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\n\t\tSET('form', { city: 'Oslo', size: 20 });\n\t\tDEFAULT('form');\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\t});\n</script>\n```\n\n## Chiavi di configurazione speciali\n\n| Chiave | Effetto |\n| --- | --- |\n| `$id:name` | Imposta l'identificatore usato da `FIND('#name')`. |\n| `$class:name` | Attiva o disattiva una classe CSS sull'elemento. |\n| `$assign:path` | Memorizza l'istanza del componente in un path. |\n| `$init:name` | Chiama la funzione globale `name(component)` quando il componente è pronto. |\n\n```html\n<ui-component id=\"el\" name=\"panel\" config=\"$id:main;$class:highlight;$assign:panels.main;$init:onpanel\"></ui-component>\n\n<script>\n\tCOMPONENT('panel', function(self) {});\n\n\tfunction onpanel(com) {\n\t\tconsole.log('init', com.id);\n\t}\n\n\tON('ready', function() {\n\t\tconsole.log(FIND('#main').name);  // panel\n\t\tconsole.log(document.getElementById('el').className);\n\t});\n</script>\n```\n\n## Collegare un'impostazione a un path\n\nUn `=` davanti a una chiave legge l'impostazione da un path e aggiorna il componente ogni volta che quel path cambia.\n\n```html\n<ui-component name=\"heading\" config=\"=title:page.title;level:2\"></ui-component>\n\n<script>\n\tCOMPONENT('heading', function(self, config) {\n\t\tself.configure = function(key, value) {\n\t\t\tif (key === 'title')\n\t\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tSET('page.title', 'Draft');\n</script>\n```\n\nL'elemento mostra `Draft` e, dopo `SET('page.title', 'Published')`, mostra `Published`.\n\n## Trovare e controllare i componenti\n\n[FIND()](../../reference/globals/) restituisce un componente. Con `true` come secondo argomento restituisce un array con tutte le corrispondenze. [SETTER()](../../reference/globals/) chiama un metodo su tutte le corrispondenze e [RECONFIGURE()](../../reference/globals/) ne modifica la configurazione.\n\n```html\n<ui-component name=\"alert\" path=\"msg.a\" config=\"$id:first\"></ui-component>\n<ui-component name=\"alert\" path=\"msg.b\"></ui-component>\n\n<script>\n\tCOMPONENT('alert', function(self, config) {\n\n\t\tself.flash = function(text) {\n\t\t\tconsole.log(self.path, 'flash', text);\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'color' && !init)\n\t\t\t\tconsole.log(self.path, 'color', value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tconsole.log(FIND('alert').path);          // msg.a\n\t\tconsole.log(FIND('alert', true).length);  // 2\n\t\tconsole.log(FIND('.msg.b').path);         // msg.b\n\t\tconsole.log(FIND('#first').path);         // msg.a\n\t\tconsole.log(FIND('alert[msg.b]').path);   // msg.b\n\n\t\tSETTER('#first', 'flash', 'one');         // msg.a flash one\n\t\tSETTER('.msg.b/flash', 'two');            // msg.b flash two\n\t\tSETTER('alert/flash', 'all');             // msg.a flash all, msg.b flash all\n\n\t\tRECONFIGURE('#first', 'color:red');       // msg.a color red\n\t});\n</script>\n```\n\n| Selettore | Trova i componenti |\n| --- | --- |\n| `name` | Con questo nome. |\n| `.path` | Con questo path. |\n| `#id` | Con questo identificatore. |\n| `name[path]` | Con questo nome e questo path. |\n\n## Inviare un comando\n\n[CMD()](../../reference/globals/) esegue un comando con nome in ogni componente che lo ha registrato, quindi chi chiama non ha bisogno di un selettore.\n\n```html\n<ui-component name=\"box\" path=\"a\"></ui-component>\n<ui-component name=\"box\" path=\"b\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.command('refresh', function(reason) {\n\t\t\tconsole.log(self.path, 'refresh:', reason);\n\t\t});\n\t});\n\n\tON('ready', function() {\n\t\tCMD('refresh', 'manual');\n\t\t// a refresh: manual\n\t\t// b refresh: manual\n\t});\n</script>\n```\n\n## Aggiungere componenti in fase di esecuzione\n\nUn elemento `<ui-component>` aggiunto alla pagina si avvia da solo. [ADD()](../../reference/globals/) ne crea uno a partire da una stringa con nome, path e configurazione.\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tCOMPONENT('tag', 'color:gray', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ' ' + value);\n\t\t};\n\t});\n\n\tSET('label', 'new');\n\n\tsetTimeout(function() {\n\n\t\tADD('tag__label__color:green', '#host');\n\t\t$('#host').append('<ui-component name=\"tag\" path=\"label\" config=\"color:blue\"></ui-component>');\n\n\t}, 300);\n</script>\n```\n\nL'elemento host finisce per contenere `green new` e `blue new`.\n\n## Caricare un componente su richiesta\n\nUn nome con il prefisso `LAZY` lascia il componente non inizializzato fino alla prima chiamata `SETTER()` che lo riguarda.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\n\tCOMPONENT('dialog', function(self) {\n\n\t\tself.make = function() {\n\t\t\tconsole.log('dialog created');\n\t\t};\n\n\t\tself.open = function(title) {\n\t\t\tconsole.log('open', title);\n\t\t};\n\t});\n\n\tsetTimeout(function() {\n\t\tconsole.log(FIND('dialog') == null);   // true\n\t\tSETTER('dialog/open', 'Help');         // dialog created, open Help\n\t}, 500);\n</script>\n```\n\n## Usare più versioni\n\nIl nome di un componente può riportare una versione dopo `@`. L'elemento riceve la classe `jc-v` seguita dalla versione.\n\n```html\n<ui-component id=\"old\" name=\"widget@1\"></ui-component>\n<ui-component id=\"new\" name=\"widget@2\"></ui-component>\n\n<script>\n\tCOMPONENT('widget@1', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n\n\tCOMPONENT('widget@2', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n</script>\n```\n\n## Applicare stili allo stato di un componente\n\nLa libreria mantiene queste classi sull'elemento del componente, così puoi definire con il CSS lo stile di ogni stato:\n\n| Classe | Presente quando |\n| --- | --- |\n| `ui-touched` | L'utente ha interagito con il componente. |\n| `ui-modified` | Il valore è stato modificato tramite il componente. |\n| `ui-invalid` | La validazione del componente non è riuscita. |\n| `ui-disabled` | La configurazione contiene `disabled:true`. |\n\n```html\n<ui-component id=\"name\" name=\"required\" path=\"form.name\"></ui-component>\n\n<script>\n\tCOMPONENT('required', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn !!value;\n\t\t};\n\t});\n</script>\n```\n\nUn campo vuoto parte con `ui-invalid`. Dopo che l'utente ha digitato, ha `ui-modified` e `ui-touched`. `RESET('form')` le rimuove di nuovo.\n\n## Reagire alla creazione e alla rimozione\n\n`ON('@name', fn)` viene eseguito quando viene creato un componente con quel nome, e `ON('#id', fn)` fa lo stesso per un identificatore. `element.ui` e `$(element).component()` restituiscono l'istanza di un elemento. [FREE()](../../reference/globals/) fa sì che la libreria ripulisca subito gli elementi rimossi, chiamando la loro funzione `destroy`.\n\n```html\n<ui-component id=\"a\" name=\"temp\"></ui-component>\n\n<script>\n\tCOMPONENT('temp', function(self) {\n\t\tself.destroy = function() {\n\t\t\tconsole.log('destroyed');\n\t\t};\n\t});\n\n\tON('@temp', com => console.log('created', com.name));\n\n\tON('ready', function() {\n\t\tconsole.log(document.getElementById('a').ui.name);   // temp\n\t\tconsole.log($('#a').component().name);               // temp\n\n\t\t$('#a').remove();\n\t\tFREE();                                              // destroyed\n\t});\n</script>\n```\n\n## Componenti che non sono nella pagina\n\nQuando una pagina usa un componente non dichiarato, la libreria lo scarica dall'indirizzo in `DEF.fallback`, che per impostazione predefinita è `https://cdn.componentator.com/j-{0}.html`, dove `{0}` è il nome del componente in minuscolo. Imposta `DEF.fallback` su una stringa vuota per disattivare questo comportamento.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammUA26M61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/using-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Používanie komponentov","summary":"Umiestni komponenty na stránku, nastav ich a vyhľadávaj a ovládaj ich z kódu.","markdown":"---\ntitle: \"Používanie komponentov\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/using-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Používanie komponentov\n\n> Umiestni komponenty na stránku, nastav ich a vyhľadávaj a ovládaj ich z kódu.\n\nKomponent je opakovane použiteľná časť používateľského rozhrania. Tento návod ukazuje, ako umiestniť a ovládať komponenty, ktoré už existujú. Ak chceš napísať vlastné, prečítaj si [Vytváranie komponentov](../creating-components/).\n\n## Umiestni komponent\n\n```html\n<ui-component name=\"stat\" path=\"sales.today\" config=\"label:Sales today;unit:EUR\"></ui-component>\n\n<script>\n\tCOMPONENT('stat', 'label:Value;unit:', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.label + ': ' + value + ' ' + config.unit);\n\t\t};\n\t});\n\n\tSET('sales.today', 1250);\n</script>\n```\n\nElement vykreslí `Sales today: 1250 EUR`.\n\n| Atribút | Popis |\n| --- | --- |\n| `name` | Názov komponentu. |\n| `path` | [Path](../paths/) hodnoty, s ktorou komponent pracuje. |\n| `config` | Konfigurácia tejto inštancie. |\n| `default` | Výraz JavaScriptu s predvolenou hodnotou. |\n\n## Zapíš konfiguráciu\n\nKonfigurácia je zoznam dvojíc `key:value` oddelených bodkočiarkami. Čísla a slová `true` a `false` sa zmenia na skutočné čísla a logické hodnoty. Ak chceš tieto znaky použiť v hodnote, napíš `\\;` a `\\:`. URL adresy, ktoré začínajú na `http://`, `https://`, `ws://` alebo `wss://`, escapovať netreba.\n\n```html\n<ui-component name=\"show\" config=\"title:Report;size:12;ratio:1.5;open:true;url:https://example.com/a;note:one\\;two;time:10\\:30\"></ui-component>\n\n<script>\n\tCOMPONENT('show', function(self, config) {\n\t\tself.make = function() {\n\t\t\tconsole.log(config.title, config.size, config.ratio, config.open, config.url, config.note, config.time);\n\t\t\tconsole.log(typeof config.size, typeof config.open);\n\t\t};\n\t});\n</script>\n```\n\nKomponent vypíše `Report 12 1.5 true https://example.com/a one;two 10:30` a potom `number boolean`.\n\n## Použi dátový atribút\n\nAtribút `data---` umiestni komponent na ľubovoľný element. Názov, path, konfiguráciu a predvolenú hodnotu spája dvoma podčiarkovníkmi.\n\n```html\n<div id=\"a\" data---=\"tag__label.text__color:red__'Default text'\"></div>\n\n<script>\n\tCOMPONENT('tag', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ': ' + value);\n\t\t};\n\t});\n</script>\n```\n\nPo vložení elementov s týmto atribútom do bežiacej stránky zavolaj [COMPILE()](../../reference/globals/).\n\n## Nastav predvolenú hodnotu\n\nKeď path nemá hodnotu, komponent uloží výsledok výrazu `default`. Text musí byť vo výraze v úvodzovkách. [DEFAULT()](../../reference/globals/) obnoví predvolené hodnoty všetkých komponentov pod daným path.\n\n```html\n<ui-component name=\"field\" path=\"form.city\" default=\"'Rome'\"></ui-component>\n<ui-component name=\"field\" path=\"form.size\" default=\"10\"></ui-component>\n\n<script>\n\tCOMPONENT('field', function(self) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\n\t\tSET('form', { city: 'Oslo', size: 20 });\n\t\tDEFAULT('form');\n\t\tconsole.log(form.city, form.size);  // Rome 10\n\t});\n</script>\n```\n\n## Špeciálne konfiguračné kľúče\n\n| Kľúč | Účinok |\n| --- | --- |\n| `$id:name` | Nastaví identifikátor, ktorý používa `FIND('#name')`. |\n| `$class:name` | Prepne CSS triedu na elemente. |\n| `$assign:path` | Uloží inštanciu komponentu do path. |\n| `$init:name` | Keď je komponent pripravený, zavolá globálnu funkciu `name(component)`. |\n\n```html\n<ui-component id=\"el\" name=\"panel\" config=\"$id:main;$class:highlight;$assign:panels.main;$init:onpanel\"></ui-component>\n\n<script>\n\tCOMPONENT('panel', function(self) {});\n\n\tfunction onpanel(com) {\n\t\tconsole.log('init', com.id);\n\t}\n\n\tON('ready', function() {\n\t\tconsole.log(FIND('#main').name);  // panel\n\t\tconsole.log(document.getElementById('el').className);\n\t});\n</script>\n```\n\n## Prepoj nastavenie s path\n\nZnak `=` pred kľúčom načíta nastavenie z path a aktualizuje komponent pri každej zmene tohto path.\n\n```html\n<ui-component name=\"heading\" config=\"=title:page.title;level:2\"></ui-component>\n\n<script>\n\tCOMPONENT('heading', function(self, config) {\n\t\tself.configure = function(key, value) {\n\t\t\tif (key === 'title')\n\t\t\t\tself.text(value);\n\t\t};\n\t});\n\n\tSET('page.title', 'Draft');\n</script>\n```\n\nElement zobrazí `Draft` a po `SET('page.title', 'Published')` zobrazí `Published`.\n\n## Vyhľadávaj a ovládaj komponenty\n\n[FIND()](../../reference/globals/) vráti komponent. S hodnotou `true` v druhom argumente vráti pole všetkých zhôd. [SETTER()](../../reference/globals/) zavolá metódu na všetkých zhodách a [RECONFIGURE()](../../reference/globals/) zmení ich konfiguráciu.\n\n```html\n<ui-component name=\"alert\" path=\"msg.a\" config=\"$id:first\"></ui-component>\n<ui-component name=\"alert\" path=\"msg.b\"></ui-component>\n\n<script>\n\tCOMPONENT('alert', function(self, config) {\n\n\t\tself.flash = function(text) {\n\t\t\tconsole.log(self.path, 'flash', text);\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'color' && !init)\n\t\t\t\tconsole.log(self.path, 'color', value);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\n\t\tconsole.log(FIND('alert').path);          // msg.a\n\t\tconsole.log(FIND('alert', true).length);  // 2\n\t\tconsole.log(FIND('.msg.b').path);         // msg.b\n\t\tconsole.log(FIND('#first').path);         // msg.a\n\t\tconsole.log(FIND('alert[msg.b]').path);   // msg.b\n\n\t\tSETTER('#first', 'flash', 'one');         // msg.a flash one\n\t\tSETTER('.msg.b/flash', 'two');            // msg.b flash two\n\t\tSETTER('alert/flash', 'all');             // msg.a flash all, msg.b flash all\n\n\t\tRECONFIGURE('#first', 'color:red');       // msg.a color red\n\t});\n</script>\n```\n\n| Selektor | Nájde komponenty |\n| --- | --- |\n| `name` | S týmto názvom. |\n| `.path` | S týmto path. |\n| `#id` | S týmto identifikátorom. |\n| `name[path]` | S týmto názvom a path. |\n\n## Pošli príkaz\n\n[CMD()](../../reference/globals/) spustí pomenovaný príkaz v každom komponente, ktorý si ho zaregistroval, takže volajúci nepotrebuje selektor.\n\n```html\n<ui-component name=\"box\" path=\"a\"></ui-component>\n<ui-component name=\"box\" path=\"b\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.command('refresh', function(reason) {\n\t\t\tconsole.log(self.path, 'refresh:', reason);\n\t\t});\n\t});\n\n\tON('ready', function() {\n\t\tCMD('refresh', 'manual');\n\t\t// a refresh: manual\n\t\t// b refresh: manual\n\t});\n</script>\n```\n\n## Pridávaj komponenty za behu\n\nElement `<ui-component>` pridaný na stránku sa spustí sám. [ADD()](../../reference/globals/) ho vytvorí z reťazca s názvom, path a konfiguráciou.\n\n```html\n<div id=\"host\"></div>\n\n<script>\n\tCOMPONENT('tag', 'color:gray', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tself.text(config.color + ' ' + value);\n\t\t};\n\t});\n\n\tSET('label', 'new');\n\n\tsetTimeout(function() {\n\n\t\tADD('tag__label__color:green', '#host');\n\t\t$('#host').append('<ui-component name=\"tag\" path=\"label\" config=\"color:blue\"></ui-component>');\n\n\t}, 300);\n</script>\n```\n\nHostiteľský element nakoniec obsahuje `green new` a `blue new`.\n\n## Načítaj komponent na požiadanie\n\nNázov s predponou `LAZY` nechá komponent neinicializovaný až do prvého volania `SETTER()` pre tento komponent.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\n\tCOMPONENT('dialog', function(self) {\n\n\t\tself.make = function() {\n\t\t\tconsole.log('dialog created');\n\t\t};\n\n\t\tself.open = function(title) {\n\t\t\tconsole.log('open', title);\n\t\t};\n\t});\n\n\tsetTimeout(function() {\n\t\tconsole.log(FIND('dialog') == null);   // true\n\t\tSETTER('dialog/open', 'Help');         // dialog created, open Help\n\t}, 500);\n</script>\n```\n\n## Použi viac verzií\n\nNázov komponentu môže za znakom `@` obsahovať verziu. Element dostane triedu `jc-v`, za ktorou nasleduje verzia.\n\n```html\n<ui-component id=\"old\" name=\"widget@1\"></ui-component>\n<ui-component id=\"new\" name=\"widget@2\"></ui-component>\n\n<script>\n\tCOMPONENT('widget@1', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n\n\tCOMPONENT('widget@2', function(self) {\n\t\tself.make = () => self.text('Version ' + self.version);\n\t});\n</script>\n```\n\n## Štýluj stav komponentu\n\nKnižnica udržiava na elemente komponentu tieto triedy, takže každý stav môžeš naštýlovať v CSS:\n\n| Trieda | Je prítomná, keď |\n| --- | --- |\n| `ui-touched` | Používateľ s komponentom pracoval. |\n| `ui-modified` | Hodnota sa zmenila prostredníctvom komponentu. |\n| `ui-invalid` | Validácia komponentu zlyhala. |\n| `ui-disabled` | Konfigurácia obsahuje `disabled:true`. |\n\n```html\n<ui-component id=\"name\" name=\"required\" path=\"form.name\"></ui-component>\n\n<script>\n\tCOMPONENT('required', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn !!value;\n\t\t};\n\t});\n</script>\n```\n\nPrázdne pole začína s `ui-invalid`. Keď používateľ začne písať, má `ui-modified` a `ui-touched`. `RESET('form')` ich opäť vymaže.\n\n## Reaguj na vytvorenie a odstránenie\n\n`ON('@name', fn)` sa spustí pri vytvorení komponentu s týmto názvom a `ON('#id', fn)` robí to isté pre identifikátor. `element.ui` a `$(element).component()` vrátia inštanciu elementu. [FREE()](../../reference/globals/) prinúti knižnicu okamžite upratať odstránené elementy, čím sa zavolá ich funkcia `destroy`.\n\n```html\n<ui-component id=\"a\" name=\"temp\"></ui-component>\n\n<script>\n\tCOMPONENT('temp', function(self) {\n\t\tself.destroy = function() {\n\t\t\tconsole.log('destroyed');\n\t\t};\n\t});\n\n\tON('@temp', com => console.log('created', com.name));\n\n\tON('ready', function() {\n\t\tconsole.log(document.getElementById('a').ui.name);   // temp\n\t\tconsole.log($('#a').component().name);               // temp\n\n\t\t$('#a').remove();\n\t\tFREE();                                              // destroyed\n\t});\n</script>\n```\n\n## Komponenty, ktoré na stránke nie sú\n\nKeď stránka používa komponent, ktorý nie je deklarovaný, knižnica ho stiahne z adresy v `DEF.fallback`, predvolene `https://cdn.componentator.com/j-{0}.html`, kde `{0}` je názov komponentu malými písmenami. Ak to chceš vypnúť, nastav `DEF.fallback` na prázdny reťazec.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTR1eM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/creating-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Creating components","summary":"Declare your own components, handle their lifecycle, and exchange data with the model.","markdown":"---\ntitle: Creating components\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/creating-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Creating components\n\n> Declare your own components, handle their lifecycle, and exchange data with the model.\n\nYou declare a component once with [COMPONENT()](../../reference/globals/) and then place it on as many pages as you need. This guide builds up the API step by step. To place existing components, read [Using components](../using-components/).\n\n## Declare a component\n\n```html\n<ui-component name=\"hello\" path=\"visitor\"></ui-component>\n\n<script>\n\tCOMPONENT('hello', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text('Hello ' + (value || 'stranger'));\n\t\t};\n\t});\n\n\tSET('visitor', 'Ana');\n</script>\n```\n\nThe element renders as `<ui-component name=\"hello\" path=\"visitor\" class=\"ui-hello\">Hello Ana</ui-component>`.\n\n`COMPONENT(name, [config], declaration, [dependencies])` takes these arguments:\n\n| Argument | Description |\n| --- | --- |\n| `name` | The name of the component. |\n| `config` | The default configuration, as a string such as `'size:1;color:red'` or as an object. |\n| `declaration` | A function that runs for each instance. |\n| `dependencies` | An array of what must load first. |\n\nThe declaration receives three arguments:\n\n| Argument | Description |\n| --- | --- |\n| `self` | The instance of the component. |\n| `config` | The configuration of this instance. |\n| `cls` | A CSS class name made of `ui-` and the name of the component. |\n\n## The lifecycle\n\nYou define the functions below on `self`, and the library calls them in this order. All of them are optional.\n\n```html\n<ui-component name=\"life\" path=\"demo.value\" config=\"size:3\"></ui-component>\n\n<script>\n\tCOMPONENT('life', 'size:1', function(self, config, cls) {\n\n\t\tconsole.log('1 declaration', cls, config.size);\n\n\t\tself.init = () => console.log('2 init');\n\t\tself.make = () => console.log('3 make');\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'size')\n\t\t\t\tconsole.log('4 configure', key, value, init);\n\t\t};\n\n\t\tself.setter = (value, path, type) => console.log('5 setter', value, path, type);\n\n\t\tself.validate = function(value) {\n\t\t\tconsole.log('6 validate', value);\n\t\t\treturn true;\n\t\t};\n\n\t\tself.state = (type, what) => console.log('7 state', type, what);\n\t\tself.done = () => console.log('8 done');\n\t\tself.destroy = () => console.log('9 destroy');\n\t});\n\n\tSET('demo.value', 'A');\n\n\tsetTimeout(() => FIND('life').remove(), 600);\n</script>\n```\n\n| Function | When it runs |\n| --- | --- |\n| `init()` | One time for each component name, with the first instance. |\n| `make()` | When the instance is created. Build the content here. |\n| `configure(key, value, init, prev)` | For each configuration key, and again whenever a key changes. |\n| `setter(value, path, type)` | With the initial value, and whenever the value changes. |\n| `validate(value)` | After the setter. Returns `true` for a valid value. |\n| `state(type, what)` | When the state of the component changes. |\n| `done()` | Shortly after the component is ready. |\n| `destroy()` | When the component is removed. |\n\nDuring initialization, `configure` also runs for the state keys `modified`, `touched` and `invalid`, with `init` set to `true`.\n\n## Receive data\n\n`self.setter` receives the value, the path that changed and the type of the change.\n\n```html\n<ui-component name=\"spy\" path=\"demo.value\" default=\"'initial'\"></ui-component>\n\n<script>\n\tCOMPONENT('spy', function(self) {\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log(value, type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('demo.value', 'manual');        // manual 1\n\t\tFIND('spy').set('input', 2);        // input 2\n\t\tDEFAULT('demo.value');              // initial 3\n\t});\n\t// initial 0\n</script>\n```\n\n| Type | Meaning |\n| --- | --- |\n| `0` | The initial value. |\n| `1` | Changed by code. |\n| `2` | Changed by user input. |\n| `3` | Set to the default value. |\n\n## Read the configuration\n\nThe `config` object always holds the current values. Use `self.configure` to react to changes, and check the `init` argument to tell the first run from later ones. `self.refresh()` runs the setter again with the current value.\n\n```html\n<ui-component name=\"meter\" path=\"level\" config=\"max:10;color:green\"></ui-component>\n\n<script>\n\tCOMPONENT('meter', 'max:100;color:gray', function(self, config) {\n\n\t\tself.configure = function(key, value, init, prev) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'color':\n\t\t\t\t\tself.css('color', value);\n\t\t\t\t\t!init && console.log('color', prev, '->', value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'max':\n\t\t\t\t\t!init && self.refresh();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' / ' + config.max);\n\t\t};\n\t});\n\n\tSET('level', 7);\n\n\tON('ready', function() {\n\t\tFIND('meter').reconfigure('color:red;max:20');\n\t\t// color green -> red\n\t});\n</script>\n```\n\nThe element renders `7 / 20` in red after the call to `reconfigure()`.\n\n## Write data\n\n| Method | Description |\n| --- | --- |\n| `self.get()` | Reads the value at the path of the component. |\n| `self.set(value, [type])` | Writes the value and marks the component as modified. The setter runs too. |\n| `self.modify(value, [type])` | Runs the parsers, marks the component as touched and writes the value with type `2`. |\n| `self.getter(value)` | Runs the parsers, marks the component as touched and writes the value if it changed. |\n| `self.bind(flags, value)` | Writes the value without running the setter, and applies the flags. |\n| `self.skip()` | Skips the next run of the setter. |\n\nThe flags of `self.bind()` are `@touched`, `@modified`, `@reset`, `@validate` and `@setter`. The last one makes the setter run after all.\n\n```html\n<ui-component name=\"stepper\" path=\"qty\"></ui-component>\n\n<script>\n\tCOMPONENT('stepper', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button>-</button> <b></b> <button>+</button>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar diff = this.textContent === '+' ? 1 : -1;\n\t\t\t\tself.bind('@touched @modified', (self.get() || 0) + diff);\n\t\t\t\tself.find('b').text(self.get());\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tconsole.log('setter', value);\n\t\t\tself.find('b').text(value);\n\t\t};\n\t});\n\n\tSET('qty', 1);    // setter 1\n</script>\n```\n\nClicking `+` twice leaves `qty` at `3`, and the setter does not run for these clicks. A later `SET('qty', 9)` runs it as usual.\n\n## Connect a text input\n\nAn `<input>`, `<textarea>` or `<select>` with the `data-jc-bind` attribute works without further code: the library copies the value in both directions, and checkboxes write `true` or `false`. A `formatter` changes how the value is displayed. The setting `type:number` makes the library store a number instead of a string.\n\n```html\n<ui-component name=\"price\" path=\"item.price\" config=\"type:number\"></ui-component>\n\n<script>\n\tCOMPONENT('price', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn value == null ? '' : value.format(2);\n\t\t});\n\t});\n\n\tSET('item.price', 5);\n</script>\n```\n\nThe input shows `5.00`. Typing `12.5` stores the number `12.5`.\n\nThese configuration keys control when an input writes its value:\n\n| Key | Effect |\n| --- | --- |\n| `$delay:500` | Waits this many milliseconds after the last key press. The default is `200`. |\n| `$realtime:false` | Writes the value when the input loses focus. |\n\n```html\n<ui-component id=\"slow\" name=\"box\" path=\"form.slow\" config=\"$delay:500\"></ui-component>\n<ui-component id=\"blur\" name=\"box\" path=\"form.blur\" config=\"$realtime:false\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n## Build a custom input\n\nFor your own controls, call `self.getter()` with the new value. A `parser` converts what the user entered into the stored value, and a `formatter` does the opposite. Both receive the path, the value, the type and the format.\n\n```html\n<ui-component name=\"tags\" path=\"post.tags\"></ui-component>\n\n<script>\n\tCOMPONENT('tags', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" />');\n\t\t\tself.event('change', 'input', function() {\n\t\t\t\tself.getter(this.value);\n\t\t\t});\n\t\t};\n\n\t\tself.parser(function(path, value) {\n\t\t\treturn value.split(',').map(tag => tag.trim());\n\t\t});\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn (value || []).join(', ');\n\t\t});\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('input').val(self.formatter(value));\n\t\t};\n\t});\n\n\tSET('post.tags', ['a', 'b']);\n</script>\n```\n\nThe input shows `a, b`. Entering `x, y ,z` stores `[\"x\",\"y\",\"z\"]`.\n\n## Validate the value\n\n`self.validate` returns `true` for a valid value. `self.isInvalid()` returns `true` when the value is invalid and the user already touched the component, which is the right moment to show an error.\n\n```html\n<ui-component id=\"mail\" name=\"email\" path=\"user.email\"></ui-component>\n\n<script>\n\tCOMPONENT('email', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" /><small>Enter a valid address</small>');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn (value || '').isEmail();\n\t\t};\n\n\t\tself.state = function() {\n\t\t\tself.find('small').tclass('hidden', !self.isInvalid());\n\t\t};\n\t});\n</script>\n```\n\nThe message stays hidden on the empty form, appears after `nope` and disappears again after `a@b.io`. [Forms and validation](../forms/) covers whole forms.\n\n## Keep internal data\n\n`self.data(key, value)` stores a value inside the component. A binding inside the component reads it with a path that starts with `@`. `@` alone is the value of the component, and `@config.name` is a configuration key.\n\n```html\n<ui-component name=\"card\" path=\"person.name\" config=\"title:Profile\"></ui-component>\n\n<script>\n\tCOMPONENT('card', 'title:Untitled', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<h3><ui-bind path=\"@config.title\" config=\"text\"></ui-bind></h3>'\n\t\t\t\t+ '<p><ui-bind path=\"@\" config=\"text\"></ui-bind></p>'\n\t\t\t\t+ '<small><ui-bind path=\"@visits\" config=\"text\"></ui-bind></small>');\n\t\t\tself.data('visits', 1);\n\t\t};\n\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('person.name', 'Ana');\n</script>\n```\n\n## Declare dependencies\n\nThe fourth argument of `COMPONENT()` lists what must be available when the component starts. `make` waits for all of them.\n\n| Item | Description |\n| --- | --- |\n| A function | Receives a `next` function to call when it finishes. |\n| A URL | A script or stylesheet that is imported one time. |\n| `@name` | Another component, downloaded if it is missing. |\n\n```html\n<ui-component name=\"chart\" path=\"stats\"></ui-component>\n\n<script>\n\tCOMPONENT('chart', function(self) {\n\t\tself.make = function() {\n\t\t\tconsole.log('make', window.chartlib);\n\t\t};\n\t}, [function(next) {\n\t\tsetTimeout(function() {\n\t\t\twindow.chartlib = 'loaded';\n\t\t\tnext();\n\t\t}, 100);\n\t}]);\n</script>\n```\n\n## Work inside a scope\n\nWhen a component is inside a [scope](../scopes/), `self.makepath()` turns `?` into the path of the scope. `self.GET()` and `self.SET()` do this for you.\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-component name=\"total\" path=\"?.items\" config=\"target:?.sum\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('total', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tvar sum = (value || []).reduce((a, b) => a + b, 0);\n\t\t\tself.SET(config.target, sum);\n\t\t\tconsole.log(self.path, self.makepath(config.target), self.GET(config.target));\n\t\t};\n\t});\n\n\tSET('order.items', [10, 20]);\n</script>\n```\n\n## Watch other data\n\n| Method | Description |\n| --- | --- |\n| `self.watch(path, fn, [init])` | Watches a path while the component exists. |\n| `self.on(name, fn)` | Listens to a global event while the component exists. |\n| `self.datasource(path, fn)` | Watches a path and calls the function with the current value once the configuration is loaded. |\n| `self.command(name, fn)` | Registers a command for [CMD()](../../reference/globals/). |\n| `self.event(type, [selector], fn)` | Adds a DOM event listener to the element. |\n\n```html\n<ui-component name=\"filter\" path=\"query\" config=\"source:shop.colors\"></ui-component>\n\n<script>\n\tCOMPONENT('filter', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.watch('shop.total', (path, value) => console.log('watch', value));\n\t\t\tself.on('reload', reason => console.log('event', reason));\n\t\t\tself.datasource(config.source, (path, value, type) => console.log('datasource', value, type));\n\t\t};\n\t});\n\n\tSET('shop.colors', ['red']);\n\n\tON('ready', function() {\n\t\tSET('shop.total', 5);            // watch 5\n\t\tEMIT('reload', 'manual');        // event manual\n\t\tSET('shop.colors', ['blue']);    // datasource [\"blue\"] 1\n\t});\n\t// datasource [\"red\"] 0\n</script>\n```\n\n## Limit when the setter runs\n\n| Method | Effect |\n| --- | --- |\n| `self.bindchanges()` | Skips the setter when the value is the same as the last one. |\n| `self.bindexact()` | Skips the setter for changes made to paths below the path of the component. |\n\n```html\n<ui-component name=\"once\" path=\"a.b\"></ui-component>\n\n<script>\n\tCOMPONENT('once', function(self) {\n\n\t\tself.bindchanges();\n\t\tself.bindexact();\n\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log('setter', JSON.stringify(value), type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('a.b', { c: 1 });     // setter {\"c\":1} 1\n\t\tSET('a.b', { c: 1 });     // (same value, skipped)\n\t\tSET('a.b.c', 2);          // (nested path, skipped)\n\t});\n\t// setter undefined 0\n</script>\n```\n\n## Work with the element\n\n| Member | Description |\n| --- | --- |\n| `self.element` | The element, as a jQuery object. |\n| `self.find(selector)` | Finds elements inside the component. |\n| `self.html(value)` | Replaces the content with HTML. |\n| `self.text(value)` | Replaces the content with text. |\n| `self.aclass(name)` | Adds a CSS class. |\n| `self.css(name, value)` | Sets a CSS property. |\n\nThe [Component](../../reference/component/) reference lists every method.\n\n## A complete component\n\nThis rating control combines configuration, rendering, user input and a binding on the same path.\n\n```html\n<ui-component name=\"rating\" path=\"review.stars\" config=\"max:5;icon:*\"></ui-component>\n<p><ui-bind path=\"review.stars\" config=\"text:value + ' of 5'\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('rating', 'max:5;icon:#', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t\tself.event('click', 'span', function() {\n\t\t\t\tself.bind('@touched @modified @setter', +this.getAttribute('data-value'));\n\t\t\t});\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\t!init && self.refresh();\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tvar builder = [];\n\t\t\tfor (var i = 1; i <= config.max; i++)\n\t\t\t\tbuilder.push('<span data-value=\"' + i + '\" class=\"' + (i <= value ? 'on' : '') + '\">' + config.icon + '</span>');\n\t\t\tself.html(builder.join(''));\n\t\t};\n\t});\n\n\tSET('review.stars', 3);\n</script>\n```\n\nThe control starts with three active stars and the text `3 of 5`. Clicking the fifth star stores `5` and updates the text.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTR1eM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/creating-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Komponenten erstellen","summary":"Deklariere eigene Komponenten, steuere ihren Lebenszyklus und tausche Daten mit dem Modell aus.","markdown":"---\ntitle: Komponenten erstellen\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/creating-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Komponenten erstellen\n\n> Deklariere eigene Komponenten, steuere ihren Lebenszyklus und tausche Daten mit dem Modell aus.\n\nDu deklarierst eine Komponente einmal mit [COMPONENT()](../../reference/globals/) und platzierst sie dann auf beliebig vielen Seiten. Dieser Leitfaden baut die API Schritt für Schritt auf. Wie du vorhandene Komponenten platzierst, erfährst du unter [Komponenten verwenden](../using-components/).\n\n## Eine Komponente deklarieren\n\n```html\n<ui-component name=\"hello\" path=\"visitor\"></ui-component>\n\n<script>\n\tCOMPONENT('hello', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text('Hello ' + (value || 'stranger'));\n\t\t};\n\t});\n\n\tSET('visitor', 'Ana');\n</script>\n```\n\nDas Element wird als `<ui-component name=\"hello\" path=\"visitor\" class=\"ui-hello\">Hello Ana</ui-component>` gerendert.\n\n`COMPONENT(name, [config], declaration, [dependencies])` nimmt diese Argumente entgegen:\n\n| Argument | Beschreibung |\n| --- | --- |\n| `name` | Der Name der Komponente. |\n| `config` | Die Standardkonfiguration, als String wie `'size:1;color:red'` oder als Objekt. |\n| `declaration` | Eine Funktion, die für jede Instanz ausgeführt wird. |\n| `dependencies` | Ein Array mit allem, was zuerst geladen werden muss. |\n\nDie Deklaration erhält drei Argumente:\n\n| Argument | Beschreibung |\n| --- | --- |\n| `self` | Die Instanz der Komponente. |\n| `config` | Die Konfiguration dieser Instanz. |\n| `cls` | Ein CSS-Klassenname aus `ui-` und dem Namen der Komponente. |\n\n## Der Lebenszyklus\n\nDie folgenden Funktionen definierst du auf `self`, und die Bibliothek ruft sie in dieser Reihenfolge auf. Alle sind optional.\n\n```html\n<ui-component name=\"life\" path=\"demo.value\" config=\"size:3\"></ui-component>\n\n<script>\n\tCOMPONENT('life', 'size:1', function(self, config, cls) {\n\n\t\tconsole.log('1 declaration', cls, config.size);\n\n\t\tself.init = () => console.log('2 init');\n\t\tself.make = () => console.log('3 make');\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'size')\n\t\t\t\tconsole.log('4 configure', key, value, init);\n\t\t};\n\n\t\tself.setter = (value, path, type) => console.log('5 setter', value, path, type);\n\n\t\tself.validate = function(value) {\n\t\t\tconsole.log('6 validate', value);\n\t\t\treturn true;\n\t\t};\n\n\t\tself.state = (type, what) => console.log('7 state', type, what);\n\t\tself.done = () => console.log('8 done');\n\t\tself.destroy = () => console.log('9 destroy');\n\t});\n\n\tSET('demo.value', 'A');\n\n\tsetTimeout(() => FIND('life').remove(), 600);\n</script>\n```\n\n| Funktion | Wann sie ausgeführt wird |\n| --- | --- |\n| `init()` | Einmal pro Komponentenname, mit der ersten Instanz. |\n| `make()` | Wenn die Instanz erstellt wird. Baue hier den Inhalt auf. |\n| `configure(key, value, init, prev)` | Für jeden Konfigurationsschlüssel und erneut bei jeder Änderung eines Schlüssels. |\n| `setter(value, path, type)` | Mit dem Anfangswert und bei jeder Änderung des Werts. |\n| `validate(value)` | Nach dem Setter. Gibt `true` für einen gültigen Wert zurück. |\n| `state(type, what)` | Wenn sich der Zustand der Komponente ändert. |\n| `done()` | Kurz nachdem die Komponente bereit ist. |\n| `destroy()` | Wenn die Komponente entfernt wird. |\n\nWährend der Initialisierung läuft `configure` auch für die Zustandsschlüssel `modified`, `touched` und `invalid`, wobei `init` auf `true` gesetzt ist.\n\n## Daten empfangen\n\n`self.setter` erhält den Wert, den geänderten Path und die Art der Änderung.\n\n```html\n<ui-component name=\"spy\" path=\"demo.value\" default=\"'initial'\"></ui-component>\n\n<script>\n\tCOMPONENT('spy', function(self) {\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log(value, type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('demo.value', 'manual');        // manual 1\n\t\tFIND('spy').set('input', 2);        // input 2\n\t\tDEFAULT('demo.value');              // initial 3\n\t});\n\t// initial 0\n</script>\n```\n\n| Typ | Bedeutung |\n| --- | --- |\n| `0` | Der Anfangswert. |\n| `1` | Durch Code geändert. |\n| `2` | Durch Benutzereingabe geändert. |\n| `3` | Auf den Standardwert gesetzt. |\n\n## Die Konfiguration lesen\n\nDas Objekt `config` enthält immer die aktuellen Werte. Mit `self.configure` reagierst du auf Änderungen, und anhand des Arguments `init` unterscheidest du den ersten Durchlauf von späteren. `self.refresh()` führt den Setter erneut mit dem aktuellen Wert aus.\n\n```html\n<ui-component name=\"meter\" path=\"level\" config=\"max:10;color:green\"></ui-component>\n\n<script>\n\tCOMPONENT('meter', 'max:100;color:gray', function(self, config) {\n\n\t\tself.configure = function(key, value, init, prev) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'color':\n\t\t\t\t\tself.css('color', value);\n\t\t\t\t\t!init && console.log('color', prev, '->', value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'max':\n\t\t\t\t\t!init && self.refresh();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' / ' + config.max);\n\t\t};\n\t});\n\n\tSET('level', 7);\n\n\tON('ready', function() {\n\t\tFIND('meter').reconfigure('color:red;max:20');\n\t\t// color green -> red\n\t});\n</script>\n```\n\nNach dem Aufruf von `reconfigure()` rendert das Element `7 / 20` in Rot.\n\n## Daten schreiben\n\n| Methode | Beschreibung |\n| --- | --- |\n| `self.get()` | Liest den Wert am Path der Komponente. |\n| `self.set(value, [type])` | Schreibt den Wert und markiert die Komponente als geändert. Auch der Setter wird ausgeführt. |\n| `self.modify(value, [type])` | Führt die Parser aus, markiert die Komponente als berührt und schreibt den Wert mit dem Typ `2`. |\n| `self.getter(value)` | Führt die Parser aus, markiert die Komponente als berührt und schreibt den Wert, falls er sich geändert hat. |\n| `self.bind(flags, value)` | Schreibt den Wert, ohne den Setter auszuführen, und wendet die Flags an. |\n| `self.skip()` | Überspringt den nächsten Durchlauf des Setters. |\n\nDie Flags von `self.bind()` sind `@touched`, `@modified`, `@reset`, `@validate` und `@setter`. Das letzte sorgt dafür, dass der Setter doch ausgeführt wird.\n\n```html\n<ui-component name=\"stepper\" path=\"qty\"></ui-component>\n\n<script>\n\tCOMPONENT('stepper', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button>-</button> <b></b> <button>+</button>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar diff = this.textContent === '+' ? 1 : -1;\n\t\t\t\tself.bind('@touched @modified', (self.get() || 0) + diff);\n\t\t\t\tself.find('b').text(self.get());\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tconsole.log('setter', value);\n\t\t\tself.find('b').text(value);\n\t\t};\n\t});\n\n\tSET('qty', 1);    // setter 1\n</script>\n```\n\nNach zwei Klicks auf `+` steht `qty` auf `3`, und der Setter läuft bei diesen Klicks nicht. Ein späteres `SET('qty', 9)` führt ihn wie gewohnt aus.\n\n## Ein Texteingabefeld anbinden\n\nEin `<input>`, `<textarea>` oder `<select>` mit dem Attribut `data-jc-bind` funktioniert ohne weiteren Code: Die Bibliothek kopiert den Wert in beide Richtungen, und Checkboxen schreiben `true` oder `false`. Ein `formatter` ändert, wie der Wert angezeigt wird. Mit der Einstellung `type:number` speichert die Bibliothek eine Zahl statt eines Strings.\n\n```html\n<ui-component name=\"price\" path=\"item.price\" config=\"type:number\"></ui-component>\n\n<script>\n\tCOMPONENT('price', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn value == null ? '' : value.format(2);\n\t\t});\n\t});\n\n\tSET('item.price', 5);\n</script>\n```\n\nDas Eingabefeld zeigt `5.00`. Die Eingabe von `12.5` speichert die Zahl `12.5`.\n\nDiese Konfigurationsschlüssel legen fest, wann ein Eingabefeld seinen Wert schreibt:\n\n| Schlüssel | Wirkung |\n| --- | --- |\n| `$delay:500` | Wartet nach dem letzten Tastendruck so viele Millisekunden. Der Standardwert ist `200`. |\n| `$realtime:false` | Schreibt den Wert, wenn das Eingabefeld den Fokus verliert. |\n\n```html\n<ui-component id=\"slow\" name=\"box\" path=\"form.slow\" config=\"$delay:500\"></ui-component>\n<ui-component id=\"blur\" name=\"box\" path=\"form.blur\" config=\"$realtime:false\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n## Ein eigenes Eingabefeld bauen\n\nRufe bei eigenen Steuerelementen `self.getter()` mit dem neuen Wert auf. Ein `parser` wandelt die Eingabe des Benutzers in den gespeicherten Wert um, ein `formatter` macht das Gegenteil. Beide erhalten den Path, den Wert, den Typ und das Format.\n\n```html\n<ui-component name=\"tags\" path=\"post.tags\"></ui-component>\n\n<script>\n\tCOMPONENT('tags', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" />');\n\t\t\tself.event('change', 'input', function() {\n\t\t\t\tself.getter(this.value);\n\t\t\t});\n\t\t};\n\n\t\tself.parser(function(path, value) {\n\t\t\treturn value.split(',').map(tag => tag.trim());\n\t\t});\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn (value || []).join(', ');\n\t\t});\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('input').val(self.formatter(value));\n\t\t};\n\t});\n\n\tSET('post.tags', ['a', 'b']);\n</script>\n```\n\nDas Eingabefeld zeigt `a, b`. Die Eingabe von `x, y ,z` speichert `[\"x\",\"y\",\"z\"]`.\n\n## Den Wert validieren\n\n`self.validate` gibt `true` für einen gültigen Wert zurück. `self.isInvalid()` gibt `true` zurück, wenn der Wert ungültig ist und der Benutzer die Komponente bereits berührt hat. Das ist der richtige Moment, um einen Fehler anzuzeigen.\n\n```html\n<ui-component id=\"mail\" name=\"email\" path=\"user.email\"></ui-component>\n\n<script>\n\tCOMPONENT('email', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" /><small>Enter a valid address</small>');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn (value || '').isEmail();\n\t\t};\n\n\t\tself.state = function() {\n\t\t\tself.find('small').tclass('hidden', !self.isInvalid());\n\t\t};\n\t});\n</script>\n```\n\nDie Meldung bleibt beim leeren Formular verborgen, erscheint nach `nope` und verschwindet nach `a@b.io` wieder. Ganze Formulare behandelt [Formulare und Validierung](../forms/).\n\n## Interne Daten speichern\n\n`self.data(key, value)` speichert einen Wert innerhalb der Komponente. Eine Bindung in der Komponente liest ihn über einen Path, der mit `@` beginnt. `@` allein ist der Wert der Komponente, und `@config.name` ist ein Konfigurationsschlüssel.\n\n```html\n<ui-component name=\"card\" path=\"person.name\" config=\"title:Profile\"></ui-component>\n\n<script>\n\tCOMPONENT('card', 'title:Untitled', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<h3><ui-bind path=\"@config.title\" config=\"text\"></ui-bind></h3>'\n\t\t\t\t+ '<p><ui-bind path=\"@\" config=\"text\"></ui-bind></p>'\n\t\t\t\t+ '<small><ui-bind path=\"@visits\" config=\"text\"></ui-bind></small>');\n\t\t\tself.data('visits', 1);\n\t\t};\n\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('person.name', 'Ana');\n</script>\n```\n\n## Abhängigkeiten deklarieren\n\nDas vierte Argument von `COMPONENT()` listet auf, was beim Start der Komponente verfügbar sein muss. `make` wartet auf alle diese Einträge.\n\n| Eintrag | Beschreibung |\n| --- | --- |\n| Eine Funktion | Erhält eine `next`-Funktion, die du aufrufst, wenn sie fertig ist. |\n| Eine URL | Ein Skript oder Stylesheet, das einmal importiert wird. |\n| `@name` | Eine andere Komponente, die heruntergeladen wird, falls sie fehlt. |\n\n```html\n<ui-component name=\"chart\" path=\"stats\"></ui-component>\n\n<script>\n\tCOMPONENT('chart', function(self) {\n\t\tself.make = function() {\n\t\t\tconsole.log('make', window.chartlib);\n\t\t};\n\t}, [function(next) {\n\t\tsetTimeout(function() {\n\t\t\twindow.chartlib = 'loaded';\n\t\t\tnext();\n\t\t}, 100);\n\t}]);\n</script>\n```\n\n## Innerhalb eines Scopes arbeiten\n\nBefindet sich eine Komponente in einem [Scope](../scopes/), wandelt `self.makepath()` das `?` in den Path des Scopes um. `self.GET()` und `self.SET()` erledigen das für dich.\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-component name=\"total\" path=\"?.items\" config=\"target:?.sum\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('total', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tvar sum = (value || []).reduce((a, b) => a + b, 0);\n\t\t\tself.SET(config.target, sum);\n\t\t\tconsole.log(self.path, self.makepath(config.target), self.GET(config.target));\n\t\t};\n\t});\n\n\tSET('order.items', [10, 20]);\n</script>\n```\n\n## Andere Daten überwachen\n\n| Methode | Beschreibung |\n| --- | --- |\n| `self.watch(path, fn, [init])` | Überwacht einen Path, solange die Komponente existiert. |\n| `self.on(name, fn)` | Lauscht auf ein globales Event, solange die Komponente existiert. |\n| `self.datasource(path, fn)` | Überwacht einen Path und ruft die Funktion mit dem aktuellen Wert auf, sobald die Konfiguration geladen ist. |\n| `self.command(name, fn)` | Registriert einen Befehl für [CMD()](../../reference/globals/). |\n| `self.event(type, [selector], fn)` | Fügt dem Element einen DOM-Event-Listener hinzu. |\n\n```html\n<ui-component name=\"filter\" path=\"query\" config=\"source:shop.colors\"></ui-component>\n\n<script>\n\tCOMPONENT('filter', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.watch('shop.total', (path, value) => console.log('watch', value));\n\t\t\tself.on('reload', reason => console.log('event', reason));\n\t\t\tself.datasource(config.source, (path, value, type) => console.log('datasource', value, type));\n\t\t};\n\t});\n\n\tSET('shop.colors', ['red']);\n\n\tON('ready', function() {\n\t\tSET('shop.total', 5);            // watch 5\n\t\tEMIT('reload', 'manual');        // event manual\n\t\tSET('shop.colors', ['blue']);    // datasource [\"blue\"] 1\n\t});\n\t// datasource [\"red\"] 0\n</script>\n```\n\n## Begrenzen, wann der Setter läuft\n\n| Methode | Wirkung |\n| --- | --- |\n| `self.bindchanges()` | Überspringt den Setter, wenn der Wert dem letzten entspricht. |\n| `self.bindexact()` | Überspringt den Setter bei Änderungen an Paths unterhalb des Paths der Komponente. |\n\n```html\n<ui-component name=\"once\" path=\"a.b\"></ui-component>\n\n<script>\n\tCOMPONENT('once', function(self) {\n\n\t\tself.bindchanges();\n\t\tself.bindexact();\n\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log('setter', JSON.stringify(value), type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('a.b', { c: 1 });     // setter {\"c\":1} 1\n\t\tSET('a.b', { c: 1 });     // (same value, skipped)\n\t\tSET('a.b.c', 2);          // (nested path, skipped)\n\t});\n\t// setter undefined 0\n</script>\n```\n\n## Mit dem Element arbeiten\n\n| Member | Beschreibung |\n| --- | --- |\n| `self.element` | Das Element als jQuery-Objekt. |\n| `self.find(selector)` | Sucht Elemente innerhalb der Komponente. |\n| `self.html(value)` | Ersetzt den Inhalt durch HTML. |\n| `self.text(value)` | Ersetzt den Inhalt durch Text. |\n| `self.aclass(name)` | Fügt eine CSS-Klasse hinzu. |\n| `self.css(name, value)` | Setzt eine CSS-Eigenschaft. |\n\nDie Referenz zu [Component](../../reference/component/) führt alle Methoden auf.\n\n## Eine vollständige Komponente\n\nDieses Bewertungs-Steuerelement kombiniert Konfiguration, Rendering, Benutzereingabe und eine Bindung auf demselben Path.\n\n```html\n<ui-component name=\"rating\" path=\"review.stars\" config=\"max:5;icon:*\"></ui-component>\n<p><ui-bind path=\"review.stars\" config=\"text:value + ' of 5'\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('rating', 'max:5;icon:#', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t\tself.event('click', 'span', function() {\n\t\t\t\tself.bind('@touched @modified @setter', +this.getAttribute('data-value'));\n\t\t\t});\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\t!init && self.refresh();\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tvar builder = [];\n\t\t\tfor (var i = 1; i <= config.max; i++)\n\t\t\t\tbuilder.push('<span data-value=\"' + i + '\" class=\"' + (i <= value ? 'on' : '') + '\">' + config.icon + '</span>');\n\t\t\tself.html(builder.join(''));\n\t\t};\n\t});\n\n\tSET('review.stars', 3);\n</script>\n```\n\nDas Steuerelement startet mit drei aktiven Sternen und dem Text `3 of 5`. Ein Klick auf den fünften Stern speichert `5` und aktualisiert den Text.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTR1eM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/creating-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Crear componentes","summary":"Declara tus propios componentes, gestiona su ciclo de vida e intercambia datos con el modelo.","markdown":"---\ntitle: Crear componentes\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/creating-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Crear componentes\n\n> Declara tus propios componentes, gestiona su ciclo de vida e intercambia datos con el modelo.\n\nDeclaras un componente una sola vez con [COMPONENT()](../../reference/globals/) y luego lo colocas en tantas páginas como necesites. Esta guía presenta la API paso a paso. Para colocar componentes existentes, lee [Usar componentes](../using-components/).\n\n## Declarar un componente\n\n```html\n<ui-component name=\"hello\" path=\"visitor\"></ui-component>\n\n<script>\n\tCOMPONENT('hello', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text('Hello ' + (value || 'stranger'));\n\t\t};\n\t});\n\n\tSET('visitor', 'Ana');\n</script>\n```\n\nEl elemento se renderiza como `<ui-component name=\"hello\" path=\"visitor\" class=\"ui-hello\">Hello Ana</ui-component>`.\n\n`COMPONENT(name, [config], declaration, [dependencies])` admite estos argumentos:\n\n| Argumento | Descripción |\n| --- | --- |\n| `name` | El nombre del componente. |\n| `config` | La configuración predeterminada, como una cadena del tipo `'size:1;color:red'` o como un objeto. |\n| `declaration` | Una función que se ejecuta para cada instancia. |\n| `dependencies` | Un array con lo que debe cargarse primero. |\n\nLa declaración recibe tres argumentos:\n\n| Argumento | Descripción |\n| --- | --- |\n| `self` | La instancia del componente. |\n| `config` | La configuración de esta instancia. |\n| `cls` | Un nombre de clase CSS formado por `ui-` y el nombre del componente. |\n\n## El ciclo de vida\n\nDefines las funciones siguientes en `self`, y la biblioteca las llama en este orden. Todas son opcionales.\n\n```html\n<ui-component name=\"life\" path=\"demo.value\" config=\"size:3\"></ui-component>\n\n<script>\n\tCOMPONENT('life', 'size:1', function(self, config, cls) {\n\n\t\tconsole.log('1 declaration', cls, config.size);\n\n\t\tself.init = () => console.log('2 init');\n\t\tself.make = () => console.log('3 make');\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'size')\n\t\t\t\tconsole.log('4 configure', key, value, init);\n\t\t};\n\n\t\tself.setter = (value, path, type) => console.log('5 setter', value, path, type);\n\n\t\tself.validate = function(value) {\n\t\t\tconsole.log('6 validate', value);\n\t\t\treturn true;\n\t\t};\n\n\t\tself.state = (type, what) => console.log('7 state', type, what);\n\t\tself.done = () => console.log('8 done');\n\t\tself.destroy = () => console.log('9 destroy');\n\t});\n\n\tSET('demo.value', 'A');\n\n\tsetTimeout(() => FIND('life').remove(), 600);\n</script>\n```\n\n| Función | Cuándo se ejecuta |\n| --- | --- |\n| `init()` | Una vez por cada nombre de componente, con la primera instancia. |\n| `make()` | Cuando se crea la instancia. Construye aquí el contenido. |\n| `configure(key, value, init, prev)` | Para cada clave de configuración, y de nuevo cada vez que cambia una clave. |\n| `setter(value, path, type)` | Con el valor inicial, y cada vez que cambia el valor. |\n| `validate(value)` | Después del setter. Devuelve `true` si el valor es válido. |\n| `state(type, what)` | Cuando cambia el estado del componente. |\n| `done()` | Poco después de que el componente esté listo. |\n| `destroy()` | Cuando se elimina el componente. |\n\nDurante la inicialización, `configure` también se ejecuta para las claves de estado `modified`, `touched` e `invalid`, con `init` a `true`.\n\n## Recibir datos\n\n`self.setter` recibe el valor, el path que ha cambiado y el tipo de cambio.\n\n```html\n<ui-component name=\"spy\" path=\"demo.value\" default=\"'initial'\"></ui-component>\n\n<script>\n\tCOMPONENT('spy', function(self) {\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log(value, type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('demo.value', 'manual');        // manual 1\n\t\tFIND('spy').set('input', 2);        // input 2\n\t\tDEFAULT('demo.value');              // initial 3\n\t});\n\t// initial 0\n</script>\n```\n\n| Tipo | Significado |\n| --- | --- |\n| `0` | El valor inicial. |\n| `1` | Cambiado por código. |\n| `2` | Cambiado por una entrada del usuario. |\n| `3` | Establecido en el valor predeterminado. |\n\n## Leer la configuración\n\nEl objeto `config` siempre contiene los valores actuales. Usa `self.configure` para reaccionar a los cambios y comprueba el argumento `init` para distinguir la primera ejecución de las siguientes. `self.refresh()` vuelve a ejecutar el setter con el valor actual.\n\n```html\n<ui-component name=\"meter\" path=\"level\" config=\"max:10;color:green\"></ui-component>\n\n<script>\n\tCOMPONENT('meter', 'max:100;color:gray', function(self, config) {\n\n\t\tself.configure = function(key, value, init, prev) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'color':\n\t\t\t\t\tself.css('color', value);\n\t\t\t\t\t!init && console.log('color', prev, '->', value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'max':\n\t\t\t\t\t!init && self.refresh();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' / ' + config.max);\n\t\t};\n\t});\n\n\tSET('level', 7);\n\n\tON('ready', function() {\n\t\tFIND('meter').reconfigure('color:red;max:20');\n\t\t// color green -> red\n\t});\n</script>\n```\n\nEl elemento renderiza `7 / 20` en rojo después de la llamada a `reconfigure()`.\n\n## Escribir datos\n\n| Método | Descripción |\n| --- | --- |\n| `self.get()` | Lee el valor en el path del componente. |\n| `self.set(value, [type])` | Escribe el valor y marca el componente como modificado. El setter también se ejecuta. |\n| `self.modify(value, [type])` | Ejecuta los parsers, marca el componente como tocado y escribe el valor con el tipo `2`. |\n| `self.getter(value)` | Ejecuta los parsers, marca el componente como tocado y escribe el valor si ha cambiado. |\n| `self.bind(flags, value)` | Escribe el valor sin ejecutar el setter y aplica los flags. |\n| `self.skip()` | Omite la siguiente ejecución del setter. |\n\nLos flags de `self.bind()` son `@touched`, `@modified`, `@reset`, `@validate` y `@setter`. El último hace que el setter se ejecute de todos modos.\n\n```html\n<ui-component name=\"stepper\" path=\"qty\"></ui-component>\n\n<script>\n\tCOMPONENT('stepper', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button>-</button> <b></b> <button>+</button>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar diff = this.textContent === '+' ? 1 : -1;\n\t\t\t\tself.bind('@touched @modified', (self.get() || 0) + diff);\n\t\t\t\tself.find('b').text(self.get());\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tconsole.log('setter', value);\n\t\t\tself.find('b').text(value);\n\t\t};\n\t});\n\n\tSET('qty', 1);    // setter 1\n</script>\n```\n\nDos clics en `+` dejan `qty` en `3`, y el setter no se ejecuta con estos clics. Un `SET('qty', 9)` posterior lo ejecuta como siempre.\n\n## Conectar un campo de texto\n\nUn `<input>`, `<textarea>` o `<select>` con el atributo `data-jc-bind` funciona sin más código: la biblioteca copia el valor en ambas direcciones, y las casillas de verificación escriben `true` o `false`. Un `formatter` cambia cómo se muestra el valor. El ajuste `type:number` hace que la biblioteca guarde un número en lugar de una cadena.\n\n```html\n<ui-component name=\"price\" path=\"item.price\" config=\"type:number\"></ui-component>\n\n<script>\n\tCOMPONENT('price', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn value == null ? '' : value.format(2);\n\t\t});\n\t});\n\n\tSET('item.price', 5);\n</script>\n```\n\nEl campo muestra `5.00`. Al escribir `12.5` se guarda el número `12.5`.\n\nEstas claves de configuración controlan cuándo escribe su valor un campo:\n\n| Clave | Efecto |\n| --- | --- |\n| `$delay:500` | Espera estos milisegundos después de la última pulsación de tecla. El valor predeterminado es `200`. |\n| `$realtime:false` | Escribe el valor cuando el campo pierde el foco. |\n\n```html\n<ui-component id=\"slow\" name=\"box\" path=\"form.slow\" config=\"$delay:500\"></ui-component>\n<ui-component id=\"blur\" name=\"box\" path=\"form.blur\" config=\"$realtime:false\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n## Crear un campo personalizado\n\nEn tus propios controles, llama a `self.getter()` con el valor nuevo. Un `parser` convierte lo que ha introducido el usuario en el valor guardado, y un `formatter` hace lo contrario. Ambos reciben el path, el valor, el tipo y el formato.\n\n```html\n<ui-component name=\"tags\" path=\"post.tags\"></ui-component>\n\n<script>\n\tCOMPONENT('tags', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" />');\n\t\t\tself.event('change', 'input', function() {\n\t\t\t\tself.getter(this.value);\n\t\t\t});\n\t\t};\n\n\t\tself.parser(function(path, value) {\n\t\t\treturn value.split(',').map(tag => tag.trim());\n\t\t});\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn (value || []).join(', ');\n\t\t});\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('input').val(self.formatter(value));\n\t\t};\n\t});\n\n\tSET('post.tags', ['a', 'b']);\n</script>\n```\n\nEl campo muestra `a, b`. Al introducir `x, y ,z` se guarda `[\"x\",\"y\",\"z\"]`.\n\n## Validar el valor\n\n`self.validate` devuelve `true` si el valor es válido. `self.isInvalid()` devuelve `true` cuando el valor no es válido y el usuario ya ha tocado el componente, que es el momento adecuado para mostrar un error.\n\n```html\n<ui-component id=\"mail\" name=\"email\" path=\"user.email\"></ui-component>\n\n<script>\n\tCOMPONENT('email', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" /><small>Enter a valid address</small>');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn (value || '').isEmail();\n\t\t};\n\n\t\tself.state = function() {\n\t\t\tself.find('small').tclass('hidden', !self.isInvalid());\n\t\t};\n\t});\n</script>\n```\n\nEl mensaje permanece oculto con el formulario vacío, aparece después de `nope` y vuelve a desaparecer después de `a@b.io`. [Formularios y validación](../forms/) trata los formularios completos.\n\n## Guardar datos internos\n\n`self.data(key, value)` guarda un valor dentro del componente. Un enlace dentro del componente lo lee con un path que empieza por `@`. `@` solo es el valor del componente, y `@config.name` es una clave de configuración.\n\n```html\n<ui-component name=\"card\" path=\"person.name\" config=\"title:Profile\"></ui-component>\n\n<script>\n\tCOMPONENT('card', 'title:Untitled', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<h3><ui-bind path=\"@config.title\" config=\"text\"></ui-bind></h3>'\n\t\t\t\t+ '<p><ui-bind path=\"@\" config=\"text\"></ui-bind></p>'\n\t\t\t\t+ '<small><ui-bind path=\"@visits\" config=\"text\"></ui-bind></small>');\n\t\t\tself.data('visits', 1);\n\t\t};\n\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('person.name', 'Ana');\n</script>\n```\n\n## Declarar dependencias\n\nEl cuarto argumento de `COMPONENT()` enumera lo que debe estar disponible cuando se inicia el componente. `make` espera a todo ello.\n\n| Elemento | Descripción |\n| --- | --- |\n| Una función | Recibe una función `next` a la que debes llamar cuando termine. |\n| Una URL | Un script o una hoja de estilos que se importa una sola vez. |\n| `@name` | Otro componente, que se descarga si falta. |\n\n```html\n<ui-component name=\"chart\" path=\"stats\"></ui-component>\n\n<script>\n\tCOMPONENT('chart', function(self) {\n\t\tself.make = function() {\n\t\t\tconsole.log('make', window.chartlib);\n\t\t};\n\t}, [function(next) {\n\t\tsetTimeout(function() {\n\t\t\twindow.chartlib = 'loaded';\n\t\t\tnext();\n\t\t}, 100);\n\t}]);\n</script>\n```\n\n## Trabajar dentro de un scope\n\nCuando un componente está dentro de un [scope](../scopes/), `self.makepath()` convierte `?` en el path del scope. `self.GET()` y `self.SET()` lo hacen por ti.\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-component name=\"total\" path=\"?.items\" config=\"target:?.sum\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('total', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tvar sum = (value || []).reduce((a, b) => a + b, 0);\n\t\t\tself.SET(config.target, sum);\n\t\t\tconsole.log(self.path, self.makepath(config.target), self.GET(config.target));\n\t\t};\n\t});\n\n\tSET('order.items', [10, 20]);\n</script>\n```\n\n## Observar otros datos\n\n| Método | Descripción |\n| --- | --- |\n| `self.watch(path, fn, [init])` | Observa un path mientras existe el componente. |\n| `self.on(name, fn)` | Escucha un evento global mientras existe el componente. |\n| `self.datasource(path, fn)` | Observa un path y llama a la función con el valor actual una vez cargada la configuración. |\n| `self.command(name, fn)` | Registra un comando para [CMD()](../../reference/globals/). |\n| `self.event(type, [selector], fn)` | Añade un listener de eventos DOM al elemento. |\n\n```html\n<ui-component name=\"filter\" path=\"query\" config=\"source:shop.colors\"></ui-component>\n\n<script>\n\tCOMPONENT('filter', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.watch('shop.total', (path, value) => console.log('watch', value));\n\t\t\tself.on('reload', reason => console.log('event', reason));\n\t\t\tself.datasource(config.source, (path, value, type) => console.log('datasource', value, type));\n\t\t};\n\t});\n\n\tSET('shop.colors', ['red']);\n\n\tON('ready', function() {\n\t\tSET('shop.total', 5);            // watch 5\n\t\tEMIT('reload', 'manual');        // event manual\n\t\tSET('shop.colors', ['blue']);    // datasource [\"blue\"] 1\n\t});\n\t// datasource [\"red\"] 0\n</script>\n```\n\n## Limitar cuándo se ejecuta el setter\n\n| Método | Efecto |\n| --- | --- |\n| `self.bindchanges()` | Omite el setter cuando el valor es igual al último. |\n| `self.bindexact()` | Omite el setter en los cambios hechos en paths situados por debajo del path del componente. |\n\n```html\n<ui-component name=\"once\" path=\"a.b\"></ui-component>\n\n<script>\n\tCOMPONENT('once', function(self) {\n\n\t\tself.bindchanges();\n\t\tself.bindexact();\n\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log('setter', JSON.stringify(value), type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('a.b', { c: 1 });     // setter {\"c\":1} 1\n\t\tSET('a.b', { c: 1 });     // (same value, skipped)\n\t\tSET('a.b.c', 2);          // (nested path, skipped)\n\t});\n\t// setter undefined 0\n</script>\n```\n\n## Trabajar con el elemento\n\n| Miembro | Descripción |\n| --- | --- |\n| `self.element` | El elemento, como objeto jQuery. |\n| `self.find(selector)` | Busca elementos dentro del componente. |\n| `self.html(value)` | Sustituye el contenido por HTML. |\n| `self.text(value)` | Sustituye el contenido por texto. |\n| `self.aclass(name)` | Añade una clase CSS. |\n| `self.css(name, value)` | Define una propiedad CSS. |\n\nLa referencia de [Component](../../reference/component/) enumera todos los métodos.\n\n## Un componente completo\n\nEste control de valoración combina configuración, renderizado, entrada del usuario y un enlace en el mismo path.\n\n```html\n<ui-component name=\"rating\" path=\"review.stars\" config=\"max:5;icon:*\"></ui-component>\n<p><ui-bind path=\"review.stars\" config=\"text:value + ' of 5'\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('rating', 'max:5;icon:#', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t\tself.event('click', 'span', function() {\n\t\t\t\tself.bind('@touched @modified @setter', +this.getAttribute('data-value'));\n\t\t\t});\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\t!init && self.refresh();\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tvar builder = [];\n\t\t\tfor (var i = 1; i <= config.max; i++)\n\t\t\t\tbuilder.push('<span data-value=\"' + i + '\" class=\"' + (i <= value ? 'on' : '') + '\">' + config.icon + '</span>');\n\t\t\tself.html(builder.join(''));\n\t\t};\n\t});\n\n\tSET('review.stars', 3);\n</script>\n```\n\nEl control empieza con tres estrellas activas y el texto `3 of 5`. Al hacer clic en la quinta estrella se guarda `5` y se actualiza el texto.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTR1eM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/creating-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Créer des composants","summary":"Déclare tes propres composants, gère leur cycle de vie et échange des données avec le modèle de données.","markdown":"---\ntitle: \"Créer des composants\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/creating-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Créer des composants\n\n> Déclare tes propres composants, gère leur cycle de vie et échange des données avec le modèle de données.\n\nTu déclares un composant une seule fois avec [COMPONENT()](../../reference/globals/), puis tu le places sur autant de pages que nécessaire. Ce guide construit l'API pas à pas. Pour placer des composants existants, lis [Utiliser des composants](../using-components/).\n\n## Déclarer un composant\n\n```html\n<ui-component name=\"hello\" path=\"visitor\"></ui-component>\n\n<script>\n\tCOMPONENT('hello', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text('Hello ' + (value || 'stranger'));\n\t\t};\n\t});\n\n\tSET('visitor', 'Ana');\n</script>\n```\n\nL'élément est rendu sous la forme `<ui-component name=\"hello\" path=\"visitor\" class=\"ui-hello\">Hello Ana</ui-component>`.\n\n`COMPONENT(name, [config], declaration, [dependencies])` accepte ces arguments :\n\n| Argument | Description |\n| --- | --- |\n| `name` | Le nom du composant. |\n| `config` | La configuration par défaut, sous forme de chaîne comme `'size:1;color:red'` ou d'objet. |\n| `declaration` | Une fonction exécutée pour chaque instance. |\n| `dependencies` | Un tableau de ce qui doit être chargé d'abord. |\n\nLa déclaration reçoit trois arguments :\n\n| Argument | Description |\n| --- | --- |\n| `self` | L'instance du composant. |\n| `config` | La configuration de cette instance. |\n| `cls` | Un nom de classe CSS composé de `ui-` et du nom du composant. |\n\n## Le cycle de vie\n\nTu définis les fonctions ci-dessous sur `self`, et la bibliothèque les appelle dans cet ordre. Elles sont toutes facultatives.\n\n```html\n<ui-component name=\"life\" path=\"demo.value\" config=\"size:3\"></ui-component>\n\n<script>\n\tCOMPONENT('life', 'size:1', function(self, config, cls) {\n\n\t\tconsole.log('1 declaration', cls, config.size);\n\n\t\tself.init = () => console.log('2 init');\n\t\tself.make = () => console.log('3 make');\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'size')\n\t\t\t\tconsole.log('4 configure', key, value, init);\n\t\t};\n\n\t\tself.setter = (value, path, type) => console.log('5 setter', value, path, type);\n\n\t\tself.validate = function(value) {\n\t\t\tconsole.log('6 validate', value);\n\t\t\treturn true;\n\t\t};\n\n\t\tself.state = (type, what) => console.log('7 state', type, what);\n\t\tself.done = () => console.log('8 done');\n\t\tself.destroy = () => console.log('9 destroy');\n\t});\n\n\tSET('demo.value', 'A');\n\n\tsetTimeout(() => FIND('life').remove(), 600);\n</script>\n```\n\n| Fonction | Quand elle s'exécute |\n| --- | --- |\n| `init()` | Une seule fois par nom de composant, avec la première instance. |\n| `make()` | À la création de l'instance. Construis le contenu ici. |\n| `configure(key, value, init, prev)` | Pour chaque clé de configuration, puis à chaque changement d'une clé. |\n| `setter(value, path, type)` | Avec la valeur initiale, puis à chaque changement de la valeur. |\n| `validate(value)` | Après le setter. Renvoie `true` pour une valeur valide. |\n| `state(type, what)` | Quand l'état du composant change. |\n| `done()` | Peu après que le composant est prêt. |\n| `destroy()` | Quand le composant est supprimé. |\n\nPendant l'initialisation, `configure` s'exécute aussi pour les clés d'état `modified`, `touched` et `invalid`, avec `init` à `true`.\n\n## Recevoir des données\n\n`self.setter` reçoit la valeur, le path qui a changé et le type de changement.\n\n```html\n<ui-component name=\"spy\" path=\"demo.value\" default=\"'initial'\"></ui-component>\n\n<script>\n\tCOMPONENT('spy', function(self) {\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log(value, type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('demo.value', 'manual');        // manual 1\n\t\tFIND('spy').set('input', 2);        // input 2\n\t\tDEFAULT('demo.value');              // initial 3\n\t});\n\t// initial 0\n</script>\n```\n\n| Type | Signification |\n| --- | --- |\n| `0` | La valeur initiale. |\n| `1` | Modifiée par le code. |\n| `2` | Modifiée par une saisie de l'utilisateur. |\n| `3` | Remise à la valeur par défaut. |\n\n## Lire la configuration\n\nL'objet `config` contient toujours les valeurs actuelles. Utilise `self.configure` pour réagir aux changements, et vérifie l'argument `init` pour distinguer la première exécution des suivantes. `self.refresh()` exécute de nouveau le setter avec la valeur actuelle.\n\n```html\n<ui-component name=\"meter\" path=\"level\" config=\"max:10;color:green\"></ui-component>\n\n<script>\n\tCOMPONENT('meter', 'max:100;color:gray', function(self, config) {\n\n\t\tself.configure = function(key, value, init, prev) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'color':\n\t\t\t\t\tself.css('color', value);\n\t\t\t\t\t!init && console.log('color', prev, '->', value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'max':\n\t\t\t\t\t!init && self.refresh();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' / ' + config.max);\n\t\t};\n\t});\n\n\tSET('level', 7);\n\n\tON('ready', function() {\n\t\tFIND('meter').reconfigure('color:red;max:20');\n\t\t// color green -> red\n\t});\n</script>\n```\n\nL'élément affiche `7 / 20` en rouge après l'appel à `reconfigure()`.\n\n## Écrire des données\n\n| Méthode | Description |\n| --- | --- |\n| `self.get()` | Lit la valeur au path du composant. |\n| `self.set(value, [type])` | Écrit la valeur et marque le composant comme modifié. Le setter s'exécute aussi. |\n| `self.modify(value, [type])` | Exécute les parsers, marque le composant comme touché et écrit la valeur avec le type `2`. |\n| `self.getter(value)` | Exécute les parsers, marque le composant comme touché et écrit la valeur si elle a changé. |\n| `self.bind(flags, value)` | Écrit la valeur sans exécuter le setter et applique les flags. |\n| `self.skip()` | Ignore la prochaine exécution du setter. |\n\nLes flags de `self.bind()` sont `@touched`, `@modified`, `@reset`, `@validate` et `@setter`. Le dernier force malgré tout l'exécution du setter.\n\n```html\n<ui-component name=\"stepper\" path=\"qty\"></ui-component>\n\n<script>\n\tCOMPONENT('stepper', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button>-</button> <b></b> <button>+</button>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar diff = this.textContent === '+' ? 1 : -1;\n\t\t\t\tself.bind('@touched @modified', (self.get() || 0) + diff);\n\t\t\t\tself.find('b').text(self.get());\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tconsole.log('setter', value);\n\t\t\tself.find('b').text(value);\n\t\t};\n\t});\n\n\tSET('qty', 1);    // setter 1\n</script>\n```\n\nDeux clics sur `+` laissent `qty` à `3`, et le setter ne s'exécute pas pour ces clics. Un `SET('qty', 9)` ultérieur l'exécute normalement.\n\n## Connecter un champ de texte\n\nUn `<input>`, un `<textarea>` ou un `<select>` portant l'attribut `data-jc-bind` fonctionne sans code supplémentaire : la bibliothèque copie la valeur dans les deux sens, et les cases à cocher écrivent `true` ou `false`. Un `formatter` modifie l'affichage de la valeur. Le réglage `type:number` fait stocker à la bibliothèque un nombre au lieu d'une chaîne.\n\n```html\n<ui-component name=\"price\" path=\"item.price\" config=\"type:number\"></ui-component>\n\n<script>\n\tCOMPONENT('price', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn value == null ? '' : value.format(2);\n\t\t});\n\t});\n\n\tSET('item.price', 5);\n</script>\n```\n\nLe champ affiche `5.00`. Saisir `12.5` stocke le nombre `12.5`.\n\nCes clés de configuration déterminent quand un champ écrit sa valeur :\n\n| Clé | Effet |\n| --- | --- |\n| `$delay:500` | Attend ce nombre de millisecondes après la dernière frappe. La valeur par défaut est `200`. |\n| `$realtime:false` | Écrit la valeur quand le champ perd le focus. |\n\n```html\n<ui-component id=\"slow\" name=\"box\" path=\"form.slow\" config=\"$delay:500\"></ui-component>\n<ui-component id=\"blur\" name=\"box\" path=\"form.blur\" config=\"$realtime:false\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n## Créer un champ personnalisé\n\nPour tes propres contrôles, appelle `self.getter()` avec la nouvelle valeur. Un `parser` convertit la saisie de l'utilisateur en valeur stockée, et un `formatter` fait l'inverse. Tous deux reçoivent le path, la valeur, le type et le format.\n\n```html\n<ui-component name=\"tags\" path=\"post.tags\"></ui-component>\n\n<script>\n\tCOMPONENT('tags', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" />');\n\t\t\tself.event('change', 'input', function() {\n\t\t\t\tself.getter(this.value);\n\t\t\t});\n\t\t};\n\n\t\tself.parser(function(path, value) {\n\t\t\treturn value.split(',').map(tag => tag.trim());\n\t\t});\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn (value || []).join(', ');\n\t\t});\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('input').val(self.formatter(value));\n\t\t};\n\t});\n\n\tSET('post.tags', ['a', 'b']);\n</script>\n```\n\nLe champ affiche `a, b`. Saisir `x, y ,z` stocke `[\"x\",\"y\",\"z\"]`.\n\n## Valider la valeur\n\n`self.validate` renvoie `true` pour une valeur valide. `self.isInvalid()` renvoie `true` quand la valeur est invalide et que l'utilisateur a déjà touché le composant : c'est le bon moment pour afficher une erreur.\n\n```html\n<ui-component id=\"mail\" name=\"email\" path=\"user.email\"></ui-component>\n\n<script>\n\tCOMPONENT('email', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" /><small>Enter a valid address</small>');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn (value || '').isEmail();\n\t\t};\n\n\t\tself.state = function() {\n\t\t\tself.find('small').tclass('hidden', !self.isInvalid());\n\t\t};\n\t});\n</script>\n```\n\nLe message reste masqué sur le formulaire vide, apparaît après `nope` et disparaît de nouveau après `a@b.io`. [Formulaires et validation](../forms/) traite des formulaires complets.\n\n## Conserver des données internes\n\n`self.data(key, value)` stocke une valeur dans le composant. Une liaison à l'intérieur du composant la lit avec un path qui commence par `@`. `@` seul correspond à la valeur du composant, et `@config.name` à une clé de configuration.\n\n```html\n<ui-component name=\"card\" path=\"person.name\" config=\"title:Profile\"></ui-component>\n\n<script>\n\tCOMPONENT('card', 'title:Untitled', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<h3><ui-bind path=\"@config.title\" config=\"text\"></ui-bind></h3>'\n\t\t\t\t+ '<p><ui-bind path=\"@\" config=\"text\"></ui-bind></p>'\n\t\t\t\t+ '<small><ui-bind path=\"@visits\" config=\"text\"></ui-bind></small>');\n\t\t\tself.data('visits', 1);\n\t\t};\n\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('person.name', 'Ana');\n</script>\n```\n\n## Déclarer des dépendances\n\nLe quatrième argument de `COMPONENT()` liste ce qui doit être disponible au démarrage du composant. `make` attend que tout soit prêt.\n\n| Élément | Description |\n| --- | --- |\n| Une fonction | Reçoit une fonction `next` à appeler quand elle a terminé. |\n| Une URL | Un script ou une feuille de style importé une seule fois. |\n| `@name` | Un autre composant, téléchargé s'il est absent. |\n\n```html\n<ui-component name=\"chart\" path=\"stats\"></ui-component>\n\n<script>\n\tCOMPONENT('chart', function(self) {\n\t\tself.make = function() {\n\t\t\tconsole.log('make', window.chartlib);\n\t\t};\n\t}, [function(next) {\n\t\tsetTimeout(function() {\n\t\t\twindow.chartlib = 'loaded';\n\t\t\tnext();\n\t\t}, 100);\n\t}]);\n</script>\n```\n\n## Travailler dans un scope\n\nQuand un composant se trouve dans un [scope](../scopes/), `self.makepath()` remplace `?` par le path du scope. `self.GET()` et `self.SET()` le font pour toi.\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-component name=\"total\" path=\"?.items\" config=\"target:?.sum\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('total', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tvar sum = (value || []).reduce((a, b) => a + b, 0);\n\t\t\tself.SET(config.target, sum);\n\t\t\tconsole.log(self.path, self.makepath(config.target), self.GET(config.target));\n\t\t};\n\t});\n\n\tSET('order.items', [10, 20]);\n</script>\n```\n\n## Observer d'autres données\n\n| Méthode | Description |\n| --- | --- |\n| `self.watch(path, fn, [init])` | Observe un path tant que le composant existe. |\n| `self.on(name, fn)` | Écoute un événement global tant que le composant existe. |\n| `self.datasource(path, fn)` | Observe un path et appelle la fonction avec la valeur actuelle une fois la configuration chargée. |\n| `self.command(name, fn)` | Enregistre une commande pour [CMD()](../../reference/globals/). |\n| `self.event(type, [selector], fn)` | Ajoute un écouteur d'événement DOM à l'élément. |\n\n```html\n<ui-component name=\"filter\" path=\"query\" config=\"source:shop.colors\"></ui-component>\n\n<script>\n\tCOMPONENT('filter', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.watch('shop.total', (path, value) => console.log('watch', value));\n\t\t\tself.on('reload', reason => console.log('event', reason));\n\t\t\tself.datasource(config.source, (path, value, type) => console.log('datasource', value, type));\n\t\t};\n\t});\n\n\tSET('shop.colors', ['red']);\n\n\tON('ready', function() {\n\t\tSET('shop.total', 5);            // watch 5\n\t\tEMIT('reload', 'manual');        // event manual\n\t\tSET('shop.colors', ['blue']);    // datasource [\"blue\"] 1\n\t});\n\t// datasource [\"red\"] 0\n</script>\n```\n\n## Limiter les exécutions du setter\n\n| Méthode | Effet |\n| --- | --- |\n| `self.bindchanges()` | Ignore le setter quand la valeur est identique à la précédente. |\n| `self.bindexact()` | Ignore le setter pour les changements apportés aux paths situés sous le path du composant. |\n\n```html\n<ui-component name=\"once\" path=\"a.b\"></ui-component>\n\n<script>\n\tCOMPONENT('once', function(self) {\n\n\t\tself.bindchanges();\n\t\tself.bindexact();\n\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log('setter', JSON.stringify(value), type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('a.b', { c: 1 });     // setter {\"c\":1} 1\n\t\tSET('a.b', { c: 1 });     // (same value, skipped)\n\t\tSET('a.b.c', 2);          // (nested path, skipped)\n\t});\n\t// setter undefined 0\n</script>\n```\n\n## Manipuler l'élément\n\n| Membre | Description |\n| --- | --- |\n| `self.element` | L'élément, sous forme d'objet jQuery. |\n| `self.find(selector)` | Trouve des éléments dans le composant. |\n| `self.html(value)` | Remplace le contenu par du HTML. |\n| `self.text(value)` | Remplace le contenu par du texte. |\n| `self.aclass(name)` | Ajoute une classe CSS. |\n| `self.css(name, value)` | Définit une propriété CSS. |\n\nLa référence [Component](../../reference/component/) liste toutes les méthodes.\n\n## Un composant complet\n\nCe contrôle de notation combine la configuration, le rendu, la saisie de l'utilisateur et une liaison sur le même path.\n\n```html\n<ui-component name=\"rating\" path=\"review.stars\" config=\"max:5;icon:*\"></ui-component>\n<p><ui-bind path=\"review.stars\" config=\"text:value + ' of 5'\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('rating', 'max:5;icon:#', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t\tself.event('click', 'span', function() {\n\t\t\t\tself.bind('@touched @modified @setter', +this.getAttribute('data-value'));\n\t\t\t});\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\t!init && self.refresh();\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tvar builder = [];\n\t\t\tfor (var i = 1; i <= config.max; i++)\n\t\t\t\tbuilder.push('<span data-value=\"' + i + '\" class=\"' + (i <= value ? 'on' : '') + '\">' + config.icon + '</span>');\n\t\t\tself.html(builder.join(''));\n\t\t};\n\t});\n\n\tSET('review.stars', 3);\n</script>\n```\n\nLe contrôle démarre avec trois étoiles actives et le texte `3 of 5`. Un clic sur la cinquième étoile stocke `5` et met à jour le texte.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTR1eM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/creating-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Creare componenti","summary":"Dichiara i tuoi componenti, gestisci il loro ciclo di vita e scambia dati con il modello.","markdown":"---\ntitle: Creare componenti\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/creating-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Creare componenti\n\n> Dichiara i tuoi componenti, gestisci il loro ciclo di vita e scambia dati con il modello.\n\nDichiari un componente una sola volta con [COMPONENT()](../../reference/globals/) e poi lo inserisci in tutte le pagine che ti servono. Questa guida costruisce l'API passo dopo passo. Per inserire componenti esistenti, leggi [Usare i componenti](../using-components/).\n\n## Dichiarare un componente\n\n```html\n<ui-component name=\"hello\" path=\"visitor\"></ui-component>\n\n<script>\n\tCOMPONENT('hello', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text('Hello ' + (value || 'stranger'));\n\t\t};\n\t});\n\n\tSET('visitor', 'Ana');\n</script>\n```\n\nL'elemento viene visualizzato come `<ui-component name=\"hello\" path=\"visitor\" class=\"ui-hello\">Hello Ana</ui-component>`.\n\n`COMPONENT(name, [config], declaration, [dependencies])` accetta questi argomenti:\n\n| Argomento | Descrizione |\n| --- | --- |\n| `name` | Il nome del componente. |\n| `config` | La configurazione predefinita, come stringa del tipo `'size:1;color:red'` o come oggetto. |\n| `declaration` | Una funzione eseguita per ogni istanza. |\n| `dependencies` | Un array di ciò che deve essere caricato prima. |\n\nLa dichiarazione riceve tre argomenti:\n\n| Argomento | Descrizione |\n| --- | --- |\n| `self` | L'istanza del componente. |\n| `config` | La configurazione di questa istanza. |\n| `cls` | Un nome di classe CSS composto da `ui-` e dal nome del componente. |\n\n## Il ciclo di vita\n\nDefinisci su `self` le funzioni seguenti e la libreria le chiama in quest'ordine. Sono tutte facoltative.\n\n```html\n<ui-component name=\"life\" path=\"demo.value\" config=\"size:3\"></ui-component>\n\n<script>\n\tCOMPONENT('life', 'size:1', function(self, config, cls) {\n\n\t\tconsole.log('1 declaration', cls, config.size);\n\n\t\tself.init = () => console.log('2 init');\n\t\tself.make = () => console.log('3 make');\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'size')\n\t\t\t\tconsole.log('4 configure', key, value, init);\n\t\t};\n\n\t\tself.setter = (value, path, type) => console.log('5 setter', value, path, type);\n\n\t\tself.validate = function(value) {\n\t\t\tconsole.log('6 validate', value);\n\t\t\treturn true;\n\t\t};\n\n\t\tself.state = (type, what) => console.log('7 state', type, what);\n\t\tself.done = () => console.log('8 done');\n\t\tself.destroy = () => console.log('9 destroy');\n\t});\n\n\tSET('demo.value', 'A');\n\n\tsetTimeout(() => FIND('life').remove(), 600);\n</script>\n```\n\n| Funzione | Quando viene eseguita |\n| --- | --- |\n| `init()` | Una volta per ogni nome di componente, con la prima istanza. |\n| `make()` | Quando l'istanza viene creata. Costruisci qui il contenuto. |\n| `configure(key, value, init, prev)` | Per ogni chiave di configurazione, e di nuovo ogni volta che una chiave cambia. |\n| `setter(value, path, type)` | Con il valore iniziale e ogni volta che il valore cambia. |\n| `validate(value)` | Dopo il setter. Restituisce `true` per un valore valido. |\n| `state(type, what)` | Quando lo stato del componente cambia. |\n| `done()` | Poco dopo che il componente è pronto. |\n| `destroy()` | Quando il componente viene rimosso. |\n\nDurante l'inizializzazione, `configure` viene eseguita anche per le chiavi di stato `modified`, `touched` e `invalid`, con `init` impostato su `true`.\n\n## Ricevere i dati\n\n`self.setter` riceve il valore, il path che è cambiato e il tipo di modifica.\n\n```html\n<ui-component name=\"spy\" path=\"demo.value\" default=\"'initial'\"></ui-component>\n\n<script>\n\tCOMPONENT('spy', function(self) {\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log(value, type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('demo.value', 'manual');        // manual 1\n\t\tFIND('spy').set('input', 2);        // input 2\n\t\tDEFAULT('demo.value');              // initial 3\n\t});\n\t// initial 0\n</script>\n```\n\n| Tipo | Significato |\n| --- | --- |\n| `0` | Il valore iniziale. |\n| `1` | Modificato dal codice. |\n| `2` | Modificato dall'input dell'utente. |\n| `3` | Impostato sul valore predefinito. |\n\n## Leggere la configurazione\n\nL'oggetto `config` contiene sempre i valori correnti. Usa `self.configure` per reagire alle modifiche e controlla l'argomento `init` per distinguere la prima esecuzione dalle successive. `self.refresh()` esegue di nuovo il setter con il valore corrente.\n\n```html\n<ui-component name=\"meter\" path=\"level\" config=\"max:10;color:green\"></ui-component>\n\n<script>\n\tCOMPONENT('meter', 'max:100;color:gray', function(self, config) {\n\n\t\tself.configure = function(key, value, init, prev) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'color':\n\t\t\t\t\tself.css('color', value);\n\t\t\t\t\t!init && console.log('color', prev, '->', value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'max':\n\t\t\t\t\t!init && self.refresh();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' / ' + config.max);\n\t\t};\n\t});\n\n\tSET('level', 7);\n\n\tON('ready', function() {\n\t\tFIND('meter').reconfigure('color:red;max:20');\n\t\t// color green -> red\n\t});\n</script>\n```\n\nDopo la chiamata a `reconfigure()`, l'elemento visualizza `7 / 20` in rosso.\n\n## Scrivere i dati\n\n| Metodo | Descrizione |\n| --- | --- |\n| `self.get()` | Legge il valore nel path del componente. |\n| `self.set(value, [type])` | Scrive il valore e contrassegna il componente come modificato. Viene eseguito anche il setter. |\n| `self.modify(value, [type])` | Esegue i parser, contrassegna il componente come toccato e scrive il valore con il tipo `2`. |\n| `self.getter(value)` | Esegue i parser, contrassegna il componente come toccato e scrive il valore se è cambiato. |\n| `self.bind(flags, value)` | Scrive il valore senza eseguire il setter e applica i flag. |\n| `self.skip()` | Salta la prossima esecuzione del setter. |\n\nI flag di `self.bind()` sono `@touched`, `@modified`, `@reset`, `@validate` e `@setter`. L'ultimo fa comunque eseguire il setter.\n\n```html\n<ui-component name=\"stepper\" path=\"qty\"></ui-component>\n\n<script>\n\tCOMPONENT('stepper', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button>-</button> <b></b> <button>+</button>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar diff = this.textContent === '+' ? 1 : -1;\n\t\t\t\tself.bind('@touched @modified', (self.get() || 0) + diff);\n\t\t\t\tself.find('b').text(self.get());\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tconsole.log('setter', value);\n\t\t\tself.find('b').text(value);\n\t\t};\n\t});\n\n\tSET('qty', 1);    // setter 1\n</script>\n```\n\nFacendo clic due volte su `+`, `qty` arriva a `3` e il setter non viene eseguito per questi clic. Un successivo `SET('qty', 9)` lo esegue come di consueto.\n\n## Collegare un campo di testo\n\nUn `<input>`, `<textarea>` o `<select>` con l'attributo `data-jc-bind` funziona senza altro codice: la libreria copia il valore in entrambe le direzioni e le caselle di controllo scrivono `true` o `false`. Un `formatter` cambia il modo in cui il valore viene visualizzato. L'impostazione `type:number` fa sì che la libreria memorizzi un numero anziché una stringa.\n\n```html\n<ui-component name=\"price\" path=\"item.price\" config=\"type:number\"></ui-component>\n\n<script>\n\tCOMPONENT('price', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn value == null ? '' : value.format(2);\n\t\t});\n\t});\n\n\tSET('item.price', 5);\n</script>\n```\n\nIl campo mostra `5.00`. Digitando `12.5` viene memorizzato il numero `12.5`.\n\nQueste chiavi di configurazione stabiliscono quando un campo scrive il proprio valore:\n\n| Chiave | Effetto |\n| --- | --- |\n| `$delay:500` | Attende questo numero di millisecondi dopo l'ultima pressione di un tasto. Il valore predefinito è `200`. |\n| `$realtime:false` | Scrive il valore quando il campo perde il focus. |\n\n```html\n<ui-component id=\"slow\" name=\"box\" path=\"form.slow\" config=\"$delay:500\"></ui-component>\n<ui-component id=\"blur\" name=\"box\" path=\"form.blur\" config=\"$realtime:false\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n## Creare un campo personalizzato\n\nPer i tuoi controlli, chiama `self.getter()` con il nuovo valore. Un `parser` converte ciò che l'utente ha inserito nel valore memorizzato e un `formatter` fa l'opposto. Entrambi ricevono il path, il valore, il tipo e il formato.\n\n```html\n<ui-component name=\"tags\" path=\"post.tags\"></ui-component>\n\n<script>\n\tCOMPONENT('tags', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" />');\n\t\t\tself.event('change', 'input', function() {\n\t\t\t\tself.getter(this.value);\n\t\t\t});\n\t\t};\n\n\t\tself.parser(function(path, value) {\n\t\t\treturn value.split(',').map(tag => tag.trim());\n\t\t});\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn (value || []).join(', ');\n\t\t});\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('input').val(self.formatter(value));\n\t\t};\n\t});\n\n\tSET('post.tags', ['a', 'b']);\n</script>\n```\n\nIl campo mostra `a, b`. Inserendo `x, y ,z` viene memorizzato `[\"x\",\"y\",\"z\"]`.\n\n## Validare il valore\n\n`self.validate` restituisce `true` per un valore valido. `self.isInvalid()` restituisce `true` quando il valore non è valido e l'utente ha già toccato il componente: è il momento giusto per mostrare un errore.\n\n```html\n<ui-component id=\"mail\" name=\"email\" path=\"user.email\"></ui-component>\n\n<script>\n\tCOMPONENT('email', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" /><small>Enter a valid address</small>');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn (value || '').isEmail();\n\t\t};\n\n\t\tself.state = function() {\n\t\t\tself.find('small').tclass('hidden', !self.isInvalid());\n\t\t};\n\t});\n</script>\n```\n\nIl messaggio resta nascosto con il modulo vuoto, compare dopo `nope` e scompare di nuovo dopo `a@b.io`. [Moduli e validazione](../forms/) tratta i moduli completi.\n\n## Conservare dati interni\n\n`self.data(key, value)` memorizza un valore all'interno del componente. Un'associazione dentro il componente lo legge con un path che inizia con `@`. `@` da solo è il valore del componente e `@config.name` è una chiave di configurazione.\n\n```html\n<ui-component name=\"card\" path=\"person.name\" config=\"title:Profile\"></ui-component>\n\n<script>\n\tCOMPONENT('card', 'title:Untitled', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<h3><ui-bind path=\"@config.title\" config=\"text\"></ui-bind></h3>'\n\t\t\t\t+ '<p><ui-bind path=\"@\" config=\"text\"></ui-bind></p>'\n\t\t\t\t+ '<small><ui-bind path=\"@visits\" config=\"text\"></ui-bind></small>');\n\t\t\tself.data('visits', 1);\n\t\t};\n\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('person.name', 'Ana');\n</script>\n```\n\n## Dichiarare le dipendenze\n\nIl quarto argomento di `COMPONENT()` elenca ciò che deve essere disponibile all'avvio del componente. `make` attende che lo siano tutte.\n\n| Voce | Descrizione |\n| --- | --- |\n| Una funzione | Riceve una funzione `next` da chiamare al termine. |\n| Un URL | Uno script o un foglio di stile importato una sola volta. |\n| `@name` | Un altro componente, scaricato se manca. |\n\n```html\n<ui-component name=\"chart\" path=\"stats\"></ui-component>\n\n<script>\n\tCOMPONENT('chart', function(self) {\n\t\tself.make = function() {\n\t\t\tconsole.log('make', window.chartlib);\n\t\t};\n\t}, [function(next) {\n\t\tsetTimeout(function() {\n\t\t\twindow.chartlib = 'loaded';\n\t\t\tnext();\n\t\t}, 100);\n\t}]);\n</script>\n```\n\n## Lavorare all'interno di uno scope\n\nQuando un componente si trova all'interno di uno [scope](../scopes/), `self.makepath()` trasforma `?` nel path dello scope. `self.GET()` e `self.SET()` lo fanno al posto tuo.\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-component name=\"total\" path=\"?.items\" config=\"target:?.sum\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('total', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tvar sum = (value || []).reduce((a, b) => a + b, 0);\n\t\t\tself.SET(config.target, sum);\n\t\t\tconsole.log(self.path, self.makepath(config.target), self.GET(config.target));\n\t\t};\n\t});\n\n\tSET('order.items', [10, 20]);\n</script>\n```\n\n## Osservare altri dati\n\n| Metodo | Descrizione |\n| --- | --- |\n| `self.watch(path, fn, [init])` | Osserva un path finché il componente esiste. |\n| `self.on(name, fn)` | Ascolta un evento globale finché il componente esiste. |\n| `self.datasource(path, fn)` | Osserva un path e chiama la funzione con il valore corrente una volta caricata la configurazione. |\n| `self.command(name, fn)` | Registra un comando per [CMD()](../../reference/globals/). |\n| `self.event(type, [selector], fn)` | Aggiunge all'elemento un listener di eventi DOM. |\n\n```html\n<ui-component name=\"filter\" path=\"query\" config=\"source:shop.colors\"></ui-component>\n\n<script>\n\tCOMPONENT('filter', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.watch('shop.total', (path, value) => console.log('watch', value));\n\t\t\tself.on('reload', reason => console.log('event', reason));\n\t\t\tself.datasource(config.source, (path, value, type) => console.log('datasource', value, type));\n\t\t};\n\t});\n\n\tSET('shop.colors', ['red']);\n\n\tON('ready', function() {\n\t\tSET('shop.total', 5);            // watch 5\n\t\tEMIT('reload', 'manual');        // event manual\n\t\tSET('shop.colors', ['blue']);    // datasource [\"blue\"] 1\n\t});\n\t// datasource [\"red\"] 0\n</script>\n```\n\n## Limitare quando viene eseguito il setter\n\n| Metodo | Effetto |\n| --- | --- |\n| `self.bindchanges()` | Salta il setter quando il valore è uguale all'ultimo. |\n| `self.bindexact()` | Salta il setter per le modifiche ai path sotto il path del componente. |\n\n```html\n<ui-component name=\"once\" path=\"a.b\"></ui-component>\n\n<script>\n\tCOMPONENT('once', function(self) {\n\n\t\tself.bindchanges();\n\t\tself.bindexact();\n\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log('setter', JSON.stringify(value), type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('a.b', { c: 1 });     // setter {\"c\":1} 1\n\t\tSET('a.b', { c: 1 });     // (same value, skipped)\n\t\tSET('a.b.c', 2);          // (nested path, skipped)\n\t});\n\t// setter undefined 0\n</script>\n```\n\n## Lavorare con l'elemento\n\n| Membro | Descrizione |\n| --- | --- |\n| `self.element` | L'elemento, come oggetto jQuery. |\n| `self.find(selector)` | Trova elementi all'interno del componente. |\n| `self.html(value)` | Sostituisce il contenuto con HTML. |\n| `self.text(value)` | Sostituisce il contenuto con testo. |\n| `self.aclass(name)` | Aggiunge una classe CSS. |\n| `self.css(name, value)` | Imposta una proprietà CSS. |\n\nIl riferimento [Component](../../reference/component/) elenca tutti i metodi.\n\n## Un componente completo\n\nQuesto controllo di valutazione combina configurazione, rendering, input dell'utente e un'associazione sullo stesso path.\n\n```html\n<ui-component name=\"rating\" path=\"review.stars\" config=\"max:5;icon:*\"></ui-component>\n<p><ui-bind path=\"review.stars\" config=\"text:value + ' of 5'\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('rating', 'max:5;icon:#', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t\tself.event('click', 'span', function() {\n\t\t\t\tself.bind('@touched @modified @setter', +this.getAttribute('data-value'));\n\t\t\t});\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\t!init && self.refresh();\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tvar builder = [];\n\t\t\tfor (var i = 1; i <= config.max; i++)\n\t\t\t\tbuilder.push('<span data-value=\"' + i + '\" class=\"' + (i <= value ? 'on' : '') + '\">' + config.icon + '</span>');\n\t\t\tself.html(builder.join(''));\n\t\t};\n\t});\n\n\tSET('review.stars', 3);\n</script>\n```\n\nIl controllo parte con tre stelle attive e il testo `3 of 5`. Facendo clic sulla quinta stella viene memorizzato `5` e il testo si aggiorna.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTR1eM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/creating-components/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Vytváranie komponentov","summary":"Deklaruj vlastné komponenty, spravuj ich životný cyklus a vymieňaj si dáta s modelom.","markdown":"---\ntitle: \"Vytváranie komponentov\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/creating-components/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Vytváranie komponentov\n\n> Deklaruj vlastné komponenty, spravuj ich životný cyklus a vymieňaj si dáta s modelom.\n\nKomponent deklaruješ raz pomocou [COMPONENT()](../../reference/globals/) a potom ho umiestniš na toľko stránok, koľko potrebuješ. Tento návod buduje API krok za krokom. Ak chceš umiestniť existujúce komponenty, prečítaj si [Používanie komponentov](../using-components/).\n\n## Deklaruj komponent\n\n```html\n<ui-component name=\"hello\" path=\"visitor\"></ui-component>\n\n<script>\n\tCOMPONENT('hello', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text('Hello ' + (value || 'stranger'));\n\t\t};\n\t});\n\n\tSET('visitor', 'Ana');\n</script>\n```\n\nElement sa vykreslí ako `<ui-component name=\"hello\" path=\"visitor\" class=\"ui-hello\">Hello Ana</ui-component>`.\n\n`COMPONENT(name, [config], declaration, [dependencies])` prijíma tieto argumenty:\n\n| Argument | Popis |\n| --- | --- |\n| `name` | Názov komponentu. |\n| `config` | Predvolená konfigurácia ako reťazec, napríklad `'size:1;color:red'`, alebo ako objekt. |\n| `declaration` | Funkcia, ktorá sa spustí pre každú inštanciu. |\n| `dependencies` | Pole toho, čo sa musí načítať ako prvé. |\n\nDeklarácia dostáva tri argumenty:\n\n| Argument | Popis |\n| --- | --- |\n| `self` | Inštancia komponentu. |\n| `config` | Konfigurácia tejto inštancie. |\n| `cls` | Názov CSS triedy zložený z `ui-` a názvu komponentu. |\n\n## Životný cyklus\n\nFunkcie uvedené nižšie definuješ na `self` a knižnica ich volá v tomto poradí. Všetky sú voliteľné.\n\n```html\n<ui-component name=\"life\" path=\"demo.value\" config=\"size:3\"></ui-component>\n\n<script>\n\tCOMPONENT('life', 'size:1', function(self, config, cls) {\n\n\t\tconsole.log('1 declaration', cls, config.size);\n\n\t\tself.init = () => console.log('2 init');\n\t\tself.make = () => console.log('3 make');\n\n\t\tself.configure = function(key, value, init) {\n\t\t\tif (key === 'size')\n\t\t\t\tconsole.log('4 configure', key, value, init);\n\t\t};\n\n\t\tself.setter = (value, path, type) => console.log('5 setter', value, path, type);\n\n\t\tself.validate = function(value) {\n\t\t\tconsole.log('6 validate', value);\n\t\t\treturn true;\n\t\t};\n\n\t\tself.state = (type, what) => console.log('7 state', type, what);\n\t\tself.done = () => console.log('8 done');\n\t\tself.destroy = () => console.log('9 destroy');\n\t});\n\n\tSET('demo.value', 'A');\n\n\tsetTimeout(() => FIND('life').remove(), 600);\n</script>\n```\n\n| Funkcia | Kedy sa spustí |\n| --- | --- |\n| `init()` | Raz pre každý názov komponentu, pri prvej inštancii. |\n| `make()` | Pri vytvorení inštancie. Tu vytvor obsah. |\n| `configure(key, value, init, prev)` | Pre každý konfiguračný kľúč a znova pri každej zmene kľúča. |\n| `setter(value, path, type)` | S počiatočnou hodnotou a pri každej zmene hodnoty. |\n| `validate(value)` | Po setteri. Pre platnú hodnotu vracia `true`. |\n| `state(type, what)` | Keď sa zmení stav komponentu. |\n| `done()` | Krátko po tom, čo je komponent pripravený. |\n| `destroy()` | Keď sa komponent odstráni. |\n\nPočas inicializácie sa `configure` spúšťa aj pre stavové kľúče `modified`, `touched` a `invalid`, pričom `init` má hodnotu `true`.\n\n## Prijímaj dáta\n\n`self.setter` dostáva hodnotu, path, ktorý sa zmenil, a typ zmeny.\n\n```html\n<ui-component name=\"spy\" path=\"demo.value\" default=\"'initial'\"></ui-component>\n\n<script>\n\tCOMPONENT('spy', function(self) {\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log(value, type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('demo.value', 'manual');        // manual 1\n\t\tFIND('spy').set('input', 2);        // input 2\n\t\tDEFAULT('demo.value');              // initial 3\n\t});\n\t// initial 0\n</script>\n```\n\n| Typ | Význam |\n| --- | --- |\n| `0` | Počiatočná hodnota. |\n| `1` | Zmenené kódom. |\n| `2` | Zmenené vstupom používateľa. |\n| `3` | Nastavené na predvolenú hodnotu. |\n\n## Čítaj konfiguráciu\n\nObjekt `config` vždy obsahuje aktuálne hodnoty. Na zmeny reaguj pomocou `self.configure` a argumentom `init` odlíš prvé spustenie od neskorších. `self.refresh()` znova spustí setter s aktuálnou hodnotou.\n\n```html\n<ui-component name=\"meter\" path=\"level\" config=\"max:10;color:green\"></ui-component>\n\n<script>\n\tCOMPONENT('meter', 'max:100;color:gray', function(self, config) {\n\n\t\tself.configure = function(key, value, init, prev) {\n\t\t\tswitch (key) {\n\t\t\t\tcase 'color':\n\t\t\t\t\tself.css('color', value);\n\t\t\t\t\t!init && console.log('color', prev, '->', value);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'max':\n\t\t\t\t\t!init && self.refresh();\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tself.text(value + ' / ' + config.max);\n\t\t};\n\t});\n\n\tSET('level', 7);\n\n\tON('ready', function() {\n\t\tFIND('meter').reconfigure('color:red;max:20');\n\t\t// color green -> red\n\t});\n</script>\n```\n\nPo volaní `reconfigure()` element vykreslí `7 / 20` červenou farbou.\n\n## Zapisuj dáta\n\n| Metóda | Popis |\n| --- | --- |\n| `self.get()` | Prečíta hodnotu na path komponentu. |\n| `self.set(value, [type])` | Zapíše hodnotu a označí komponent ako zmenený. Spustí sa aj setter. |\n| `self.modify(value, [type])` | Spustí parsery, označí komponent ako dotknutý a zapíše hodnotu s typom `2`. |\n| `self.getter(value)` | Spustí parsery, označí komponent ako dotknutý a zapíše hodnotu, ak sa zmenila. |\n| `self.bind(flags, value)` | Zapíše hodnotu bez spustenia settera a použije flagy. |\n| `self.skip()` | Preskočí nasledujúce spustenie settera. |\n\nFlagy metódy `self.bind()` sú `@touched`, `@modified`, `@reset`, `@validate` a `@setter`. Posledný z nich setter napokon predsa len spustí.\n\n```html\n<ui-component name=\"stepper\" path=\"qty\"></ui-component>\n\n<script>\n\tCOMPONENT('stepper', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<button>-</button> <b></b> <button>+</button>');\n\t\t\tself.event('click', 'button', function() {\n\t\t\t\tvar diff = this.textContent === '+' ? 1 : -1;\n\t\t\t\tself.bind('@touched @modified', (self.get() || 0) + diff);\n\t\t\t\tself.find('b').text(self.get());\n\t\t\t});\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tconsole.log('setter', value);\n\t\t\tself.find('b').text(value);\n\t\t};\n\t});\n\n\tSET('qty', 1);    // setter 1\n</script>\n```\n\nPo dvoch kliknutiach na `+` má `qty` hodnotu `3` a setter sa pri týchto kliknutiach nespustí. Neskoršie `SET('qty', 9)` ho spustí ako obvykle.\n\n## Pripoj textový vstup\n\nElement `<input>`, `<textarea>` alebo `<select>` s atribútom `data-jc-bind` funguje bez ďalšieho kódu: knižnica kopíruje hodnotu oboma smermi a začiarkavacie políčka zapisujú `true` alebo `false`. Funkcia `formatter` mení spôsob zobrazenia hodnoty. Nastavenie `type:number` zaistí, že knižnica uloží číslo namiesto reťazca.\n\n```html\n<ui-component name=\"price\" path=\"item.price\" config=\"type:number\"></ui-component>\n\n<script>\n\tCOMPONENT('price', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn value == null ? '' : value.format(2);\n\t\t});\n\t});\n\n\tSET('item.price', 5);\n</script>\n```\n\nVstup zobrazí `5.00`. Keď napíšeš `12.5`, uloží sa číslo `12.5`.\n\nTieto konfiguračné kľúče určujú, kedy vstup zapíše svoju hodnotu:\n\n| Kľúč | Účinok |\n| --- | --- |\n| `$delay:500` | Po poslednom stlačení klávesu počká zadaný počet milisekúnd. Predvolene `200`. |\n| `$realtime:false` | Zapíše hodnotu, keď vstup stratí fokus. |\n\n```html\n<ui-component id=\"slow\" name=\"box\" path=\"form.slow\" config=\"$delay:500\"></ui-component>\n<ui-component id=\"blur\" name=\"box\" path=\"form.blur\" config=\"$realtime:false\"></ui-component>\n\n<script>\n\tCOMPONENT('box', function(self) {\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" />');\n\t\t};\n\t});\n</script>\n```\n\n## Vytvor vlastný vstup\n\nVo vlastných ovládacích prvkoch zavolaj `self.getter()` s novou hodnotou. Funkcia `parser` prevedie to, čo používateľ zadal, na uloženú hodnotu a `formatter` robí opak. Obe dostávajú path, hodnotu, typ a formát.\n\n```html\n<ui-component name=\"tags\" path=\"post.tags\"></ui-component>\n\n<script>\n\tCOMPONENT('tags', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" />');\n\t\t\tself.event('change', 'input', function() {\n\t\t\t\tself.getter(this.value);\n\t\t\t});\n\t\t};\n\n\t\tself.parser(function(path, value) {\n\t\t\treturn value.split(',').map(tag => tag.trim());\n\t\t});\n\n\t\tself.formatter(function(path, value) {\n\t\t\treturn (value || []).join(', ');\n\t\t});\n\n\t\tself.setter = function(value) {\n\t\t\tself.find('input').val(self.formatter(value));\n\t\t};\n\t});\n\n\tSET('post.tags', ['a', 'b']);\n</script>\n```\n\nVstup zobrazí `a, b`. Keď zadáš `x, y ,z`, uloží sa `[\"x\",\"y\",\"z\"]`.\n\n## Validuj hodnotu\n\n`self.validate` vracia `true` pre platnú hodnotu. `self.isInvalid()` vracia `true`, keď je hodnota neplatná a používateľ už s komponentom pracoval, čo je správny moment na zobrazenie chyby.\n\n```html\n<ui-component id=\"mail\" name=\"email\" path=\"user.email\"></ui-component>\n\n<script>\n\tCOMPONENT('email', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<input type=\"text\" data-jc-bind=\"\" /><small>Enter a valid address</small>');\n\t\t};\n\n\t\tself.validate = function(value) {\n\t\t\treturn (value || '').isEmail();\n\t\t};\n\n\t\tself.state = function() {\n\t\t\tself.find('small').tclass('hidden', !self.isInvalid());\n\t\t};\n\t});\n</script>\n```\n\nSpráva zostáva pri prázdnom formulári skrytá, objaví sa po zadaní `nope` a po zadaní `a@b.io` opäť zmizne. Celým formulárom sa venuje časť [Formuláre a validácia](../forms/).\n\n## Uchovávaj interné dáta\n\n`self.data(key, value)` uloží hodnotu vnútri komponentu. Väzba vnútri komponentu ju číta cez path, ktorý začína znakom `@`. Samotný `@` je hodnota komponentu a `@config.name` je konfiguračný kľúč.\n\n```html\n<ui-component name=\"card\" path=\"person.name\" config=\"title:Profile\"></ui-component>\n\n<script>\n\tCOMPONENT('card', 'title:Untitled', function(self) {\n\n\t\tself.make = function() {\n\t\t\tself.html('<h3><ui-bind path=\"@config.title\" config=\"text\"></ui-bind></h3>'\n\t\t\t\t+ '<p><ui-bind path=\"@\" config=\"text\"></ui-bind></p>'\n\t\t\t\t+ '<small><ui-bind path=\"@visits\" config=\"text\"></ui-bind></small>');\n\t\t\tself.data('visits', 1);\n\t\t};\n\n\t\tself.setter = NOOP;\n\t});\n\n\tSET('person.name', 'Ana');\n</script>\n```\n\n## Deklaruj závislosti\n\nŠtvrtý argument `COMPONENT()` uvádza, čo musí byť dostupné pri spustení komponentu. `make` čaká na všetky tieto položky.\n\n| Položka | Popis |\n| --- | --- |\n| Funkcia | Dostane funkciu `next`, ktorú zavolá po dokončení. |\n| URL | Skript alebo štýl, ktorý sa importuje raz. |\n| `@name` | Iný komponent, ktorý sa stiahne, ak chýba. |\n\n```html\n<ui-component name=\"chart\" path=\"stats\"></ui-component>\n\n<script>\n\tCOMPONENT('chart', function(self) {\n\t\tself.make = function() {\n\t\t\tconsole.log('make', window.chartlib);\n\t\t};\n\t}, [function(next) {\n\t\tsetTimeout(function() {\n\t\t\twindow.chartlib = 'loaded';\n\t\t\tnext();\n\t\t}, 100);\n\t}]);\n</script>\n```\n\n## Práca vnútri scope\n\nKeď je komponent vnútri [scope](../scopes/), `self.makepath()` premení `?` na path scope. `self.GET()` a `self.SET()` to urobia za teba.\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-component name=\"total\" path=\"?.items\" config=\"target:?.sum\"></ui-component>\n</ui-plugin>\n\n<script>\n\tCOMPONENT('total', function(self, config) {\n\t\tself.setter = function(value) {\n\t\t\tvar sum = (value || []).reduce((a, b) => a + b, 0);\n\t\t\tself.SET(config.target, sum);\n\t\t\tconsole.log(self.path, self.makepath(config.target), self.GET(config.target));\n\t\t};\n\t});\n\n\tSET('order.items', [10, 20]);\n</script>\n```\n\n## Sleduj iné dáta\n\n| Metóda | Popis |\n| --- | --- |\n| `self.watch(path, fn, [init])` | Sleduje path, kým komponent existuje. |\n| `self.on(name, fn)` | Počúva globálnu udalosť, kým komponent existuje. |\n| `self.datasource(path, fn)` | Sleduje path a po načítaní konfigurácie zavolá funkciu s aktuálnou hodnotou. |\n| `self.command(name, fn)` | Zaregistruje príkaz pre [CMD()](../../reference/globals/). |\n| `self.event(type, [selector], fn)` | Pridá na element poslucháča udalosti DOM. |\n\n```html\n<ui-component name=\"filter\" path=\"query\" config=\"source:shop.colors\"></ui-component>\n\n<script>\n\tCOMPONENT('filter', function(self, config) {\n\n\t\tself.make = function() {\n\t\t\tself.watch('shop.total', (path, value) => console.log('watch', value));\n\t\t\tself.on('reload', reason => console.log('event', reason));\n\t\t\tself.datasource(config.source, (path, value, type) => console.log('datasource', value, type));\n\t\t};\n\t});\n\n\tSET('shop.colors', ['red']);\n\n\tON('ready', function() {\n\t\tSET('shop.total', 5);            // watch 5\n\t\tEMIT('reload', 'manual');        // event manual\n\t\tSET('shop.colors', ['blue']);    // datasource [\"blue\"] 1\n\t});\n\t// datasource [\"red\"] 0\n</script>\n```\n\n## Obmedz spúšťanie settera\n\n| Metóda | Účinok |\n| --- | --- |\n| `self.bindchanges()` | Preskočí setter, keď je hodnota rovnaká ako posledná. |\n| `self.bindexact()` | Preskočí setter pri zmenách paths pod path komponentu. |\n\n```html\n<ui-component name=\"once\" path=\"a.b\"></ui-component>\n\n<script>\n\tCOMPONENT('once', function(self) {\n\n\t\tself.bindchanges();\n\t\tself.bindexact();\n\n\t\tself.setter = function(value, path, type) {\n\t\t\tconsole.log('setter', JSON.stringify(value), type);\n\t\t};\n\t});\n\n\tON('ready', function() {\n\t\tSET('a.b', { c: 1 });     // setter {\"c\":1} 1\n\t\tSET('a.b', { c: 1 });     // (same value, skipped)\n\t\tSET('a.b.c', 2);          // (nested path, skipped)\n\t});\n\t// setter undefined 0\n</script>\n```\n\n## Práca s elementom\n\n| Člen | Popis |\n| --- | --- |\n| `self.element` | Element ako objekt jQuery. |\n| `self.find(selector)` | Nájde elementy vnútri komponentu. |\n| `self.html(value)` | Nahradí obsah kódom HTML. |\n| `self.text(value)` | Nahradí obsah textom. |\n| `self.aclass(name)` | Pridá CSS triedu. |\n| `self.css(name, value)` | Nastaví vlastnosť CSS. |\n\nReferencia [Komponent](../../reference/component/) uvádza všetky metódy.\n\n## Kompletný komponent\n\nTento ovládací prvok hodnotenia kombinuje konfiguráciu, vykresľovanie, vstup používateľa a väzbu na rovnaký path.\n\n```html\n<ui-component name=\"rating\" path=\"review.stars\" config=\"max:5;icon:*\"></ui-component>\n<p><ui-bind path=\"review.stars\" config=\"text:value + ' of 5'\"></ui-bind></p>\n\n<script>\n\tCOMPONENT('rating', 'max:5;icon:#', function(self, config, cls) {\n\n\t\tself.make = function() {\n\t\t\tself.aclass(cls);\n\t\t\tself.event('click', 'span', function() {\n\t\t\t\tself.bind('@touched @modified @setter', +this.getAttribute('data-value'));\n\t\t\t});\n\t\t};\n\n\t\tself.configure = function(key, value, init) {\n\t\t\t!init && self.refresh();\n\t\t};\n\n\t\tself.setter = function(value) {\n\t\t\tvar builder = [];\n\t\t\tfor (var i = 1; i <= config.max; i++)\n\t\t\t\tbuilder.push('<span data-value=\"' + i + '\" class=\"' + (i <= value ? 'on' : '') + '\">' + config.icon + '</span>');\n\t\t\tself.html(builder.join(''));\n\t\t};\n\t});\n\n\tSET('review.stars', 3);\n</script>\n```\n\nOvládací prvok začína s tromi aktívnymi hviezdičkami a textom `3 of 5`. Kliknutie na piatu hviezdičku uloží `5` a aktualizuje text.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTr1uM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/macros/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Macros","summary":"Attach small reusable behaviour to a ui-bind element with MACRO().","markdown":"---\ntitle: Macros\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/macros/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Macros\n\n> Attach small reusable behaviour to a ui-bind element with MACRO().\n\nA macro is a small piece of behaviour that you attach to a `<ui-bind>` element. It has no template and no path of its own: it uses the element and the path of the binding it is attached to. Use a macro when a [virtual binding](../virtual-bindings/) or a [ui-bind command](../../reference/ui-bind/) is not enough and a full [component](../creating-components/) would be too much.\n\n## Declaring a macro\n\n`MACRO(name, declaration)` registers a macro. The declaration runs once for every binding that uses the macro and receives three arguments:\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `self` | Macro | The macro instance. |\n| `element` | jQuery | The element of the binding. |\n| `cls` | String | A CSS class name made of `DEF.prefixcssmacros` (`m-` by default) and the macro name. |\n\nThis macro counts clicks and writes the result back to the path:\n\n```html\n<script>\n    MACRO('clicks', function(self, element, cls) {\n\n        self.make = function() {\n            self.aclass(cls);\n            element.on('click', function() {\n                self.set((self.get() || 0) + 1);\n            });\n        };\n\n        self.setter = function(value) {\n            self.text('Clicked ' + value + ' times');\n        };\n    });\n\n    var counter = 0;\n</script>\n\n<ui-bind path=\"counter\" config=\"macro:clicks\"></ui-bind>\n```\n\nAfter two clicks, `counter` is `2`, the element shows `Clicked 2 times` and it has the class `m-clicks`.\n\n## Attaching a macro\n\nAdd the `macro` command to the `config` attribute of `<ui-bind>`. Separate several macros with a comma. They run in the order you list them:\n\n```html\n<script>\n    MACRO('uppercase', function(self) {\n        self.setter = function(value) {\n            self.text((value || '').toUpperCase());\n        };\n    });\n\n    MACRO('length', function(self) {\n        self.setter = function(value, path) {\n            self.attrd('length', (value || '').length);\n        };\n    });\n\n    var title = 'hello';\n</script>\n\n<ui-bind path=\"title\" config=\"macro:uppercase,length\"></ui-bind>\n```\n\nAfter `SET('title', 'world')`, the element shows `WORLD` and `data-length` is `5`.\n\nA macro has to be registered at the moment the binding is created. A name that is not registered at that moment is ignored without an error.\n\n## Delegates\n\nAssign these functions to `self` inside the declaration. All of them are optional.\n\n| Delegate | When it runs |\n| --- | --- |\n| `self.make()` | Once, right after the declaration. |\n| `self.setter(value, path, type)` | With the current value when the binding starts, and on every change of the path. |\n| `self.destroy()` | When the element of the binding is removed and the library cleans it up. |\n| `self.service(counter)` | Once a minute. `counter` grows with every call. |\n\n## Reading and writing the value\n\n| Member | Description |\n| --- | --- |\n| `self.get()` | Returns the value of the path. |\n| `self.set(value)` | Writes a value to the path. |\n| `self.refresh()` | Runs the binding again with the current value. |\n| `self.path` | The path of the binding. |\n| `self.name` | The macro name. |\n| `self.element` | The element as a jQuery object. |\n| `self.dom` | The DOM element. |\n| `self.binder` | The binding the macro is attached to. |\n\nA macro also has shortcuts for working with its element, such as `self.aclass()`, `self.attrd()`, `self.find()` and `self.text()`. The [Macro reference](../../reference/macro/) lists all of them.\n\n## Macros inside a plugin\n\nWhen the binding is inside a `<ui-plugin>`, the `?` character in a path refers to that plugin. `self.EXEC()` understands it, so a macro can call a method of the plugin around it:\n\n```html\n<script>\n    PLUGIN('cart', function(exports) {\n        exports.set('total', 3);\n        exports.clear = function(value) {\n            exports.set('total', value);\n        };\n    });\n\n    MACRO('clearbutton', function(self, element) {\n        element.on('click', function() {\n            self.EXEC('?/clear', 0);\n        });\n        self.setter = function(value) {\n            self.text('Clear ' + value + ' items');\n        };\n    });\n</script>\n\n<ui-plugin path=\"cart\">\n    <ui-bind path=\"?.total\" config=\"macro:clearbutton\"></ui-bind>\n</ui-plugin>\n```\n\nThe element shows `Clear 3 items`, and `Clear 0 items` after a click.\n\nThe property `self.scope` holds the surrounding scope. It is assigned after `self.make()` has finished, so read it in `self.setter()` or in an event handler. See [Scopes](../scopes/) and [Plugins](../plugins/).\n\n## Cleaning up\n\nRelease timers and global handlers in `self.destroy()`:\n\n```html\n<script>\n    MACRO('ticker', function(self) {\n\n        var timer;\n\n        self.make = function() {\n            timer = setInterval(function() {\n                // periodic work\n            }, 1000);\n        };\n\n        self.destroy = function() {\n            clearInterval(timer);\n        };\n    });\n</script>\n```\n\nThe library removes bindings of deleted elements during its regular cleanup. Call `FREE()` to run that cleanup right away.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTr1uM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/macros/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Macros","summary":"Hänge mit MACRO() kleines, wiederverwendbares Verhalten an ein ui-bind-Element.","markdown":"---\ntitle: Macros\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/macros/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Macros\n\n> Hänge mit MACRO() kleines, wiederverwendbares Verhalten an ein ui-bind-Element.\n\nEin Macro ist ein kleines Stück Verhalten, das du an ein `<ui-bind>`-Element hängst. Es hat weder ein Template noch einen eigenen Path: Es verwendet das Element und den Path der Bindung, an die es gehängt ist. Setze ein Macro ein, wenn eine [virtuelle Bindung](../virtual-bindings/) oder ein [ui-bind-Befehl](../../reference/ui-bind/) nicht ausreicht und eine vollständige [Komponente](../creating-components/) zu viel wäre.\n\n## Ein Macro deklarieren\n\n`MACRO(name, declaration)` registriert ein Macro. Die Deklaration läuft einmal für jede Bindung, die das Macro verwendet, und erhält drei Argumente:\n\n| Argument | Typ | Beschreibung |\n| --- | --- | --- |\n| `self` | Macro | Die Instanz des Macros. |\n| `element` | jQuery | Das Element der Bindung. |\n| `cls` | String | Ein CSS-Klassenname aus `DEF.prefixcssmacros` (standardmäßig `m-`) und dem Namen des Macros. |\n\nDieses Macro zählt Klicks und schreibt das Ergebnis zurück in den Path:\n\n```html\n<script>\n    MACRO('clicks', function(self, element, cls) {\n\n        self.make = function() {\n            self.aclass(cls);\n            element.on('click', function() {\n                self.set((self.get() || 0) + 1);\n            });\n        };\n\n        self.setter = function(value) {\n            self.text('Clicked ' + value + ' times');\n        };\n    });\n\n    var counter = 0;\n</script>\n\n<ui-bind path=\"counter\" config=\"macro:clicks\"></ui-bind>\n```\n\nNach zwei Klicks ist `counter` gleich `2`, das Element zeigt `Clicked 2 times` und hat die Klasse `m-clicks`.\n\n## Ein Macro anhängen\n\nFüge dem Attribut `config` von `<ui-bind>` den Befehl `macro` hinzu. Trenne mehrere Macros durch ein Komma. Die Macros laufen in der angegebenen Reihenfolge:\n\n```html\n<script>\n    MACRO('uppercase', function(self) {\n        self.setter = function(value) {\n            self.text((value || '').toUpperCase());\n        };\n    });\n\n    MACRO('length', function(self) {\n        self.setter = function(value, path) {\n            self.attrd('length', (value || '').length);\n        };\n    });\n\n    var title = 'hello';\n</script>\n\n<ui-bind path=\"title\" config=\"macro:uppercase,length\"></ui-bind>\n```\n\nNach `SET('title', 'world')` zeigt das Element `WORLD`, und `data-length` ist `5`.\n\nEin Macro muss in dem Moment registriert sein, in dem die Bindung erstellt wird. Ein Name, der zu diesem Zeitpunkt nicht registriert ist, wird ohne Fehlermeldung ignoriert.\n\n## Delegates\n\nWeise diese Funktionen innerhalb der Deklaration `self` zu. Alle sind optional.\n\n| Delegate | Wann es ausgeführt wird |\n| --- | --- |\n| `self.make()` | Einmal, direkt nach der Deklaration. |\n| `self.setter(value, path, type)` | Mit dem aktuellen Wert beim Start der Bindung und bei jeder Änderung des Paths. |\n| `self.destroy()` | Wenn das Element der Bindung entfernt wird und die Bibliothek es aufräumt. |\n| `self.service(counter)` | Einmal pro Minute. `counter` wächst mit jedem Aufruf. |\n\n## Den Wert lesen und schreiben\n\n| Member | Beschreibung |\n| --- | --- |\n| `self.get()` | Gibt den Wert des Paths zurück. |\n| `self.set(value)` | Schreibt einen Wert in den Path. |\n| `self.refresh()` | Führt die Bindung erneut mit dem aktuellen Wert aus. |\n| `self.path` | Der Path der Bindung. |\n| `self.name` | Der Name des Macros. |\n| `self.element` | Das Element als jQuery-Objekt. |\n| `self.dom` | Das DOM-Element. |\n| `self.binder` | Die Bindung, an die das Macro gehängt ist. |\n\nEin Macro hat außerdem Kurzformen für die Arbeit mit seinem Element, etwa `self.aclass()`, `self.attrd()`, `self.find()` und `self.text()`. Die [Macro-Referenz](../../reference/macro/) führt alle auf.\n\n## Macros in einem Plugin\n\nBefindet sich die Bindung in einem `<ui-plugin>`, verweist das Zeichen `?` in einem Path auf dieses Plugin. `self.EXEC()` versteht das, sodass ein Macro eine Methode des umgebenden Plugins aufrufen kann:\n\n```html\n<script>\n    PLUGIN('cart', function(exports) {\n        exports.set('total', 3);\n        exports.clear = function(value) {\n            exports.set('total', value);\n        };\n    });\n\n    MACRO('clearbutton', function(self, element) {\n        element.on('click', function() {\n            self.EXEC('?/clear', 0);\n        });\n        self.setter = function(value) {\n            self.text('Clear ' + value + ' items');\n        };\n    });\n</script>\n\n<ui-plugin path=\"cart\">\n    <ui-bind path=\"?.total\" config=\"macro:clearbutton\"></ui-bind>\n</ui-plugin>\n```\n\nDas Element zeigt `Clear 3 items` und nach einem Klick `Clear 0 items`.\n\nDie Eigenschaft `self.scope` enthält den umgebenden Scope. Der Wert wird erst gesetzt, nachdem `self.make()` beendet ist. Lies die Eigenschaft daher in `self.setter()` oder in einem Event-Handler. Siehe [Scopes](../scopes/) und [Plugins](../plugins/).\n\n## Aufräumen\n\nGib Timer und globale Handler in `self.destroy()` frei:\n\n```html\n<script>\n    MACRO('ticker', function(self) {\n\n        var timer;\n\n        self.make = function() {\n            timer = setInterval(function() {\n                // periodic work\n            }, 1000);\n        };\n\n        self.destroy = function() {\n            clearInterval(timer);\n        };\n    });\n</script>\n```\n\nDie Bibliothek entfernt Bindungen gelöschter Elemente bei ihrer regelmäßigen Aufräumrunde. Rufe `FREE()` auf, um diese Aufräumrunde sofort auszuführen.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTr1uM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/macros/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Macros","summary":"Añade un pequeño comportamiento reutilizable a un elemento ui-bind con MACRO().","markdown":"---\ntitle: Macros\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/macros/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Macros\n\n> Añade un pequeño comportamiento reutilizable a un elemento ui-bind con MACRO().\n\nUna macro es un pequeño comportamiento que añades a un elemento `<ui-bind>`. No tiene plantilla ni path propios: usa el elemento y el path del enlace al que está unida. Usa una macro cuando un [enlace virtual](../virtual-bindings/) o un [comando de ui-bind](../../reference/ui-bind/) no basten y un [componente](../creating-components/) completo sea demasiado.\n\n## Declarar una macro\n\n`MACRO(name, declaration)` registra una macro. La declaración se ejecuta una vez por cada enlace que usa la macro y recibe tres argumentos:\n\n| Argumento | Tipo | Descripción |\n| --- | --- | --- |\n| `self` | Macro | La instancia de la macro. |\n| `element` | jQuery | El elemento del enlace. |\n| `cls` | String | Un nombre de clase CSS formado por `DEF.prefixcssmacros` (`m-` por defecto) y el nombre de la macro. |\n\nEsta macro cuenta los clics y escribe el resultado en el path:\n\n```html\n<script>\n    MACRO('clicks', function(self, element, cls) {\n\n        self.make = function() {\n            self.aclass(cls);\n            element.on('click', function() {\n                self.set((self.get() || 0) + 1);\n            });\n        };\n\n        self.setter = function(value) {\n            self.text('Clicked ' + value + ' times');\n        };\n    });\n\n    var counter = 0;\n</script>\n\n<ui-bind path=\"counter\" config=\"macro:clicks\"></ui-bind>\n```\n\nDespués de dos clics, `counter` vale `2`, el elemento muestra `Clicked 2 times` y tiene la clase `m-clicks`.\n\n## Añadir una macro\n\nAñade el comando `macro` al atributo `config` de `<ui-bind>`. Separa varias macros con una coma. Se ejecutan en el orden en que las escribes:\n\n```html\n<script>\n    MACRO('uppercase', function(self) {\n        self.setter = function(value) {\n            self.text((value || '').toUpperCase());\n        };\n    });\n\n    MACRO('length', function(self) {\n        self.setter = function(value, path) {\n            self.attrd('length', (value || '').length);\n        };\n    });\n\n    var title = 'hello';\n</script>\n\n<ui-bind path=\"title\" config=\"macro:uppercase,length\"></ui-bind>\n```\n\nDespués de `SET('title', 'world')`, el elemento muestra `WORLD` y `data-length` vale `5`.\n\nUna macro tiene que estar registrada en el momento en que se crea el enlace. Un nombre que no esté registrado en ese momento se ignora sin ningún error.\n\n## Delegates\n\nAsigna estas funciones a `self` dentro de la declaración. Todas son opcionales.\n\n| Delegate | Cuándo se ejecuta |\n| --- | --- |\n| `self.make()` | Una vez, justo después de la declaración. |\n| `self.setter(value, path, type)` | Con el valor actual cuando se inicia el enlace, y en cada cambio del path. |\n| `self.destroy()` | Cuando se elimina el elemento del enlace y la biblioteca lo limpia. |\n| `self.service(counter)` | Una vez por minuto. `counter` aumenta con cada llamada. |\n\n## Leer y escribir el valor\n\n| Miembro | Descripción |\n| --- | --- |\n| `self.get()` | Devuelve el valor del path. |\n| `self.set(value)` | Escribe un valor en el path. |\n| `self.refresh()` | Vuelve a ejecutar el enlace con el valor actual. |\n| `self.path` | El path del enlace. |\n| `self.name` | El nombre de la macro. |\n| `self.element` | El elemento como objeto jQuery. |\n| `self.dom` | El elemento DOM. |\n| `self.binder` | El enlace al que está unida la macro. |\n\nUna macro también tiene atajos para trabajar con su elemento, como `self.aclass()`, `self.attrd()`, `self.find()` y `self.text()`. La [referencia de Macro](../../reference/macro/) los enumera todos.\n\n## Macros dentro de un plugin\n\nCuando el enlace está dentro de un `<ui-plugin>`, el carácter `?` de un path hace referencia a ese plugin. `self.EXEC()` lo entiende, así que una macro puede llamar a un método del plugin que la rodea:\n\n```html\n<script>\n    PLUGIN('cart', function(exports) {\n        exports.set('total', 3);\n        exports.clear = function(value) {\n            exports.set('total', value);\n        };\n    });\n\n    MACRO('clearbutton', function(self, element) {\n        element.on('click', function() {\n            self.EXEC('?/clear', 0);\n        });\n        self.setter = function(value) {\n            self.text('Clear ' + value + ' items');\n        };\n    });\n</script>\n\n<ui-plugin path=\"cart\">\n    <ui-bind path=\"?.total\" config=\"macro:clearbutton\"></ui-bind>\n</ui-plugin>\n```\n\nEl elemento muestra `Clear 3 items` y, después de un clic, `Clear 0 items`.\n\nLa propiedad `self.scope` contiene el scope que la rodea. Se asigna cuando `self.make()` ha terminado, así que léela en `self.setter()` o en un manejador de eventos. Consulta [Scopes](../scopes/) y [Plugins](../plugins/).\n\n## Limpieza\n\nLibera los temporizadores y los manejadores globales en `self.destroy()`:\n\n```html\n<script>\n    MACRO('ticker', function(self) {\n\n        var timer;\n\n        self.make = function() {\n            timer = setInterval(function() {\n                // periodic work\n            }, 1000);\n        };\n\n        self.destroy = function() {\n            clearInterval(timer);\n        };\n    });\n</script>\n```\n\nLa biblioteca elimina los enlaces de los elementos borrados durante su limpieza periódica. Llama a `FREE()` para ejecutar esa limpieza de inmediato.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTr1uM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/macros/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Macros","summary":"Attache un petit comportement réutilisable à un élément ui-bind avec MACRO().","markdown":"---\ntitle: Macros\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/macros/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Macros\n\n> Attache un petit comportement réutilisable à un élément ui-bind avec MACRO().\n\nUne macro est un petit comportement que tu attaches à un élément `<ui-bind>`. Elle n'a ni modèle ni path propres : elle utilise l'élément et le path de la liaison à laquelle elle est attachée. Utilise une macro quand une [liaison virtuelle](../virtual-bindings/) ou une [commande ui-bind](../../reference/ui-bind/) ne suffit pas et qu'un [composant](../creating-components/) complet serait excessif.\n\n## Déclarer une macro\n\n`MACRO(name, declaration)` enregistre une macro. La déclaration s'exécute une fois pour chaque liaison qui utilise la macro et reçoit trois arguments :\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `self` | Macro | L'instance de la macro. |\n| `element` | jQuery | L'élément de la liaison. |\n| `cls` | String | Un nom de classe CSS composé de `DEF.prefixcssmacros` (`m-` par défaut) et du nom de la macro. |\n\nCette macro compte les clics et réécrit le résultat dans le path :\n\n```html\n<script>\n    MACRO('clicks', function(self, element, cls) {\n\n        self.make = function() {\n            self.aclass(cls);\n            element.on('click', function() {\n                self.set((self.get() || 0) + 1);\n            });\n        };\n\n        self.setter = function(value) {\n            self.text('Clicked ' + value + ' times');\n        };\n    });\n\n    var counter = 0;\n</script>\n\n<ui-bind path=\"counter\" config=\"macro:clicks\"></ui-bind>\n```\n\nAprès deux clics, `counter` vaut `2`, l'élément affiche `Clicked 2 times` et il porte la classe `m-clicks`.\n\n## Attacher une macro\n\nAjoute la commande `macro` à l'attribut `config` de `<ui-bind>`. Sépare plusieurs macros par une virgule. Elles s'exécutent dans l'ordre où tu les indiques :\n\n```html\n<script>\n    MACRO('uppercase', function(self) {\n        self.setter = function(value) {\n            self.text((value || '').toUpperCase());\n        };\n    });\n\n    MACRO('length', function(self) {\n        self.setter = function(value, path) {\n            self.attrd('length', (value || '').length);\n        };\n    });\n\n    var title = 'hello';\n</script>\n\n<ui-bind path=\"title\" config=\"macro:uppercase,length\"></ui-bind>\n```\n\nAprès `SET('title', 'world')`, l'élément affiche `WORLD` et `data-length` vaut `5`.\n\nUne macro doit être enregistrée au moment où la liaison est créée. Un nom qui n'est pas enregistré à ce moment-là est ignoré sans erreur.\n\n## Delegates\n\nAssigne ces fonctions à `self` dans la déclaration. Elles sont toutes facultatives.\n\n| Delegate | Quand il s'exécute |\n| --- | --- |\n| `self.make()` | Une fois, juste après la déclaration. |\n| `self.setter(value, path, type)` | Avec la valeur actuelle au démarrage de la liaison, puis à chaque changement du path. |\n| `self.destroy()` | Quand l'élément de la liaison est supprimé et que la bibliothèque le nettoie. |\n| `self.service(counter)` | Une fois par minute. `counter` augmente à chaque appel. |\n\n## Lire et écrire la valeur\n\n| Membre | Description |\n| --- | --- |\n| `self.get()` | Renvoie la valeur du path. |\n| `self.set(value)` | Écrit une valeur dans le path. |\n| `self.refresh()` | Exécute de nouveau la liaison avec la valeur actuelle. |\n| `self.path` | Le path de la liaison. |\n| `self.name` | Le nom de la macro. |\n| `self.element` | L'élément sous forme d'objet jQuery. |\n| `self.dom` | L'élément DOM. |\n| `self.binder` | La liaison à laquelle la macro est attachée. |\n\nUne macro dispose aussi de raccourcis pour manipuler son élément, comme `self.aclass()`, `self.attrd()`, `self.find()` et `self.text()`. La [référence Macro](../../reference/macro/) les liste tous.\n\n## Macros dans un plugin\n\nQuand la liaison se trouve dans un `<ui-plugin>`, le caractère `?` d'un path désigne ce plugin. `self.EXEC()` le comprend, ce qui permet à une macro d'appeler une méthode du plugin qui l'entoure :\n\n```html\n<script>\n    PLUGIN('cart', function(exports) {\n        exports.set('total', 3);\n        exports.clear = function(value) {\n            exports.set('total', value);\n        };\n    });\n\n    MACRO('clearbutton', function(self, element) {\n        element.on('click', function() {\n            self.EXEC('?/clear', 0);\n        });\n        self.setter = function(value) {\n            self.text('Clear ' + value + ' items');\n        };\n    });\n</script>\n\n<ui-plugin path=\"cart\">\n    <ui-bind path=\"?.total\" config=\"macro:clearbutton\"></ui-bind>\n</ui-plugin>\n```\n\nL'élément affiche `Clear 3 items`, puis `Clear 0 items` après un clic.\n\nLa propriété `self.scope` contient le scope environnant. Elle est assignée une fois `self.make()` terminé : lis-la donc dans `self.setter()` ou dans un gestionnaire d'événement. Consulte [Scopes](../scopes/) et [Plugins](../plugins/).\n\n## Nettoyer\n\nLibère les minuteurs et les gestionnaires globaux dans `self.destroy()` :\n\n```html\n<script>\n    MACRO('ticker', function(self) {\n\n        var timer;\n\n        self.make = function() {\n            timer = setInterval(function() {\n                // periodic work\n            }, 1000);\n        };\n\n        self.destroy = function() {\n            clearInterval(timer);\n        };\n    });\n</script>\n```\n\nLa bibliothèque supprime les liaisons des éléments effacés lors de son nettoyage régulier. Appelle `FREE()` pour lancer ce nettoyage immédiatement.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTr1uM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/macros/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Macro","summary":"Aggiungi a un elemento ui-bind un piccolo comportamento riutilizzabile con MACRO().","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/macros/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Macro\n\n> Aggiungi a un elemento ui-bind un piccolo comportamento riutilizzabile con MACRO().\n\nUna macro è un piccolo comportamento che colleghi a un elemento `<ui-bind>`. Non ha né un template né un path propri: usa l'elemento e il path dell'associazione a cui è collegata. Usa una macro quando un'[associazione virtuale](../virtual-bindings/) o un [comando ui-bind](../../reference/ui-bind/) non bastano e un [componente](../creating-components/) completo sarebbe eccessivo.\n\n## Dichiarare una macro\n\n`MACRO(name, declaration)` registra una macro. La dichiarazione viene eseguita una volta per ogni associazione che usa la macro e riceve tre argomenti:\n\n| Argomento | Tipo | Descrizione |\n| --- | --- | --- |\n| `self` | Macro | L'istanza della macro. |\n| `element` | jQuery | L'elemento dell'associazione. |\n| `cls` | String | Un nome di classe CSS composto da `DEF.prefixcssmacros` (`m-` per impostazione predefinita) e dal nome della macro. |\n\nQuesta macro conta i clic e riscrive il risultato nel path:\n\n```html\n<script>\n    MACRO('clicks', function(self, element, cls) {\n\n        self.make = function() {\n            self.aclass(cls);\n            element.on('click', function() {\n                self.set((self.get() || 0) + 1);\n            });\n        };\n\n        self.setter = function(value) {\n            self.text('Clicked ' + value + ' times');\n        };\n    });\n\n    var counter = 0;\n</script>\n\n<ui-bind path=\"counter\" config=\"macro:clicks\"></ui-bind>\n```\n\nDopo due clic, `counter` vale `2`, l'elemento mostra `Clicked 2 times` e ha la classe `m-clicks`.\n\n## Collegare una macro\n\nAggiungi il comando `macro` all'attributo `config` di `<ui-bind>`. Separa più macro con una virgola. Vengono eseguite nell'ordine in cui le elenchi:\n\n```html\n<script>\n    MACRO('uppercase', function(self) {\n        self.setter = function(value) {\n            self.text((value || '').toUpperCase());\n        };\n    });\n\n    MACRO('length', function(self) {\n        self.setter = function(value, path) {\n            self.attrd('length', (value || '').length);\n        };\n    });\n\n    var title = 'hello';\n</script>\n\n<ui-bind path=\"title\" config=\"macro:uppercase,length\"></ui-bind>\n```\n\nDopo `SET('title', 'world')`, l'elemento mostra `WORLD` e `data-length` vale `5`.\n\nUna macro deve essere registrata nel momento in cui viene creata l'associazione. Un nome non registrato in quel momento viene ignorato senza alcun errore.\n\n## Delegate\n\nAssegna queste funzioni a `self` all'interno della dichiarazione. Sono tutte facoltative.\n\n| Delegate | Quando viene eseguito |\n| --- | --- |\n| `self.make()` | Una volta, subito dopo la dichiarazione. |\n| `self.setter(value, path, type)` | Con il valore corrente all'avvio dell'associazione e a ogni modifica del path. |\n| `self.destroy()` | Quando l'elemento dell'associazione viene rimosso e la libreria lo ripulisce. |\n| `self.service(counter)` | Una volta al minuto. `counter` aumenta a ogni chiamata. |\n\n## Leggere e scrivere il valore\n\n| Membro | Descrizione |\n| --- | --- |\n| `self.get()` | Restituisce il valore del path. |\n| `self.set(value)` | Scrive un valore nel path. |\n| `self.refresh()` | Esegue di nuovo l'associazione con il valore corrente. |\n| `self.path` | Il path dell'associazione. |\n| `self.name` | Il nome della macro. |\n| `self.element` | L'elemento come oggetto jQuery. |\n| `self.dom` | L'elemento DOM. |\n| `self.binder` | L'associazione a cui è collegata la macro. |\n\nUna macro dispone anche di scorciatoie per lavorare con il suo elemento, come `self.aclass()`, `self.attrd()`, `self.find()` e `self.text()`. Il [riferimento di Macro](../../reference/macro/) le elenca tutte.\n\n## Macro all'interno di un plugin\n\nQuando l'associazione si trova all'interno di un `<ui-plugin>`, il carattere `?` in un path si riferisce a quel plugin. `self.EXEC()` lo interpreta, quindi una macro può chiamare un metodo del plugin che la contiene:\n\n```html\n<script>\n    PLUGIN('cart', function(exports) {\n        exports.set('total', 3);\n        exports.clear = function(value) {\n            exports.set('total', value);\n        };\n    });\n\n    MACRO('clearbutton', function(self, element) {\n        element.on('click', function() {\n            self.EXEC('?/clear', 0);\n        });\n        self.setter = function(value) {\n            self.text('Clear ' + value + ' items');\n        };\n    });\n</script>\n\n<ui-plugin path=\"cart\">\n    <ui-bind path=\"?.total\" config=\"macro:clearbutton\"></ui-bind>\n</ui-plugin>\n```\n\nL'elemento mostra `Clear 3 items` e, dopo un clic, `Clear 0 items`.\n\nLa proprietà `self.scope` contiene lo scope circostante. Viene assegnata al termine di `self.make()`, quindi leggila in `self.setter()` o in un gestore di eventi. Consulta [Scope](../scopes/) e [Plugin](../plugins/).\n\n## Pulizia\n\nRilascia i timer e i gestori globali in `self.destroy()`:\n\n```html\n<script>\n    MACRO('ticker', function(self) {\n\n        var timer;\n\n        self.make = function() {\n            timer = setInterval(function() {\n                // periodic work\n            }, 1000);\n        };\n\n        self.destroy = function() {\n            clearInterval(timer);\n        };\n    });\n</script>\n```\n\nLa libreria rimuove le associazioni degli elementi eliminati durante la sua pulizia periodica. Chiama `FREE()` per eseguire subito questa pulizia.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTr1uM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/macros/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Macros","summary":"Pripoj k elementu ui-bind malé opakovane použiteľné správanie pomocou MACRO().","markdown":"---\ntitle: Macros\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/macros/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Macros\n\n> Pripoj k elementu ui-bind malé opakovane použiteľné správanie pomocou MACRO().\n\nMacro je malý kus správania, ktorý pripojíš k elementu `<ui-bind>`. Nemá šablónu ani vlastný path: používa element a path väzby, ku ktorej je pripojené. Macro použi vtedy, keď [virtuálna väzba](../virtual-bindings/) alebo [príkaz ui-bind](../../reference/ui-bind/) nestačí a celý [komponent](../creating-components/) by bol priveľa.\n\n## Deklarácia macra\n\n`MACRO(name, declaration)` zaregistruje macro. Deklarácia sa spustí raz pre každú väzbu, ktorá macro používa, a dostane tri argumenty:\n\n| Argument | Typ | Popis |\n| --- | --- | --- |\n| `self` | Macro | Inštancia macra. |\n| `element` | jQuery | Element väzby. |\n| `cls` | String | Názov CSS triedy zložený z `DEF.prefixcssmacros` (predvolene `m-`) a názvu macra. |\n\nToto macro počíta kliknutia a výsledok zapisuje späť do path:\n\n```html\n<script>\n    MACRO('clicks', function(self, element, cls) {\n\n        self.make = function() {\n            self.aclass(cls);\n            element.on('click', function() {\n                self.set((self.get() || 0) + 1);\n            });\n        };\n\n        self.setter = function(value) {\n            self.text('Clicked ' + value + ' times');\n        };\n    });\n\n    var counter = 0;\n</script>\n\n<ui-bind path=\"counter\" config=\"macro:clicks\"></ui-bind>\n```\n\nPo dvoch kliknutiach má `counter` hodnotu `2`, element zobrazuje `Clicked 2 times` a má triedu `m-clicks`.\n\n## Pripojenie macra\n\nDo atribútu `config` elementu `<ui-bind>` pridaj príkaz `macro`. Ak ich je viac, oddeľ ich čiarkou. Spúšťajú sa v poradí, v akom ich uvedieš:\n\n```html\n<script>\n    MACRO('uppercase', function(self) {\n        self.setter = function(value) {\n            self.text((value || '').toUpperCase());\n        };\n    });\n\n    MACRO('length', function(self) {\n        self.setter = function(value, path) {\n            self.attrd('length', (value || '').length);\n        };\n    });\n\n    var title = 'hello';\n</script>\n\n<ui-bind path=\"title\" config=\"macro:uppercase,length\"></ui-bind>\n```\n\nPo `SET('title', 'world')` element zobrazí `WORLD` a `data-length` má hodnotu `5`.\n\nMacro musí byť zaregistrované v momente vytvorenia väzby. Názov, ktorý v tom momente nie je zaregistrovaný, sa bez chyby ignoruje.\n\n## Delegate\n\nTieto funkcie priraď k `self` vnútri deklarácie. Všetky sú voliteľné.\n\n| Delegate | Kedy sa spustí |\n| --- | --- |\n| `self.make()` | Raz, hneď po deklarácii. |\n| `self.setter(value, path, type)` | S aktuálnou hodnotou pri štarte väzby a pri každej zmene path. |\n| `self.destroy()` | Keď sa element väzby odstráni a knižnica ho uprace. |\n| `self.service(counter)` | Raz za minútu. `counter` sa pri každom volaní zvyšuje. |\n\n## Čítanie a zápis hodnoty\n\n| Člen | Popis |\n| --- | --- |\n| `self.get()` | Vráti hodnotu path. |\n| `self.set(value)` | Zapíše hodnotu do path. |\n| `self.refresh()` | Znova spustí väzbu s aktuálnou hodnotou. |\n| `self.path` | Path väzby. |\n| `self.name` | Názov macra. |\n| `self.element` | Element ako objekt jQuery. |\n| `self.dom` | Element DOM. |\n| `self.binder` | Väzba, ku ktorej je macro pripojené. |\n\nMacro má aj skratky na prácu so svojím elementom, napríklad `self.aclass()`, `self.attrd()`, `self.find()` a `self.text()`. Všetky uvádza [referencia Macro](../../reference/macro/).\n\n## Macros vnútri pluginu\n\nKeď je väzba vnútri `<ui-plugin>`, znak `?` v path odkazuje na tento plugin. `self.EXEC()` mu rozumie, takže macro môže zavolať metódu pluginu, ktorý ho obklopuje:\n\n```html\n<script>\n    PLUGIN('cart', function(exports) {\n        exports.set('total', 3);\n        exports.clear = function(value) {\n            exports.set('total', value);\n        };\n    });\n\n    MACRO('clearbutton', function(self, element) {\n        element.on('click', function() {\n            self.EXEC('?/clear', 0);\n        });\n        self.setter = function(value) {\n            self.text('Clear ' + value + ' items');\n        };\n    });\n</script>\n\n<ui-plugin path=\"cart\">\n    <ui-bind path=\"?.total\" config=\"macro:clearbutton\"></ui-bind>\n</ui-plugin>\n```\n\nElement zobrazí `Clear 3 items` a po kliknutí `Clear 0 items`.\n\nVlastnosť `self.scope` obsahuje okolitý scope. Priradí sa až po dokončení `self.make()`, preto ju čítaj v `self.setter()` alebo v obslužnej funkcii udalosti. Pozri [Scopes](../scopes/) a [Pluginy](../plugins/).\n\n## Upratovanie\n\nČasovače a globálne obslužné funkcie uvoľni v `self.destroy()`:\n\n```html\n<script>\n    MACRO('ticker', function(self) {\n\n        var timer;\n\n        self.make = function() {\n            timer = setInterval(function() {\n                // periodic work\n            }, 1000);\n        };\n\n        self.destroy = function() {\n            clearInterval(timer);\n        };\n    });\n</script>\n```\n\nKnižnica odstraňuje väzby vymazaných elementov počas pravidelného upratovania. Ak ho chceš spustiť hneď, zavolaj `FREE()`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTx1yM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/plugins/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Plugins","summary":"Organise the logic and data of a part of the application with PLUGIN() and ui-plugin.","markdown":"---\ntitle: Plugins\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/plugins/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Plugins\n\n> Organise the logic and data of a part of the application with PLUGIN() and ui-plugin.\n\nA plugin holds the data and the logic of one part of an application, such as a page, a form or a panel. It owns a path with the same name as the plugin, so the plugin `orders` keeps its data in `orders.*`. The HTML connects to it with the `<ui-plugin>` element.\n\n## Declaring a plugin\n\n`PLUGIN(name, declaration)` creates a plugin. The declaration receives the plugin instance, usually named `exports`. Everything you assign to it becomes a public method:\n\n```html\n<script>\n    PLUGIN('counter', function(exports) {\n\n        exports.set('count', 0);\n\n        exports.increment = function() {\n            exports.inc('count', 1);\n        };\n    });\n</script>\n\n<ui-plugin path=\"counter\">\n    <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nInside `<ui-plugin>`, the `?` character stands for the plugin path, so `?.count` is `counter.count` and `?/increment` is the method `increment` of the plugin. An element with the class `exec` calls the method named in `data-exec` when it is clicked.\n\nThe name `*` declares a plugin on the common path, whose name comes from `DEF.pathcommon` (`common` by default).\n\n## The ui-plugin element\n\n`<ui-plugin>` connects a part of the page with a plugin. Its `config` attribute holds settings, and its `default` attribute holds a JavaScript expression that becomes the plugin model:\n\n```html\n<script>\n    PLUGIN('settings', function(exports) {\n        exports.show = function() {\n            var config = exports.element.scope().config;\n            console.log(config.title, config.size);\n            console.log(exports.model);\n        };\n    });\n</script>\n\n<ui-plugin path=\"settings\" config=\"title:Account;size:10\" default=\"{ theme: 'light' }\"></ui-plugin>\n```\n\n`PLUGINS.settings.show()` prints `Account 10` and `{ theme: 'light' }`.\n\n`exports.element` is the `<ui-plugin>` element once the plugin is connected to it. While a declaration placed ahead of the element runs, `exports.element` is still the `<body>`. If no plugin is declared for the path, the library creates an empty one. All attributes are in the [ui-plugin reference](../../reference/ui-plugin/).\n\n## Working with data\n\nThe methods of a plugin work with paths relative to the plugin. Without a path, they work with the whole model:\n\n| Method | Description |\n| --- | --- |\n| `exports.get([path])` | Reads a value. |\n| `exports.set([path], value, [type])` | Writes a value. |\n| `exports.push([path], value, [type])` | Adds an item to an array. |\n| `exports.inc([path], value, [type])` | Increases a number. |\n| `exports.extend([path], value, [type])` | Merges an object into an existing object. |\n| `exports.toggle(path, [type])` | Inverts a boolean value. |\n| `exports.nul(path, [type])` | Writes `null`. |\n| `exports.upd(path, [type])` | Notifies bindings about a change you made directly. |\n| `exports.reset([path])` | Resets the state of the form fields under the path. |\n| `exports.makepath([path])` | Returns the absolute path. |\n\n```js\nPLUGIN('todo', function(exports) {\n\n    exports.set({ items: [], done: false, total: 1 });\n    exports.push('items', 'Write docs');\n    exports.inc('total', 2);\n    exports.toggle('done');\n\n    exports.get('total');       // 3\n    exports.model.items;        // ['Write docs']\n    exports.makepath('items');  // 'todo.items'\n});\n```\n\nFour properties read the model directly:\n\n| Property | Description |\n| --- | --- |\n| `exports.model` | Reads or replaces the whole model. |\n| `exports.data` | The same as `exports.model`. |\n| `exports.form` | Returns the model and resets the state of its form fields. |\n| `exports.modified` | Returns only the fields the user changed and resets the state of the form fields. |\n\n[Forms and validation](../forms/) shows `exports.form` and `exports.modified` in use.\n\n## Calling a plugin\n\nUse `EXEC()` with the plugin name, a slash and the method name. `PLUGINS` holds all running plugins by name:\n\n```js\nEXEC('counter/increment');\nPLUGINS.counter.increment();\n```\n\n`exports.exec('method', [arguments])` calls a method of the same plugin. When one plugin calls another through `EXEC()`, the called plugin finds the calling plugin in `exports.caller`:\n\n```html\n<script>\n    PLUGIN('page', function(exports) {\n        exports.refresh = function() {\n            console.log('refreshed by', exports.caller.name);\n        };\n    });\n\n    PLUGIN('page.toolbar', function(exports) {\n        exports.reload = function() {\n            EXEC('page/refresh');\n        };\n    });\n</script>\n\n<ui-plugin path=\"page\">\n    <ui-plugin path=\"toolbar\"></ui-plugin>\n</ui-plugin>\n```\n\n`EXEC('page.toolbar/reload')` prints `refreshed by page.toolbar`.\n\n## Nested plugins\n\nA `<ui-plugin>` inside another one extends the path of its parent. In the example above, the inner element uses the plugin `page.toolbar`, and `PLUGINS['page.toolbar'].parent` returns the plugin `page`. [Scopes](../scopes/) describes how nested paths are resolved.\n\n## Watching values and events\n\n`exports.watch()` observes a path relative to the plugin. `exports.on()` listens to a global event. Both stop automatically when the plugin is removed:\n\n```js\nPLUGIN('clock', function(exports) {\n\n    exports.watch('time', function(value, path, type) {\n        console.log('watch', value, path);\n    });\n\n    exports.on('tick', function(value) {\n        exports.set('time', value);\n    });\n\n    exports.destroy = function() {\n        console.log('destroyed');\n    };\n});\n```\n\n`EMIT('tick', 1)` prints `watch 1 clock.time`. The callback of `exports.watch()` receives the value first and the path second.\n\n## One declaration for many instances\n\nA name with a space declares a shared definition. The word after the space is the name of the definition, and each `<ui-plugin>` that uses it gets its own instance on its own path:\n\n```html\n<script>\n    PLUGIN('? panel', function(exports) {\n        exports.set('title', 'Panel ' + exports.name);\n    });\n</script>\n\n<ui-plugin path=\"left panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"right panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nThis page runs the plugins `left` and `right`, which show `Panel left` and `Panel right`.\n\n## Plugins created on demand\n\n`PLUGINABLE(name, declaration)` registers a plugin without running it. The plugin is created by the first `EXEC()` that calls it:\n\n```js\nPLUGINABLE('report', function(exports) {\n    exports.build = function(year) {\n        console.log('building', year);\n    };\n});\n\nPLUGINS.report;              // undefined\nEXEC('report/build', 2024);  // creates the plugin and calls build()\n```\n\n## Calling the server\n\n`exports.ajax()` sends a request. The callback can be a function, a path relative to the plugin, or missing. Without a callback and without data, the method returns a promise:\n\n```js\nPLUGIN('users', function(exports) {\n\n    exports.load = function() {\n\n        // A function\n        exports.ajax('GET /api/users/', function(response) {\n            console.log(response);\n        });\n\n        // A path: the response is stored in \"users.saved\"\n        exports.ajax('POST /api/users/', { name: 'Peter' }, 'saved');\n    };\n\n    exports.read = async function() {\n        var response = await exports.ajax('GET /api/users/1/');\n        console.log(response);\n    };\n});\n```\n\n`exports.api()`, `exports.tapi()`, `exports.dapi()` and `exports.upload()` take the same arguments and use the matching global function. See the [Plugin reference](../../reference/plugin/).\n\n## Removing a plugin\n\n`exports.remove()` emits the `plugin.destroy` event, runs the `exports.destroy()` delegate, stops the watchers and events of the plugin and deletes it from `PLUGINS`. Declaring a plugin with a name that is already in use removes the running plugin and replaces it:\n\n```js\nPLUGIN('editor', function(exports) {\n    exports.destroy = function() {\n        console.log('first instance destroyed');\n    };\n});\n\nPLUGIN('editor', function(exports) {\n    exports.version = 2;\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTx1yM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/plugins/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Plugins","summary":"Organisiere die Logik und die Daten eines Anwendungsteils mit PLUGIN() und ui-plugin.","markdown":"---\ntitle: Plugins\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/plugins/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Plugins\n\n> Organisiere die Logik und die Daten eines Anwendungsteils mit PLUGIN() und ui-plugin.\n\nEin Plugin enthält die Daten und die Logik eines Teils einer Anwendung, etwa einer Seite, eines Formulars oder eines Panels. Ihm gehört ein Path mit demselben Namen wie das Plugin, das Plugin `orders` hält seine Daten also in `orders.*`. Das HTML verbindet sich über das Element `<ui-plugin>` mit ihm.\n\n## Ein Plugin deklarieren\n\n`PLUGIN(name, declaration)` erstellt ein Plugin. Die Deklaration erhält die Instanz des Plugins, die üblicherweise `exports` heißt. Alles, was du ihr zuweist, wird zu einer öffentlichen Methode:\n\n```html\n<script>\n    PLUGIN('counter', function(exports) {\n\n        exports.set('count', 0);\n\n        exports.increment = function() {\n            exports.inc('count', 1);\n        };\n    });\n</script>\n\n<ui-plugin path=\"counter\">\n    <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nInnerhalb von `<ui-plugin>` steht das Zeichen `?` für den Path des Plugins, also ist `?.count` gleich `counter.count` und `?/increment` die Methode `increment` des Plugins. Ein Element mit der Klasse `exec` ruft beim Anklicken die in `data-exec` genannte Methode auf.\n\nDer Name `*` deklariert ein Plugin auf dem gemeinsamen Path, dessen Name aus `DEF.pathcommon` stammt (standardmäßig `common`).\n\n## Das Element ui-plugin\n\n`<ui-plugin>` verbindet einen Teil der Seite mit einem Plugin. Das Attribut `config` enthält Einstellungen, und das Attribut `default` enthält einen JavaScript-Ausdruck, der zum Modell des Plugins wird:\n\n```html\n<script>\n    PLUGIN('settings', function(exports) {\n        exports.show = function() {\n            var config = exports.element.scope().config;\n            console.log(config.title, config.size);\n            console.log(exports.model);\n        };\n    });\n</script>\n\n<ui-plugin path=\"settings\" config=\"title:Account;size:10\" default=\"{ theme: 'light' }\"></ui-plugin>\n```\n\n`PLUGINS.settings.show()` gibt `Account 10` und `{ theme: 'light' }` aus.\n\n`exports.element` ist das `<ui-plugin>`-Element, sobald das Plugin damit verbunden ist. Solange eine vor dem Element platzierte Deklaration läuft, ist `exports.element` noch das `<body>`. Ist für den Path kein Plugin deklariert, erstellt die Bibliothek ein leeres. Alle Attribute findest du in der [ui-plugin-Referenz](../../reference/ui-plugin/).\n\n## Mit Daten arbeiten\n\nDie Methoden eines Plugins arbeiten mit Paths relativ zum Plugin. Ohne Path arbeiten sie mit dem gesamten Modell:\n\n| Methode | Beschreibung |\n| --- | --- |\n| `exports.get([path])` | Liest einen Wert. |\n| `exports.set([path], value, [type])` | Schreibt einen Wert. |\n| `exports.push([path], value, [type])` | Fügt einem Array einen Eintrag hinzu. |\n| `exports.inc([path], value, [type])` | Erhöht eine Zahl. |\n| `exports.extend([path], value, [type])` | Führt ein Objekt mit einem vorhandenen Objekt zusammen. |\n| `exports.toggle(path, [type])` | Kehrt einen booleschen Wert um. |\n| `exports.nul(path, [type])` | Schreibt `null`. |\n| `exports.upd(path, [type])` | Benachrichtigt Bindungen über eine direkt vorgenommene Änderung. |\n| `exports.reset([path])` | Setzt den Zustand der Formularfelder unter dem Path zurück. |\n| `exports.makepath([path])` | Gibt den absoluten Path zurück. |\n\n```js\nPLUGIN('todo', function(exports) {\n\n    exports.set({ items: [], done: false, total: 1 });\n    exports.push('items', 'Write docs');\n    exports.inc('total', 2);\n    exports.toggle('done');\n\n    exports.get('total');       // 3\n    exports.model.items;        // ['Write docs']\n    exports.makepath('items');  // 'todo.items'\n});\n```\n\nVier Eigenschaften lesen das Modell direkt:\n\n| Eigenschaft | Beschreibung |\n| --- | --- |\n| `exports.model` | Liest oder ersetzt das gesamte Modell. |\n| `exports.data` | Dasselbe wie `exports.model`. |\n| `exports.form` | Gibt das Modell zurück und setzt den Zustand seiner Formularfelder zurück. |\n| `exports.modified` | Gibt nur die vom Benutzer geänderten Felder zurück und setzt den Zustand der Formularfelder zurück. |\n\n[Formulare und Validierung](../forms/) zeigt `exports.form` und `exports.modified` im Einsatz.\n\n## Ein Plugin aufrufen\n\nVerwende `EXEC()` mit dem Namen des Plugins, einem Schrägstrich und dem Namen der Methode. `PLUGINS` enthält alle laufenden Plugins nach Namen:\n\n```js\nEXEC('counter/increment');\nPLUGINS.counter.increment();\n```\n\n`exports.exec('method', [arguments])` ruft eine Methode desselben Plugins auf. Ruft ein Plugin über `EXEC()` ein anderes auf, findet das aufgerufene Plugin das aufrufende in `exports.caller`:\n\n```html\n<script>\n    PLUGIN('page', function(exports) {\n        exports.refresh = function() {\n            console.log('refreshed by', exports.caller.name);\n        };\n    });\n\n    PLUGIN('page.toolbar', function(exports) {\n        exports.reload = function() {\n            EXEC('page/refresh');\n        };\n    });\n</script>\n\n<ui-plugin path=\"page\">\n    <ui-plugin path=\"toolbar\"></ui-plugin>\n</ui-plugin>\n```\n\n`EXEC('page.toolbar/reload')` gibt `refreshed by page.toolbar` aus.\n\n## Verschachtelte Plugins\n\nEin `<ui-plugin>` innerhalb eines anderen erweitert den Path des übergeordneten. Im obigen Beispiel verwendet das innere Element das Plugin `page.toolbar`, und `PLUGINS['page.toolbar'].parent` gibt das Plugin `page` zurück. Unter [Scopes](../scopes/) steht, wie verschachtelte Paths aufgelöst werden.\n\n## Werte und Events überwachen\n\n`exports.watch()` beobachtet einen Path relativ zum Plugin. `exports.on()` lauscht auf ein globales Event. Beide enden automatisch, wenn das Plugin entfernt wird:\n\n```js\nPLUGIN('clock', function(exports) {\n\n    exports.watch('time', function(value, path, type) {\n        console.log('watch', value, path);\n    });\n\n    exports.on('tick', function(value) {\n        exports.set('time', value);\n    });\n\n    exports.destroy = function() {\n        console.log('destroyed');\n    };\n});\n```\n\n`EMIT('tick', 1)` gibt `watch 1 clock.time` aus. Der Callback von `exports.watch()` erhält zuerst den Wert und dann den Path.\n\n## Eine Deklaration für viele Instanzen\n\nEin Name mit einem Leerzeichen deklariert eine gemeinsame Definition. Das Wort nach dem Leerzeichen ist der Name der Definition, und jedes `<ui-plugin>`, das sie verwendet, erhält eine eigene Instanz auf seinem eigenen Path:\n\n```html\n<script>\n    PLUGIN('? panel', function(exports) {\n        exports.set('title', 'Panel ' + exports.name);\n    });\n</script>\n\n<ui-plugin path=\"left panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"right panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nDiese Seite führt die Plugins `left` und `right` aus, die `Panel left` und `Panel right` anzeigen.\n\n## Plugins bei Bedarf erstellen\n\n`PLUGINABLE(name, declaration)` registriert ein Plugin, ohne es auszuführen. Das Plugin wird beim ersten `EXEC()` erstellt, das es aufruft:\n\n```js\nPLUGINABLE('report', function(exports) {\n    exports.build = function(year) {\n        console.log('building', year);\n    };\n});\n\nPLUGINS.report;              // undefined\nEXEC('report/build', 2024);  // creates the plugin and calls build()\n```\n\n## Den Server aufrufen\n\n`exports.ajax()` sendet eine Anfrage. Der Callback kann eine Funktion oder ein Path relativ zum Plugin sein oder ganz fehlen. Ohne Callback und ohne Daten gibt die Methode ein Promise zurück:\n\n```js\nPLUGIN('users', function(exports) {\n\n    exports.load = function() {\n\n        // A function\n        exports.ajax('GET /api/users/', function(response) {\n            console.log(response);\n        });\n\n        // A path: the response is stored in \"users.saved\"\n        exports.ajax('POST /api/users/', { name: 'Peter' }, 'saved');\n    };\n\n    exports.read = async function() {\n        var response = await exports.ajax('GET /api/users/1/');\n        console.log(response);\n    };\n});\n```\n\n`exports.api()`, `exports.tapi()`, `exports.dapi()` und `exports.upload()` nehmen dieselben Argumente entgegen und verwenden die entsprechende globale Funktion. Siehe die [Plugin-Referenz](../../reference/plugin/).\n\n## Ein Plugin entfernen\n\n`exports.remove()` löst das Event `plugin.destroy` aus, führt das Delegate `exports.destroy()` aus, beendet die Watcher und Events des Plugins und löscht es aus `PLUGINS`. Deklarierst du ein Plugin mit einem bereits vergebenen Namen, wird das laufende Plugin entfernt und ersetzt:\n\n```js\nPLUGIN('editor', function(exports) {\n    exports.destroy = function() {\n        console.log('first instance destroyed');\n    };\n});\n\nPLUGIN('editor', function(exports) {\n    exports.version = 2;\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTx1yM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/plugins/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Plugins","summary":"Organiza la lógica y los datos de una parte de la aplicación con PLUGIN() y ui-plugin.","markdown":"---\ntitle: Plugins\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/plugins/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Plugins\n\n> Organiza la lógica y los datos de una parte de la aplicación con PLUGIN() y ui-plugin.\n\nUn plugin contiene los datos y la lógica de una parte de una aplicación, como una página, un formulario o un panel. Es dueño de un path con su mismo nombre, de modo que el plugin `orders` guarda sus datos en `orders.*`. El HTML se conecta a él con el elemento `<ui-plugin>`.\n\n## Declarar un plugin\n\n`PLUGIN(name, declaration)` crea un plugin. La declaración recibe la instancia del plugin, que normalmente se llama `exports`. Todo lo que le asignes se convierte en un método público:\n\n```html\n<script>\n    PLUGIN('counter', function(exports) {\n\n        exports.set('count', 0);\n\n        exports.increment = function() {\n            exports.inc('count', 1);\n        };\n    });\n</script>\n\n<ui-plugin path=\"counter\">\n    <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nDentro de `<ui-plugin>`, el carácter `?` representa el path del plugin, de modo que `?.count` es `counter.count` y `?/increment` es el método `increment` del plugin. Un elemento con la clase `exec` llama al método indicado en `data-exec` cuando se hace clic en él.\n\nEl nombre `*` declara un plugin en el path común, cuyo nombre procede de `DEF.pathcommon` (`common` por defecto).\n\n## El elemento ui-plugin\n\n`<ui-plugin>` conecta una parte de la página con un plugin. Su atributo `config` contiene los ajustes, y su atributo `default` contiene una expresión JavaScript que se convierte en el modelo del plugin:\n\n```html\n<script>\n    PLUGIN('settings', function(exports) {\n        exports.show = function() {\n            var config = exports.element.scope().config;\n            console.log(config.title, config.size);\n            console.log(exports.model);\n        };\n    });\n</script>\n\n<ui-plugin path=\"settings\" config=\"title:Account;size:10\" default=\"{ theme: 'light' }\"></ui-plugin>\n```\n\n`PLUGINS.settings.show()` imprime `Account 10` y `{ theme: 'light' }`.\n\n`exports.element` es el elemento `<ui-plugin>` una vez que el plugin está conectado a él. Mientras se ejecuta una declaración situada antes del elemento, `exports.element` sigue siendo el `<body>`. Si no hay ningún plugin declarado para el path, la biblioteca crea uno vacío. Todos los atributos están en la [referencia de ui-plugin](../../reference/ui-plugin/).\n\n## Trabajar con datos\n\nLos métodos de un plugin trabajan con paths relativos al plugin. Sin path, trabajan con el modelo completo:\n\n| Método | Descripción |\n| --- | --- |\n| `exports.get([path])` | Lee un valor. |\n| `exports.set([path], value, [type])` | Escribe un valor. |\n| `exports.push([path], value, [type])` | Añade un elemento a un array. |\n| `exports.inc([path], value, [type])` | Incrementa un número. |\n| `exports.extend([path], value, [type])` | Fusiona un objeto con un objeto existente. |\n| `exports.toggle(path, [type])` | Invierte un valor booleano. |\n| `exports.nul(path, [type])` | Escribe `null`. |\n| `exports.upd(path, [type])` | Notifica a los enlaces un cambio que has hecho directamente. |\n| `exports.reset([path])` | Restablece el estado de los campos de formulario que hay bajo el path. |\n| `exports.makepath([path])` | Devuelve el path absoluto. |\n\n```js\nPLUGIN('todo', function(exports) {\n\n    exports.set({ items: [], done: false, total: 1 });\n    exports.push('items', 'Write docs');\n    exports.inc('total', 2);\n    exports.toggle('done');\n\n    exports.get('total');       // 3\n    exports.model.items;        // ['Write docs']\n    exports.makepath('items');  // 'todo.items'\n});\n```\n\nCuatro propiedades leen el modelo directamente:\n\n| Propiedad | Descripción |\n| --- | --- |\n| `exports.model` | Lee o sustituye el modelo completo. |\n| `exports.data` | Igual que `exports.model`. |\n| `exports.form` | Devuelve el modelo y restablece el estado de sus campos de formulario. |\n| `exports.modified` | Devuelve solo los campos que ha cambiado el usuario y restablece el estado de los campos de formulario. |\n\n[Formularios y validación](../forms/) muestra `exports.form` y `exports.modified` en acción.\n\n## Llamar a un plugin\n\nUsa `EXEC()` con el nombre del plugin, una barra y el nombre del método. `PLUGINS` contiene todos los plugins en ejecución por nombre:\n\n```js\nEXEC('counter/increment');\nPLUGINS.counter.increment();\n```\n\n`exports.exec('method', [arguments])` llama a un método del mismo plugin. Cuando un plugin llama a otro mediante `EXEC()`, el plugin llamado encuentra al que lo llama en `exports.caller`:\n\n```html\n<script>\n    PLUGIN('page', function(exports) {\n        exports.refresh = function() {\n            console.log('refreshed by', exports.caller.name);\n        };\n    });\n\n    PLUGIN('page.toolbar', function(exports) {\n        exports.reload = function() {\n            EXEC('page/refresh');\n        };\n    });\n</script>\n\n<ui-plugin path=\"page\">\n    <ui-plugin path=\"toolbar\"></ui-plugin>\n</ui-plugin>\n```\n\n`EXEC('page.toolbar/reload')` imprime `refreshed by page.toolbar`.\n\n## Plugins anidados\n\nUn `<ui-plugin>` dentro de otro amplía el path de su padre. En el ejemplo anterior, el elemento interior usa el plugin `page.toolbar`, y `PLUGINS['page.toolbar'].parent` devuelve el plugin `page`. [Scopes](../scopes/) describe cómo se resuelven los paths anidados.\n\n## Observar valores y eventos\n\n`exports.watch()` observa un path relativo al plugin. `exports.on()` escucha un evento global. Ambos se detienen automáticamente cuando se elimina el plugin:\n\n```js\nPLUGIN('clock', function(exports) {\n\n    exports.watch('time', function(value, path, type) {\n        console.log('watch', value, path);\n    });\n\n    exports.on('tick', function(value) {\n        exports.set('time', value);\n    });\n\n    exports.destroy = function() {\n        console.log('destroyed');\n    };\n});\n```\n\n`EMIT('tick', 1)` imprime `watch 1 clock.time`. El callback de `exports.watch()` recibe primero el valor y después el path.\n\n## Una declaración para muchas instancias\n\nUn nombre con un espacio declara una definición compartida. La palabra que sigue al espacio es el nombre de la definición, y cada `<ui-plugin>` que la usa obtiene su propia instancia en su propio path:\n\n```html\n<script>\n    PLUGIN('? panel', function(exports) {\n        exports.set('title', 'Panel ' + exports.name);\n    });\n</script>\n\n<ui-plugin path=\"left panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"right panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nEsta página ejecuta los plugins `left` y `right`, que muestran `Panel left` y `Panel right`.\n\n## Plugins creados bajo demanda\n\n`PLUGINABLE(name, declaration)` registra un plugin sin ejecutarlo. El plugin se crea con el primer `EXEC()` que lo llama:\n\n```js\nPLUGINABLE('report', function(exports) {\n    exports.build = function(year) {\n        console.log('building', year);\n    };\n});\n\nPLUGINS.report;              // undefined\nEXEC('report/build', 2024);  // creates the plugin and calls build()\n```\n\n## Llamar al servidor\n\n`exports.ajax()` envía una petición. El callback puede ser una función, un path relativo al plugin o no existir. Sin callback y sin datos, el método devuelve una promesa:\n\n```js\nPLUGIN('users', function(exports) {\n\n    exports.load = function() {\n\n        // A function\n        exports.ajax('GET /api/users/', function(response) {\n            console.log(response);\n        });\n\n        // A path: the response is stored in \"users.saved\"\n        exports.ajax('POST /api/users/', { name: 'Peter' }, 'saved');\n    };\n\n    exports.read = async function() {\n        var response = await exports.ajax('GET /api/users/1/');\n        console.log(response);\n    };\n});\n```\n\n`exports.api()`, `exports.tapi()`, `exports.dapi()` y `exports.upload()` admiten los mismos argumentos y usan la función global correspondiente. Consulta la [referencia de Plugin](../../reference/plugin/).\n\n## Eliminar un plugin\n\n`exports.remove()` emite el evento `plugin.destroy`, ejecuta el delegate `exports.destroy()`, detiene los observadores y eventos del plugin y lo borra de `PLUGINS`. Declarar un plugin con un nombre que ya está en uso elimina el plugin en ejecución y lo sustituye:\n\n```js\nPLUGIN('editor', function(exports) {\n    exports.destroy = function() {\n        console.log('first instance destroyed');\n    };\n});\n\nPLUGIN('editor', function(exports) {\n    exports.version = 2;\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTx1yM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/plugins/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Plugins","summary":"Organise la logique et les données d'une partie de l'application avec PLUGIN() et ui-plugin.","markdown":"---\ntitle: Plugins\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/plugins/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Plugins\n\n> Organise la logique et les données d'une partie de l'application avec PLUGIN() et ui-plugin.\n\nUn plugin contient les données et la logique d'une partie d'une application, comme une page, un formulaire ou un panneau. Il possède un path du même nom que lui : le plugin `orders` garde donc ses données dans `orders.*`. Le HTML s'y connecte avec l'élément `<ui-plugin>`.\n\n## Déclarer un plugin\n\n`PLUGIN(name, declaration)` crée un plugin. La déclaration reçoit l'instance du plugin, généralement nommée `exports`. Tout ce que tu lui assignes devient une méthode publique :\n\n```html\n<script>\n    PLUGIN('counter', function(exports) {\n\n        exports.set('count', 0);\n\n        exports.increment = function() {\n            exports.inc('count', 1);\n        };\n    });\n</script>\n\n<ui-plugin path=\"counter\">\n    <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nDans `<ui-plugin>`, le caractère `?` représente le path du plugin : `?.count` correspond donc à `counter.count` et `?/increment` à la méthode `increment` du plugin. Un élément portant la classe `exec` appelle au clic la méthode indiquée dans `data-exec`.\n\nLe nom `*` déclare un plugin sur le path commun, dont le nom provient de `DEF.pathcommon` (`common` par défaut).\n\n## L'élément ui-plugin\n\n`<ui-plugin>` relie une partie de la page à un plugin. Son attribut `config` contient les réglages, et son attribut `default` une expression JavaScript qui devient le modèle de données du plugin :\n\n```html\n<script>\n    PLUGIN('settings', function(exports) {\n        exports.show = function() {\n            var config = exports.element.scope().config;\n            console.log(config.title, config.size);\n            console.log(exports.model);\n        };\n    });\n</script>\n\n<ui-plugin path=\"settings\" config=\"title:Account;size:10\" default=\"{ theme: 'light' }\"></ui-plugin>\n```\n\n`PLUGINS.settings.show()` affiche `Account 10` et `{ theme: 'light' }`.\n\n`exports.element` est l'élément `<ui-plugin>` une fois le plugin connecté à celui-ci. Tant qu'une déclaration placée avant l'élément s'exécute, `exports.element` reste le `<body>`. Si aucun plugin n'est déclaré pour le path, la bibliothèque en crée un vide. Tous les attributs figurent dans la [référence ui-plugin](../../reference/ui-plugin/).\n\n## Manipuler les données\n\nLes méthodes d'un plugin utilisent des paths relatifs au plugin. Sans path, elles portent sur le modèle de données entier :\n\n| Méthode | Description |\n| --- | --- |\n| `exports.get([path])` | Lit une valeur. |\n| `exports.set([path], value, [type])` | Écrit une valeur. |\n| `exports.push([path], value, [type])` | Ajoute un élément à un tableau. |\n| `exports.inc([path], value, [type])` | Augmente un nombre. |\n| `exports.extend([path], value, [type])` | Fusionne un objet dans un objet existant. |\n| `exports.toggle(path, [type])` | Inverse une valeur booléenne. |\n| `exports.nul(path, [type])` | Écrit `null`. |\n| `exports.upd(path, [type])` | Notifie les liaisons d'un changement effectué directement. |\n| `exports.reset([path])` | Réinitialise l'état des champs de formulaire situés sous le path. |\n| `exports.makepath([path])` | Renvoie le path absolu. |\n\n```js\nPLUGIN('todo', function(exports) {\n\n    exports.set({ items: [], done: false, total: 1 });\n    exports.push('items', 'Write docs');\n    exports.inc('total', 2);\n    exports.toggle('done');\n\n    exports.get('total');       // 3\n    exports.model.items;        // ['Write docs']\n    exports.makepath('items');  // 'todo.items'\n});\n```\n\nQuatre propriétés lisent directement le modèle de données :\n\n| Propriété | Description |\n| --- | --- |\n| `exports.model` | Lit ou remplace le modèle de données entier. |\n| `exports.data` | Identique à `exports.model`. |\n| `exports.form` | Renvoie le modèle de données et réinitialise l'état de ses champs de formulaire. |\n| `exports.modified` | Renvoie uniquement les champs modifiés par l'utilisateur et réinitialise l'état des champs de formulaire. |\n\n[Formulaires et validation](../forms/) montre `exports.form` et `exports.modified` en pratique.\n\n## Appeler un plugin\n\nUtilise `EXEC()` avec le nom du plugin, une barre oblique et le nom de la méthode. `PLUGINS` contient tous les plugins en cours d'exécution, classés par nom :\n\n```js\nEXEC('counter/increment');\nPLUGINS.counter.increment();\n```\n\n`exports.exec('method', [arguments])` appelle une méthode du même plugin. Quand un plugin en appelle un autre avec `EXEC()`, le plugin appelé trouve le plugin appelant dans `exports.caller` :\n\n```html\n<script>\n    PLUGIN('page', function(exports) {\n        exports.refresh = function() {\n            console.log('refreshed by', exports.caller.name);\n        };\n    });\n\n    PLUGIN('page.toolbar', function(exports) {\n        exports.reload = function() {\n            EXEC('page/refresh');\n        };\n    });\n</script>\n\n<ui-plugin path=\"page\">\n    <ui-plugin path=\"toolbar\"></ui-plugin>\n</ui-plugin>\n```\n\n`EXEC('page.toolbar/reload')` affiche `refreshed by page.toolbar`.\n\n## Plugins imbriqués\n\nUn `<ui-plugin>` placé dans un autre prolonge le path de son parent. Dans l'exemple ci-dessus, l'élément interne utilise le plugin `page.toolbar`, et `PLUGINS['page.toolbar'].parent` renvoie le plugin `page`. [Scopes](../scopes/) décrit comment les paths imbriqués sont résolus.\n\n## Observer des valeurs et des événements\n\n`exports.watch()` observe un path relatif au plugin. `exports.on()` écoute un événement global. Les deux s'arrêtent automatiquement quand le plugin est supprimé :\n\n```js\nPLUGIN('clock', function(exports) {\n\n    exports.watch('time', function(value, path, type) {\n        console.log('watch', value, path);\n    });\n\n    exports.on('tick', function(value) {\n        exports.set('time', value);\n    });\n\n    exports.destroy = function() {\n        console.log('destroyed');\n    };\n});\n```\n\n`EMIT('tick', 1)` affiche `watch 1 clock.time`. Le callback de `exports.watch()` reçoit d'abord la valeur, puis le path.\n\n## Une déclaration pour plusieurs instances\n\nUn nom contenant une espace déclare une définition partagée. Le mot situé après l'espace est le nom de la définition, et chaque `<ui-plugin>` qui l'utilise obtient sa propre instance sur son propre path :\n\n```html\n<script>\n    PLUGIN('? panel', function(exports) {\n        exports.set('title', 'Panel ' + exports.name);\n    });\n</script>\n\n<ui-plugin path=\"left panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"right panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nCette page exécute les plugins `left` et `right`, qui affichent `Panel left` et `Panel right`.\n\n## Plugins créés à la demande\n\n`PLUGINABLE(name, declaration)` enregistre un plugin sans l'exécuter. Le plugin est créé par le premier `EXEC()` qui l'appelle :\n\n```js\nPLUGINABLE('report', function(exports) {\n    exports.build = function(year) {\n        console.log('building', year);\n    };\n});\n\nPLUGINS.report;              // undefined\nEXEC('report/build', 2024);  // creates the plugin and calls build()\n```\n\n## Appeler le serveur\n\n`exports.ajax()` envoie une requête. Le callback peut être une fonction, un path relatif au plugin, ou être absent. Sans callback et sans données, la méthode renvoie une promesse :\n\n```js\nPLUGIN('users', function(exports) {\n\n    exports.load = function() {\n\n        // A function\n        exports.ajax('GET /api/users/', function(response) {\n            console.log(response);\n        });\n\n        // A path: the response is stored in \"users.saved\"\n        exports.ajax('POST /api/users/', { name: 'Peter' }, 'saved');\n    };\n\n    exports.read = async function() {\n        var response = await exports.ajax('GET /api/users/1/');\n        console.log(response);\n    };\n});\n```\n\n`exports.api()`, `exports.tapi()`, `exports.dapi()` et `exports.upload()` acceptent les mêmes arguments et utilisent la fonction globale correspondante. Consulte la [référence Plugin](../../reference/plugin/).\n\n## Supprimer un plugin\n\n`exports.remove()` émet l'événement `plugin.destroy`, exécute le delegate `exports.destroy()`, arrête les observateurs et les événements du plugin, puis le retire de `PLUGINS`. Déclarer un plugin avec un nom déjà utilisé supprime le plugin en cours d'exécution et le remplace :\n\n```js\nPLUGIN('editor', function(exports) {\n    exports.destroy = function() {\n        console.log('first instance destroyed');\n    };\n});\n\nPLUGIN('editor', function(exports) {\n    exports.version = 2;\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTx1yM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/plugins/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Plugin","summary":"Organizza la logica e i dati di una parte dell'applicazione con PLUGIN() e ui-plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/plugins/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Plugin\n\n> Organizza la logica e i dati di una parte dell'applicazione con PLUGIN() e ui-plugin.\n\nUn plugin contiene i dati e la logica di una parte di un'applicazione, come una pagina, un modulo o un pannello. Possiede un path con lo stesso nome del plugin, quindi il plugin `orders` conserva i suoi dati in `orders.*`. L'HTML si collega al plugin tramite l'elemento `<ui-plugin>`.\n\n## Dichiarare un plugin\n\n`PLUGIN(name, declaration)` crea un plugin. La dichiarazione riceve l'istanza del plugin, di solito chiamata `exports`. Tutto ciò che le assegni diventa un metodo pubblico:\n\n```html\n<script>\n    PLUGIN('counter', function(exports) {\n\n        exports.set('count', 0);\n\n        exports.increment = function() {\n            exports.inc('count', 1);\n        };\n    });\n</script>\n\n<ui-plugin path=\"counter\">\n    <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nAll'interno di `<ui-plugin>`, il carattere `?` rappresenta il path del plugin, quindi `?.count` è `counter.count` e `?/increment` è il metodo `increment` del plugin. Un elemento con la classe `exec` chiama, al clic, il metodo indicato in `data-exec`.\n\nIl nome `*` dichiara un plugin sul path comune, il cui nome deriva da `DEF.pathcommon` (`common` per impostazione predefinita).\n\n## L'elemento ui-plugin\n\n`<ui-plugin>` collega una parte della pagina a un plugin. Il suo attributo `config` contiene le impostazioni e il suo attributo `default` contiene un'espressione JavaScript che diventa il modello del plugin:\n\n```html\n<script>\n    PLUGIN('settings', function(exports) {\n        exports.show = function() {\n            var config = exports.element.scope().config;\n            console.log(config.title, config.size);\n            console.log(exports.model);\n        };\n    });\n</script>\n\n<ui-plugin path=\"settings\" config=\"title:Account;size:10\" default=\"{ theme: 'light' }\"></ui-plugin>\n```\n\n`PLUGINS.settings.show()` stampa `Account 10` e `{ theme: 'light' }`.\n\n`exports.element` è l'elemento `<ui-plugin>` una volta che il plugin è collegato a esso. Mentre viene eseguita una dichiarazione posta prima dell'elemento, `exports.element` è ancora il `<body>`. Se per il path non è dichiarato alcun plugin, la libreria ne crea uno vuoto. Trovi tutti gli attributi nel [riferimento di ui-plugin](../../reference/ui-plugin/).\n\n## Lavorare con i dati\n\nI metodi di un plugin lavorano con path relativi al plugin. Senza un path, lavorano con l'intero modello:\n\n| Metodo | Descrizione |\n| --- | --- |\n| `exports.get([path])` | Legge un valore. |\n| `exports.set([path], value, [type])` | Scrive un valore. |\n| `exports.push([path], value, [type])` | Aggiunge un elemento a un array. |\n| `exports.inc([path], value, [type])` | Incrementa un numero. |\n| `exports.extend([path], value, [type])` | Unisce un oggetto a un oggetto esistente. |\n| `exports.toggle(path, [type])` | Inverte un valore booleano. |\n| `exports.nul(path, [type])` | Scrive `null`. |\n| `exports.upd(path, [type])` | Notifica alle associazioni una modifica che hai fatto direttamente. |\n| `exports.reset([path])` | Reimposta lo stato dei campi del modulo sotto il path. |\n| `exports.makepath([path])` | Restituisce il path assoluto. |\n\n```js\nPLUGIN('todo', function(exports) {\n\n    exports.set({ items: [], done: false, total: 1 });\n    exports.push('items', 'Write docs');\n    exports.inc('total', 2);\n    exports.toggle('done');\n\n    exports.get('total');       // 3\n    exports.model.items;        // ['Write docs']\n    exports.makepath('items');  // 'todo.items'\n});\n```\n\nQuattro proprietà leggono direttamente il modello:\n\n| Proprietà | Descrizione |\n| --- | --- |\n| `exports.model` | Legge o sostituisce l'intero modello. |\n| `exports.data` | Uguale a `exports.model`. |\n| `exports.form` | Restituisce il modello e reimposta lo stato dei suoi campi del modulo. |\n| `exports.modified` | Restituisce solo i campi modificati dall'utente e reimposta lo stato dei campi del modulo. |\n\n[Moduli e validazione](../forms/) mostra `exports.form` e `exports.modified` in azione.\n\n## Chiamare un plugin\n\nUsa `EXEC()` con il nome del plugin, una barra e il nome del metodo. `PLUGINS` contiene tutti i plugin in esecuzione, per nome:\n\n```js\nEXEC('counter/increment');\nPLUGINS.counter.increment();\n```\n\n`exports.exec('method', [arguments])` chiama un metodo dello stesso plugin. Quando un plugin ne chiama un altro tramite `EXEC()`, il plugin chiamato trova il plugin chiamante in `exports.caller`:\n\n```html\n<script>\n    PLUGIN('page', function(exports) {\n        exports.refresh = function() {\n            console.log('refreshed by', exports.caller.name);\n        };\n    });\n\n    PLUGIN('page.toolbar', function(exports) {\n        exports.reload = function() {\n            EXEC('page/refresh');\n        };\n    });\n</script>\n\n<ui-plugin path=\"page\">\n    <ui-plugin path=\"toolbar\"></ui-plugin>\n</ui-plugin>\n```\n\n`EXEC('page.toolbar/reload')` stampa `refreshed by page.toolbar`.\n\n## Plugin annidati\n\nUn `<ui-plugin>` all'interno di un altro estende il path del genitore. Nell'esempio precedente, l'elemento interno usa il plugin `page.toolbar` e `PLUGINS['page.toolbar'].parent` restituisce il plugin `page`. [Scope](../scopes/) descrive come vengono risolti i path annidati.\n\n## Osservare valori ed eventi\n\n`exports.watch()` osserva un path relativo al plugin. `exports.on()` ascolta un evento globale. Entrambi si interrompono automaticamente quando il plugin viene rimosso:\n\n```js\nPLUGIN('clock', function(exports) {\n\n    exports.watch('time', function(value, path, type) {\n        console.log('watch', value, path);\n    });\n\n    exports.on('tick', function(value) {\n        exports.set('time', value);\n    });\n\n    exports.destroy = function() {\n        console.log('destroyed');\n    };\n});\n```\n\n`EMIT('tick', 1)` stampa `watch 1 clock.time`. La callback di `exports.watch()` riceve prima il valore e poi il path.\n\n## Una dichiarazione per molte istanze\n\nUn nome con uno spazio dichiara una definizione condivisa. La parola dopo lo spazio è il nome della definizione, e ogni `<ui-plugin>` che la usa ottiene una propria istanza sul proprio path:\n\n```html\n<script>\n    PLUGIN('? panel', function(exports) {\n        exports.set('title', 'Panel ' + exports.name);\n    });\n</script>\n\n<ui-plugin path=\"left panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"right panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nQuesta pagina esegue i plugin `left` e `right`, che mostrano `Panel left` e `Panel right`.\n\n## Plugin creati su richiesta\n\n`PLUGINABLE(name, declaration)` registra un plugin senza eseguirlo. Il plugin viene creato dal primo `EXEC()` che lo chiama:\n\n```js\nPLUGINABLE('report', function(exports) {\n    exports.build = function(year) {\n        console.log('building', year);\n    };\n});\n\nPLUGINS.report;              // undefined\nEXEC('report/build', 2024);  // creates the plugin and calls build()\n```\n\n## Chiamare il server\n\n`exports.ajax()` invia una richiesta. La callback può essere una funzione, un path relativo al plugin, oppure può mancare. Senza callback e senza dati, il metodo restituisce una promise:\n\n```js\nPLUGIN('users', function(exports) {\n\n    exports.load = function() {\n\n        // A function\n        exports.ajax('GET /api/users/', function(response) {\n            console.log(response);\n        });\n\n        // A path: the response is stored in \"users.saved\"\n        exports.ajax('POST /api/users/', { name: 'Peter' }, 'saved');\n    };\n\n    exports.read = async function() {\n        var response = await exports.ajax('GET /api/users/1/');\n        console.log(response);\n    };\n});\n```\n\n`exports.api()`, `exports.tapi()`, `exports.dapi()` e `exports.upload()` accettano gli stessi argomenti e usano la funzione globale corrispondente. Consulta il [riferimento di Plugin](../../reference/plugin/).\n\n## Rimuovere un plugin\n\n`exports.remove()` emette l'evento `plugin.destroy`, esegue il delegate `exports.destroy()`, ferma gli osservatori e gli eventi del plugin e lo elimina da `PLUGINS`. Dichiarare un plugin con un nome già in uso rimuove il plugin in esecuzione e lo sostituisce:\n\n```js\nPLUGIN('editor', function(exports) {\n    exports.destroy = function() {\n        console.log('first instance destroyed');\n    };\n});\n\nPLUGIN('editor', function(exports) {\n    exports.version = 2;\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTx1yM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/plugins/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Pluginy","summary":"Usporiadaj logiku a dáta časti aplikácie pomocou PLUGIN() a ui-plugin.","markdown":"---\ntitle: Pluginy\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/plugins/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Pluginy\n\n> Usporiadaj logiku a dáta časti aplikácie pomocou PLUGIN() a ui-plugin.\n\nPlugin obsahuje dáta a logiku jednej časti aplikácie, napríklad stránky, formulára alebo panelu. Patrí mu path s rovnakým názvom, ako má plugin, takže plugin `orders` uchováva svoje dáta v `orders.*`. HTML sa k nemu pripája elementom `<ui-plugin>`.\n\n## Deklarácia pluginu\n\n`PLUGIN(name, declaration)` vytvorí plugin. Deklarácia dostane inštanciu pluginu, zvyčajne pomenovanú `exports`. Všetko, čo jej priradíš, sa stane verejnou metódou:\n\n```html\n<script>\n    PLUGIN('counter', function(exports) {\n\n        exports.set('count', 0);\n\n        exports.increment = function() {\n            exports.inc('count', 1);\n        };\n    });\n</script>\n\n<ui-plugin path=\"counter\">\n    <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nVnútri `<ui-plugin>` zastupuje znak `?` path pluginu, takže `?.count` je `counter.count` a `?/increment` je metóda `increment` pluginu. Element s triedou `exec` po kliknutí zavolá metódu uvedenú v `data-exec`.\n\nNázov `*` deklaruje plugin na spoločnom path, ktorého názov pochádza z `DEF.pathcommon` (predvolene `common`).\n\n## Element ui-plugin\n\n`<ui-plugin>` spája časť stránky s pluginom. Jeho atribút `config` obsahuje nastavenia a atribút `default` obsahuje výraz JavaScriptu, ktorý sa stane modelom pluginu:\n\n```html\n<script>\n    PLUGIN('settings', function(exports) {\n        exports.show = function() {\n            var config = exports.element.scope().config;\n            console.log(config.title, config.size);\n            console.log(exports.model);\n        };\n    });\n</script>\n\n<ui-plugin path=\"settings\" config=\"title:Account;size:10\" default=\"{ theme: 'light' }\"></ui-plugin>\n```\n\n`PLUGINS.settings.show()` vypíše `Account 10` a `{ theme: 'light' }`.\n\n`exports.element` je element `<ui-plugin>`, keď je k nemu plugin pripojený. Kým beží deklarácia umiestnená pred elementom, `exports.element` je ešte `<body>`. Ak pre daný path nie je deklarovaný žiadny plugin, knižnica vytvorí prázdny. Všetky atribúty nájdeš v [referencii ui-plugin](../../reference/ui-plugin/).\n\n## Práca s dátami\n\nMetódy pluginu pracujú s paths relatívnymi voči pluginu. Bez path pracujú s celým modelom:\n\n| Metóda | Popis |\n| --- | --- |\n| `exports.get([path])` | Prečíta hodnotu. |\n| `exports.set([path], value, [type])` | Zapíše hodnotu. |\n| `exports.push([path], value, [type])` | Pridá položku do poľa. |\n| `exports.inc([path], value, [type])` | Zvýši číslo. |\n| `exports.extend([path], value, [type])` | Zlúči objekt s existujúcim objektom. |\n| `exports.toggle(path, [type])` | Invertuje logickú hodnotu. |\n| `exports.nul(path, [type])` | Zapíše `null`. |\n| `exports.upd(path, [type])` | Upozorní väzby na zmenu, ktorú si urobil priamo. |\n| `exports.reset([path])` | Vynuluje stav polí formulára pod daným path. |\n| `exports.makepath([path])` | Vráti absolútny path. |\n\n```js\nPLUGIN('todo', function(exports) {\n\n    exports.set({ items: [], done: false, total: 1 });\n    exports.push('items', 'Write docs');\n    exports.inc('total', 2);\n    exports.toggle('done');\n\n    exports.get('total');       // 3\n    exports.model.items;        // ['Write docs']\n    exports.makepath('items');  // 'todo.items'\n});\n```\n\nŠtyri vlastnosti čítajú model priamo:\n\n| Vlastnosť | Popis |\n| --- | --- |\n| `exports.model` | Prečíta alebo nahradí celý model. |\n| `exports.data` | To isté ako `exports.model`. |\n| `exports.form` | Vráti model a vynuluje stav jeho polí formulára. |\n| `exports.modified` | Vráti iba polia, ktoré používateľ zmenil, a vynuluje stav polí formulára. |\n\n[Formuláre a validácia](../forms/) ukazuje použitie `exports.form` a `exports.modified`.\n\n## Volanie pluginu\n\nPouži `EXEC()` s názvom pluginu, lomkou a názvom metódy. `PLUGINS` obsahuje všetky bežiace pluginy podľa názvu:\n\n```js\nEXEC('counter/increment');\nPLUGINS.counter.increment();\n```\n\n`exports.exec('method', [arguments])` zavolá metódu toho istého pluginu. Keď jeden plugin volá iný cez `EXEC()`, volaný plugin nájde volajúci plugin v `exports.caller`:\n\n```html\n<script>\n    PLUGIN('page', function(exports) {\n        exports.refresh = function() {\n            console.log('refreshed by', exports.caller.name);\n        };\n    });\n\n    PLUGIN('page.toolbar', function(exports) {\n        exports.reload = function() {\n            EXEC('page/refresh');\n        };\n    });\n</script>\n\n<ui-plugin path=\"page\">\n    <ui-plugin path=\"toolbar\"></ui-plugin>\n</ui-plugin>\n```\n\n`EXEC('page.toolbar/reload')` vypíše `refreshed by page.toolbar`.\n\n## Vnorené pluginy\n\nElement `<ui-plugin>` vnútri iného rozširuje path svojho rodiča. V príklade vyššie používa vnútorný element plugin `page.toolbar` a `PLUGINS['page.toolbar'].parent` vráti plugin `page`. Časť [Scopes](../scopes/) popisuje, ako sa vnorené paths vyhodnocujú.\n\n## Sledovanie hodnôt a udalostí\n\n`exports.watch()` sleduje path relatívny voči pluginu. `exports.on()` počúva globálnu udalosť. Obe sa pri odstránení pluginu automaticky zastavia:\n\n```js\nPLUGIN('clock', function(exports) {\n\n    exports.watch('time', function(value, path, type) {\n        console.log('watch', value, path);\n    });\n\n    exports.on('tick', function(value) {\n        exports.set('time', value);\n    });\n\n    exports.destroy = function() {\n        console.log('destroyed');\n    };\n});\n```\n\n`EMIT('tick', 1)` vypíše `watch 1 clock.time`. Callback metódy `exports.watch()` dostane najprv hodnotu a potom path.\n\n## Jedna deklarácia pre viac inštancií\n\nNázov s medzerou deklaruje zdieľanú definíciu. Slovo za medzerou je názov definície a každý `<ui-plugin>`, ktorý ju používa, dostane vlastnú inštanciu na vlastnom path:\n\n```html\n<script>\n    PLUGIN('? panel', function(exports) {\n        exports.set('title', 'Panel ' + exports.name);\n    });\n</script>\n\n<ui-plugin path=\"left panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-plugin path=\"right panel\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nNa tejto stránke bežia pluginy `left` a `right`, ktoré zobrazujú `Panel left` a `Panel right`.\n\n## Pluginy vytvárané na požiadanie\n\n`PLUGINABLE(name, declaration)` zaregistruje plugin bez jeho spustenia. Plugin vytvorí prvé `EXEC()`, ktoré ho zavolá:\n\n```js\nPLUGINABLE('report', function(exports) {\n    exports.build = function(year) {\n        console.log('building', year);\n    };\n});\n\nPLUGINS.report;              // undefined\nEXEC('report/build', 2024);  // creates the plugin and calls build()\n```\n\n## Volanie servera\n\n`exports.ajax()` odošle požiadavku. Callback môže byť funkcia, path relatívny voči pluginu, alebo môže chýbať. Bez callbacku a bez dát vráti metóda promise:\n\n```js\nPLUGIN('users', function(exports) {\n\n    exports.load = function() {\n\n        // A function\n        exports.ajax('GET /api/users/', function(response) {\n            console.log(response);\n        });\n\n        // A path: the response is stored in \"users.saved\"\n        exports.ajax('POST /api/users/', { name: 'Peter' }, 'saved');\n    };\n\n    exports.read = async function() {\n        var response = await exports.ajax('GET /api/users/1/');\n        console.log(response);\n    };\n});\n```\n\n`exports.api()`, `exports.tapi()`, `exports.dapi()` a `exports.upload()` prijímajú rovnaké argumenty a používajú príslušnú globálnu funkciu. Pozri [referenciu Plugin](../../reference/plugin/).\n\n## Odstránenie pluginu\n\n`exports.remove()` vyšle udalosť `plugin.destroy`, spustí delegate `exports.destroy()`, zastaví sledovače a udalosti pluginu a vymaže ho z `PLUGINS`. Deklarácia pluginu s názvom, ktorý sa už používa, bežiaci plugin odstráni a nahradí ho:\n\n```js\nPLUGIN('editor', function(exports) {\n    exports.destroy = function() {\n        console.log('first instance destroyed');\n    };\n});\n\nPLUGIN('editor', function(exports) {\n    exports.version = 2;\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTh1oM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/importing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Importing content","summary":"Load HTML, scripts and stylesheets on demand with IMPORT() and the ui-import element.","markdown":"---\ntitle: Importing content\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/importing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Importing content\n\n> Load HTML, scripts and stylesheets on demand with IMPORT() and the ui-import element.\n\nAn application does not have to load everything at once. `IMPORT()` downloads HTML, scripts and stylesheets when you ask for them, and the `<ui-import>` element does the same from the markup.\n\n## Importing HTML\n\n`IMPORT(url, [target], [callback], [insert], [preparator])` downloads a file and adds it to the page.\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `url` | String or Array | The address of the file, or a list of addresses. |\n| `target` | String, jQuery or Element | Where the content goes. The default is `body`. |\n| `callback` | Function | Runs when the import is finished and receives a status. |\n| `insert` | Boolean | `false` replaces the content of the target. Any other value appends to it. |\n| `preparator` | Function | Receives the downloaded text and returns the text to insert. |\n\n```html\n<div id=\"box\"><i>Loading</i></div>\n\n<script>\n    IMPORT('/parts/hello.html', '#box', function(status) {\n        console.log(status);\n    });\n</script>\n```\n\nIf `/parts/hello.html` contains `<b>Hello from the server</b>`, the status is `1` and the target contains `<i>Loading</i><b>Hello from the server</b>`. The status is `0` when nothing was imported: the response was empty, or the file was skipped by one of the conditions described below.\n\nYou can leave `target` out and pass the callback as the second argument.\n\n### Replacing and changing the content\n\nPass `false` to replace what is in the target, and a function to change the text ahead of insertion:\n\n```js\nIMPORT('/parts/hello.html', '#box', function() {\n    console.log($('#box').html());\n}, false, function(response) {\n    return response.replace('Hello', 'Welcome');\n});\n```\n\nThe target now holds only `<b>Welcome from the server</b>`.\n\n### What happens with the content\n\n- `<style>` blocks move to the `<head>`.\n- `<script>` blocks run.\n- Components, bindings and plugins in the content are compiled.\n- Text marked with `@(...)` is translated, see [Localization](../localization/).\n\n## Importing scripts and stylesheets\n\nThe extension decides how a file is loaded. `.js` adds a `<script>` element and `.css` adds a `<link>` element to the `<head>`, and the target is not used. If the address has no suitable extension, add one at the end, separated by a space:\n\n```js\nIMPORT('/assets/chart.js', function() {\n    // The script is ready\n});\n\nIMPORT('/assets/theme.css');\n\nIMPORT('/download?file=chart .js');\n```\n\nThe callback of a `.js` or `.css` file runs only when the file loads. It does not run when the download fails.\n\n## Importing a file once\n\nThe prefix `once ` (or `!`) imports a file a single time. Further imports of the same address do nothing and call the callback with the status `0`:\n\n```js\nIMPORT('once /parts/hello.html', '#box', function(status) {\n    console.log(status); // 1\n\n    IMPORT('once /parts/hello.html', '#box', function(status) {\n        console.log(status); // 0\n    });\n});\n```\n\n## Importing a file conditionally\n\nA path in angle brackets skips the import when the value of the path is truthy. Add `()` to call a function and use its result. This is the usual way to load a library only when it is missing:\n\n```js\nIMPORT('<window.Chart> /assets/chart.js', function(status) {\n    // status is 0 when window.Chart already exists\n});\n```\n\n## Importing several files\n\nAn array imports the files one after another. The callback runs after the last one and receives no status:\n\n```js\nIMPORT(['/parts/hello.html', '/parts/widget.html'], '#box', function() {\n    // Both files are in #box\n});\n```\n\n## Caching a response\n\n`IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])` works like `IMPORT()` and keeps the downloaded HTML for the given time:\n\n```js\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#box');\n```\n\n## The ui-import element\n\n`<ui-import>` imports a file when the element appears on the page. The content replaces whatever the element contains:\n\n```html\n<ui-import config=\"url:/parts/widget.html;path:orders;id:w1\"></ui-import>\n```\n\nThe most used settings of the `config` attribute:\n\n| Setting | Description |\n| --- | --- |\n| `url` | The address of the file. |\n| `path` | The value of the `~PATH~` placeholder. |\n| `id` | The value of the `~ID~` placeholder. |\n| `replace` | `true` replaces the element itself with the content. |\n| `target` | A selector of the element that receives the content. |\n| `make` | The path of a function that receives `(response, element, path)` and returns the text to insert. |\n| `init` | The path of a function that runs after the import and receives the element. |\n| `cache` | How long to keep the response, for example `5 minutes`. |\n| `reevaluate` | `true` keeps scripts and styles when the same address is imported again. |\n\n```html\n<ui-import config=\"url:/parts/hello.html;make:prepare;init:ready\"></ui-import>\n\n<script>\n    function prepare(response, element, path) {\n        return response.replace('server', 'browser');\n    }\n\n    function ready(element) {\n        console.log(element.text()); // Hello from the browser\n    }\n</script>\n```\n\nThe first import of an address runs its scripts and styles. Next imports of the same address remove them from the content, so one file placed on a page three times does not run its script three times. Use `reevaluate:true` when every copy has to run its script. The [ui-import reference](../../reference/ui-import/) describes every setting.\n\n## Reusing a file with placeholders\n\nPlaceholders let one file serve several places. `<ui-import>` replaces `~PATH~` with `path` and `~ID~` with `id`. `PLUGIN(function(` in the file gets the path as the plugin name:\n\n```html\n<!-- /parts/plugin.html -->\n<ui-plugin path=\"~PATH~\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n    PLUGIN(function(exports) {\n        exports.set('title', 'Plugin ' + exports.name);\n    });\n</script>\n```\n\n```html\n<ui-import config=\"url:/parts/plugin.html;path:orders\"></ui-import>\n<ui-import config=\"url:/parts/plugin.html;path:users;reevaluate:true\"></ui-import>\n```\n\nThe page now runs the plugins `orders` and `users`, showing `Plugin orders` and `Plugin users`. See [Plugins](../plugins/).\n\n## Importing from a component\n\nA component imports into its own element with `self.import(url, [callback], [insert], [preparator])`. See [Creating components](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTh1oM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/importing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Inhalte importieren","summary":"Lade HTML, Skripte und Stylesheets bei Bedarf mit IMPORT() und dem Element ui-import.","markdown":"---\ntitle: Inhalte importieren\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/importing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Inhalte importieren\n\n> Lade HTML, Skripte und Stylesheets bei Bedarf mit IMPORT() und dem Element ui-import.\n\nEine Anwendung muss nicht alles auf einmal laden. `IMPORT()` lädt HTML, Skripte und Stylesheets herunter, wenn du sie anforderst, und das Element `<ui-import>` tut dasselbe direkt aus dem Markup.\n\n## HTML importieren\n\n`IMPORT(url, [target], [callback], [insert], [preparator])` lädt eine Datei herunter und fügt sie der Seite hinzu.\n\n| Argument | Typ | Beschreibung |\n| --- | --- | --- |\n| `url` | String oder Array | Die Adresse der Datei oder eine Liste von Adressen. |\n| `target` | String, jQuery oder Element | Wohin der Inhalt kommt. Der Standardwert ist `body`. |\n| `callback` | Funktion | Läuft, wenn der Import abgeschlossen ist, und erhält einen Status. |\n| `insert` | Boolean | `false` ersetzt den Inhalt des Ziels. Jeder andere Wert hängt an ihn an. |\n| `preparator` | Funktion | Erhält den heruntergeladenen Text und gibt den einzufügenden Text zurück. |\n\n```html\n<div id=\"box\"><i>Loading</i></div>\n\n<script>\n    IMPORT('/parts/hello.html', '#box', function(status) {\n        console.log(status);\n    });\n</script>\n```\n\nEnthält `/parts/hello.html` den Inhalt `<b>Hello from the server</b>`, ist der Status `1`, und das Ziel enthält `<i>Loading</i><b>Hello from the server</b>`. Der Status ist `0`, wenn nichts importiert wurde: Die Antwort war leer, oder die Datei wurde durch eine der unten beschriebenen Bedingungen übersprungen.\n\nDu kannst `target` weglassen und den Callback als zweites Argument übergeben.\n\n### Den Inhalt ersetzen und ändern\n\nÜbergib `false`, um den Inhalt des Ziels zu ersetzen, und eine Funktion, um den Text vor dem Einfügen zu ändern:\n\n```js\nIMPORT('/parts/hello.html', '#box', function() {\n    console.log($('#box').html());\n}, false, function(response) {\n    return response.replace('Hello', 'Welcome');\n});\n```\n\nDas Ziel enthält jetzt nur noch `<b>Welcome from the server</b>`.\n\n### Was mit dem Inhalt passiert\n\n- `<style>`-Blöcke wandern in den `<head>`.\n- `<script>`-Blöcke werden ausgeführt.\n- Komponenten, Bindungen und Plugins im Inhalt werden kompiliert.\n- Mit `@(...)` markierter Text wird übersetzt, siehe [Lokalisierung](../localization/).\n\n## Skripte und Stylesheets importieren\n\nDie Dateiendung entscheidet, wie eine Datei geladen wird. `.js` fügt dem `<head>` ein `<script>`-Element hinzu und `.css` ein `<link>`-Element, das Ziel wird dabei nicht verwendet. Hat die Adresse keine passende Endung, hängst du eine durch ein Leerzeichen getrennt an:\n\n```js\nIMPORT('/assets/chart.js', function() {\n    // The script is ready\n});\n\nIMPORT('/assets/theme.css');\n\nIMPORT('/download?file=chart .js');\n```\n\nDer Callback einer `.js`- oder `.css`-Datei läuft nur, wenn die Datei geladen wird. Schlägt der Download fehl, läuft er nicht.\n\n## Eine Datei nur einmal importieren\n\nDas Präfix `once ` (oder `!`) importiert eine Datei ein einziges Mal. Weitere Importe derselben Adresse bewirken nichts und rufen den Callback mit dem Status `0` auf:\n\n```js\nIMPORT('once /parts/hello.html', '#box', function(status) {\n    console.log(status); // 1\n\n    IMPORT('once /parts/hello.html', '#box', function(status) {\n        console.log(status); // 0\n    });\n});\n```\n\n## Eine Datei bedingt importieren\n\nEin Path in spitzen Klammern überspringt den Import, wenn der Wert des Paths truthy ist. Füge `()` hinzu, um eine Funktion aufzurufen und ihr Ergebnis zu verwenden. So lädst du üblicherweise eine Bibliothek nur dann, wenn sie fehlt:\n\n```js\nIMPORT('<window.Chart> /assets/chart.js', function(status) {\n    // status is 0 when window.Chart already exists\n});\n```\n\n## Mehrere Dateien importieren\n\nEin Array importiert die Dateien nacheinander. Der Callback läuft nach der letzten Datei und erhält keinen Status:\n\n```js\nIMPORT(['/parts/hello.html', '/parts/widget.html'], '#box', function() {\n    // Both files are in #box\n});\n```\n\n## Eine Antwort cachen\n\n`IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])` funktioniert wie `IMPORT()` und behält das heruntergeladene HTML für die angegebene Zeit:\n\n```js\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#box');\n```\n\n## Das Element ui-import\n\n`<ui-import>` importiert eine Datei, sobald das Element auf der Seite erscheint. Der Inhalt ersetzt alles, was das Element enthält:\n\n```html\n<ui-import config=\"url:/parts/widget.html;path:orders;id:w1\"></ui-import>\n```\n\nDie meistgenutzten Einstellungen des Attributs `config`:\n\n| Einstellung | Beschreibung |\n| --- | --- |\n| `url` | Die Adresse der Datei. |\n| `path` | Der Wert des Platzhalters `~PATH~`. |\n| `id` | Der Wert des Platzhalters `~ID~`. |\n| `replace` | `true` ersetzt das Element selbst durch den Inhalt. |\n| `target` | Ein Selektor des Elements, das den Inhalt erhält. |\n| `make` | Der Path einer Funktion, die `(response, element, path)` erhält und den einzufügenden Text zurückgibt. |\n| `init` | Der Path einer Funktion, die nach dem Import läuft und das Element erhält. |\n| `cache` | Wie lange die Antwort aufbewahrt wird, zum Beispiel `5 minutes`. |\n| `reevaluate` | `true` behält Skripte und Styles, wenn dieselbe Adresse erneut importiert wird. |\n\n```html\n<ui-import config=\"url:/parts/hello.html;make:prepare;init:ready\"></ui-import>\n\n<script>\n    function prepare(response, element, path) {\n        return response.replace('server', 'browser');\n    }\n\n    function ready(element) {\n        console.log(element.text()); // Hello from the browser\n    }\n</script>\n```\n\nDer erste Import einer Adresse führt ihre Skripte und Styles aus. Weitere Importe derselben Adresse entfernen diese aus dem Inhalt, sodass eine dreimal auf einer Seite platzierte Datei ihr Skript nicht dreimal ausführt. Verwende `reevaluate:true`, wenn jede Kopie ihr Skript ausführen soll. Die [ui-import-Referenz](../../reference/ui-import/) beschreibt alle Einstellungen.\n\n## Eine Datei mit Platzhaltern wiederverwenden\n\nMit Platzhaltern dient eine Datei mehreren Stellen. `<ui-import>` ersetzt `~PATH~` durch `path` und `~ID~` durch `id`. `PLUGIN(function(` in der Datei erhält den Path als Plugin-Namen:\n\n```html\n<!-- /parts/plugin.html -->\n<ui-plugin path=\"~PATH~\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n    PLUGIN(function(exports) {\n        exports.set('title', 'Plugin ' + exports.name);\n    });\n</script>\n```\n\n```html\n<ui-import config=\"url:/parts/plugin.html;path:orders\"></ui-import>\n<ui-import config=\"url:/parts/plugin.html;path:users;reevaluate:true\"></ui-import>\n```\n\nDie Seite führt jetzt die Plugins `orders` und `users` aus, die `Plugin orders` und `Plugin users` anzeigen. Siehe [Plugins](../plugins/).\n\n## Aus einer Komponente importieren\n\nEine Komponente importiert mit `self.import(url, [callback], [insert], [preparator])` in ihr eigenes Element. Siehe [Komponenten erstellen](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTh1oM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/importing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Importar contenido","summary":"Carga HTML, scripts y hojas de estilos bajo demanda con IMPORT() y el elemento ui-import.","markdown":"---\ntitle: Importar contenido\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/importing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Importar contenido\n\n> Carga HTML, scripts y hojas de estilos bajo demanda con IMPORT() y el elemento ui-import.\n\nUna aplicación no tiene por qué cargarlo todo de una vez. `IMPORT()` descarga HTML, scripts y hojas de estilos cuando se lo pides, y el elemento `<ui-import>` hace lo mismo desde el marcado.\n\n## Importar HTML\n\n`IMPORT(url, [target], [callback], [insert], [preparator])` descarga un archivo y lo añade a la página.\n\n| Argumento | Tipo | Descripción |\n| --- | --- | --- |\n| `url` | String o Array | La dirección del archivo, o una lista de direcciones. |\n| `target` | String, jQuery o Element | Dónde va el contenido. El valor predeterminado es `body`. |\n| `callback` | Function | Se ejecuta cuando termina la importación y recibe un estado. |\n| `insert` | Boolean | `false` sustituye el contenido del destino. Cualquier otro valor lo añade al final. |\n| `preparator` | Function | Recibe el texto descargado y devuelve el texto que se va a insertar. |\n\n```html\n<div id=\"box\"><i>Loading</i></div>\n\n<script>\n    IMPORT('/parts/hello.html', '#box', function(status) {\n        console.log(status);\n    });\n</script>\n```\n\nSi `/parts/hello.html` contiene `<b>Hello from the server</b>`, el estado es `1` y el destino contiene `<i>Loading</i><b>Hello from the server</b>`. El estado es `0` cuando no se ha importado nada: la respuesta estaba vacía o el archivo se ha omitido por una de las condiciones que se describen más abajo.\n\nPuedes omitir `target` y pasar el callback como segundo argumento.\n\n### Sustituir y modificar el contenido\n\nPasa `false` para sustituir lo que hay en el destino, y una función para modificar el texto antes de insertarlo:\n\n```js\nIMPORT('/parts/hello.html', '#box', function() {\n    console.log($('#box').html());\n}, false, function(response) {\n    return response.replace('Hello', 'Welcome');\n});\n```\n\nAhora el destino solo contiene `<b>Welcome from the server</b>`.\n\n### Qué ocurre con el contenido\n\n- Los bloques `<style>` se mueven al `<head>`.\n- Los bloques `<script>` se ejecutan.\n- Los componentes, enlaces y plugins del contenido se compilan.\n- El texto marcado con `@(...)` se traduce; consulta [Localización](../localization/).\n\n## Importar scripts y hojas de estilos\n\nLa extensión decide cómo se carga un archivo. `.js` añade un elemento `<script>` y `.css` añade un elemento `<link>` al `<head>`, y el destino no se usa. Si la dirección no tiene una extensión adecuada, añade una al final, separada por un espacio:\n\n```js\nIMPORT('/assets/chart.js', function() {\n    // The script is ready\n});\n\nIMPORT('/assets/theme.css');\n\nIMPORT('/download?file=chart .js');\n```\n\nEl callback de un archivo `.js` o `.css` solo se ejecuta cuando el archivo se carga. No se ejecuta si la descarga falla.\n\n## Importar un archivo una sola vez\n\nEl prefijo `once ` (o `!`) importa un archivo una única vez. Las importaciones posteriores de la misma dirección no hacen nada y llaman al callback con el estado `0`:\n\n```js\nIMPORT('once /parts/hello.html', '#box', function(status) {\n    console.log(status); // 1\n\n    IMPORT('once /parts/hello.html', '#box', function(status) {\n        console.log(status); // 0\n    });\n});\n```\n\n## Importar un archivo de forma condicional\n\nUn path entre corchetes angulares omite la importación cuando el valor del path se evalúa como verdadero. Añade `()` para llamar a una función y usar su resultado. Es la forma habitual de cargar una biblioteca solo cuando falta:\n\n```js\nIMPORT('<window.Chart> /assets/chart.js', function(status) {\n    // status is 0 when window.Chart already exists\n});\n```\n\n## Importar varios archivos\n\nUn array importa los archivos uno tras otro. El callback se ejecuta después del último y no recibe ningún estado:\n\n```js\nIMPORT(['/parts/hello.html', '/parts/widget.html'], '#box', function() {\n    // Both files are in #box\n});\n```\n\n## Guardar una respuesta en caché\n\n`IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])` funciona como `IMPORT()` y conserva el HTML descargado durante el tiempo indicado:\n\n```js\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#box');\n```\n\n## El elemento ui-import\n\n`<ui-import>` importa un archivo cuando el elemento aparece en la página. El contenido sustituye a lo que tenga el elemento:\n\n```html\n<ui-import config=\"url:/parts/widget.html;path:orders;id:w1\"></ui-import>\n```\n\nLos ajustes más usados del atributo `config`:\n\n| Ajuste | Descripción |\n| --- | --- |\n| `url` | La dirección del archivo. |\n| `path` | El valor del marcador `~PATH~`. |\n| `id` | El valor del marcador `~ID~`. |\n| `replace` | `true` sustituye el propio elemento por el contenido. |\n| `target` | Un selector del elemento que recibe el contenido. |\n| `make` | El path de una función que recibe `(response, element, path)` y devuelve el texto que se va a insertar. |\n| `init` | El path de una función que se ejecuta después de la importación y recibe el elemento. |\n| `cache` | Cuánto tiempo se conserva la respuesta, por ejemplo `5 minutes`. |\n| `reevaluate` | `true` conserva los scripts y estilos cuando se vuelve a importar la misma dirección. |\n\n```html\n<ui-import config=\"url:/parts/hello.html;make:prepare;init:ready\"></ui-import>\n\n<script>\n    function prepare(response, element, path) {\n        return response.replace('server', 'browser');\n    }\n\n    function ready(element) {\n        console.log(element.text()); // Hello from the browser\n    }\n</script>\n```\n\nLa primera importación de una dirección ejecuta sus scripts y estilos. Las siguientes importaciones de la misma dirección los quitan del contenido, de modo que un archivo colocado tres veces en una página no ejecuta su script tres veces. Usa `reevaluate:true` cuando cada copia tenga que ejecutar su script. La [referencia de ui-import](../../reference/ui-import/) describe todos los ajustes.\n\n## Reutilizar un archivo con marcadores\n\nLos marcadores permiten que un archivo sirva para varios lugares. `<ui-import>` sustituye `~PATH~` por `path` y `~ID~` por `id`. `PLUGIN(function(` en el archivo recibe el path como nombre del plugin:\n\n```html\n<!-- /parts/plugin.html -->\n<ui-plugin path=\"~PATH~\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n    PLUGIN(function(exports) {\n        exports.set('title', 'Plugin ' + exports.name);\n    });\n</script>\n```\n\n```html\n<ui-import config=\"url:/parts/plugin.html;path:orders\"></ui-import>\n<ui-import config=\"url:/parts/plugin.html;path:users;reevaluate:true\"></ui-import>\n```\n\nAhora la página ejecuta los plugins `orders` y `users`, que muestran `Plugin orders` y `Plugin users`. Consulta [Plugins](../plugins/).\n\n## Importar desde un componente\n\nUn componente importa en su propio elemento con `self.import(url, [callback], [insert], [preparator])`. Consulta [Crear componentes](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTh1oM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/importing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Importer du contenu","summary":"Charge du HTML, des scripts et des feuilles de style à la demande avec IMPORT() et l'élément ui-import.","markdown":"---\ntitle: Importer du contenu\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/importing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Importer du contenu\n\n> Charge du HTML, des scripts et des feuilles de style à la demande avec IMPORT() et l'élément ui-import.\n\nUne application n'a pas besoin de tout charger d'un coup. `IMPORT()` télécharge du HTML, des scripts et des feuilles de style quand tu le demandes, et l'élément `<ui-import>` fait de même depuis le balisage.\n\n## Importer du HTML\n\n`IMPORT(url, [target], [callback], [insert], [preparator])` télécharge un fichier et l'ajoute à la page.\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `url` | String ou Array | L'adresse du fichier, ou une liste d'adresses. |\n| `target` | String, jQuery ou Element | L'endroit où placer le contenu. La valeur par défaut est `body`. |\n| `callback` | Function | S'exécute à la fin de l'import et reçoit un statut. |\n| `insert` | Boolean | `false` remplace le contenu de la cible. Toute autre valeur ajoute le contenu à la suite. |\n| `preparator` | Function | Reçoit le texte téléchargé et renvoie le texte à insérer. |\n\n```html\n<div id=\"box\"><i>Loading</i></div>\n\n<script>\n    IMPORT('/parts/hello.html', '#box', function(status) {\n        console.log(status);\n    });\n</script>\n```\n\nSi `/parts/hello.html` contient `<b>Hello from the server</b>`, le statut est `1` et la cible contient `<i>Loading</i><b>Hello from the server</b>`. Le statut est `0` quand rien n'a été importé : la réponse était vide, ou le fichier a été ignoré à cause de l'une des conditions décrites plus bas.\n\nTu peux omettre `target` et passer le callback comme deuxième argument.\n\n### Remplacer et modifier le contenu\n\nPasse `false` pour remplacer ce qui se trouve dans la cible, et une fonction pour modifier le texte avant son insertion :\n\n```js\nIMPORT('/parts/hello.html', '#box', function() {\n    console.log($('#box').html());\n}, false, function(response) {\n    return response.replace('Hello', 'Welcome');\n});\n```\n\nLa cible ne contient plus que `<b>Welcome from the server</b>`.\n\n### Ce que devient le contenu\n\n- Les blocs `<style>` sont déplacés dans le `<head>`.\n- Les blocs `<script>` sont exécutés.\n- Les composants, les liaisons et les plugins du contenu sont compilés.\n- Le texte marqué avec `@(...)` est traduit, voir [Localisation](../localization/).\n\n## Importer des scripts et des feuilles de style\n\nL'extension détermine comment un fichier est chargé. `.js` ajoute un élément `<script>` et `.css` un élément `<link>` au `<head>`, et la cible n'est pas utilisée. Si l'adresse n'a pas d'extension adaptée, ajoutes-en une à la fin, séparée par une espace :\n\n```js\nIMPORT('/assets/chart.js', function() {\n    // The script is ready\n});\n\nIMPORT('/assets/theme.css');\n\nIMPORT('/download?file=chart .js');\n```\n\nLe callback d'un fichier `.js` ou `.css` ne s'exécute que lorsque le fichier est chargé. Il ne s'exécute pas si le téléchargement échoue.\n\n## Importer un fichier une seule fois\n\nLe préfixe `once ` (ou `!`) importe un fichier une seule fois. Les imports suivants de la même adresse ne font rien et appellent le callback avec le statut `0` :\n\n```js\nIMPORT('once /parts/hello.html', '#box', function(status) {\n    console.log(status); // 1\n\n    IMPORT('once /parts/hello.html', '#box', function(status) {\n        console.log(status); // 0\n    });\n});\n```\n\n## Importer un fichier sous condition\n\nUn path entre chevrons ignore l'import quand la valeur du path est truthy. Ajoute `()` pour appeler une fonction et utiliser son résultat. C'est la manière habituelle de charger une bibliothèque seulement quand elle est absente :\n\n```js\nIMPORT('<window.Chart> /assets/chart.js', function(status) {\n    // status is 0 when window.Chart already exists\n});\n```\n\n## Importer plusieurs fichiers\n\nUn tableau importe les fichiers les uns après les autres. Le callback s'exécute après le dernier et ne reçoit aucun statut :\n\n```js\nIMPORT(['/parts/hello.html', '/parts/widget.html'], '#box', function() {\n    // Both files are in #box\n});\n```\n\n## Mettre une réponse en cache\n\n`IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])` fonctionne comme `IMPORT()` et conserve le HTML téléchargé pendant la durée indiquée :\n\n```js\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#box');\n```\n\n## L'élément ui-import\n\n`<ui-import>` importe un fichier quand l'élément apparaît sur la page. Le contenu remplace ce que l'élément contient :\n\n```html\n<ui-import config=\"url:/parts/widget.html;path:orders;id:w1\"></ui-import>\n```\n\nLes réglages les plus utilisés de l'attribut `config` :\n\n| Réglage | Description |\n| --- | --- |\n| `url` | L'adresse du fichier. |\n| `path` | La valeur de l'emplacement `~PATH~`. |\n| `id` | La valeur de l'emplacement `~ID~`. |\n| `replace` | `true` remplace l'élément lui-même par le contenu. |\n| `target` | Un sélecteur de l'élément qui reçoit le contenu. |\n| `make` | Le path d'une fonction qui reçoit `(response, element, path)` et renvoie le texte à insérer. |\n| `init` | Le path d'une fonction exécutée après l'import, qui reçoit l'élément. |\n| `cache` | La durée de conservation de la réponse, par exemple `5 minutes`. |\n| `reevaluate` | `true` conserve les scripts et les styles quand la même adresse est de nouveau importée. |\n\n```html\n<ui-import config=\"url:/parts/hello.html;make:prepare;init:ready\"></ui-import>\n\n<script>\n    function prepare(response, element, path) {\n        return response.replace('server', 'browser');\n    }\n\n    function ready(element) {\n        console.log(element.text()); // Hello from the browser\n    }\n</script>\n```\n\nLe premier import d'une adresse exécute ses scripts et ses styles. Les imports suivants de la même adresse les retirent du contenu : un fichier placé trois fois sur une page n'exécute donc pas son script trois fois. Utilise `reevaluate:true` quand chaque copie doit exécuter son script. La [référence ui-import](../../reference/ui-import/) décrit tous les réglages.\n\n## Réutiliser un fichier avec des emplacements\n\nLes emplacements permettent à un même fichier de servir à plusieurs endroits. `<ui-import>` remplace `~PATH~` par `path` et `~ID~` par `id`. Dans le fichier, `PLUGIN(function(` reçoit le path comme nom de plugin :\n\n```html\n<!-- /parts/plugin.html -->\n<ui-plugin path=\"~PATH~\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n    PLUGIN(function(exports) {\n        exports.set('title', 'Plugin ' + exports.name);\n    });\n</script>\n```\n\n```html\n<ui-import config=\"url:/parts/plugin.html;path:orders\"></ui-import>\n<ui-import config=\"url:/parts/plugin.html;path:users;reevaluate:true\"></ui-import>\n```\n\nLa page exécute maintenant les plugins `orders` et `users`, qui affichent `Plugin orders` et `Plugin users`. Consulte [Plugins](../plugins/).\n\n## Importer depuis un composant\n\nUn composant importe dans son propre élément avec `self.import(url, [callback], [insert], [preparator])`. Consulte [Créer des composants](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTh1oM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/importing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Importare contenuti","summary":"Carica HTML, script e fogli di stile su richiesta con IMPORT() e l'elemento ui-import.","markdown":"---\ntitle: Importare contenuti\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/importing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Importare contenuti\n\n> Carica HTML, script e fogli di stile su richiesta con IMPORT() e l'elemento ui-import.\n\nUn'applicazione non deve caricare tutto in una volta. `IMPORT()` scarica HTML, script e fogli di stile quando li richiedi, e l'elemento `<ui-import>` fa lo stesso dal markup.\n\n## Importare HTML\n\n`IMPORT(url, [target], [callback], [insert], [preparator])` scarica un file e lo aggiunge alla pagina.\n\n| Argomento | Tipo | Descrizione |\n| --- | --- | --- |\n| `url` | String o Array | L'indirizzo del file, o un elenco di indirizzi. |\n| `target` | String, jQuery o Element | Dove va il contenuto. Il valore predefinito è `body`. |\n| `callback` | Function | Viene eseguita al termine dell'importazione e riceve uno stato. |\n| `insert` | Boolean | `false` sostituisce il contenuto della destinazione. Qualsiasi altro valore lo aggiunge in coda. |\n| `preparator` | Function | Riceve il testo scaricato e restituisce il testo da inserire. |\n\n```html\n<div id=\"box\"><i>Loading</i></div>\n\n<script>\n    IMPORT('/parts/hello.html', '#box', function(status) {\n        console.log(status);\n    });\n</script>\n```\n\nSe `/parts/hello.html` contiene `<b>Hello from the server</b>`, lo stato è `1` e la destinazione contiene `<i>Loading</i><b>Hello from the server</b>`. Lo stato è `0` quando non è stato importato nulla: la risposta era vuota oppure il file è stato saltato per una delle condizioni descritte più avanti.\n\nPuoi omettere `target` e passare la callback come secondo argomento.\n\n### Sostituire e modificare il contenuto\n\nPassa `false` per sostituire ciò che si trova nella destinazione e una funzione per modificare il testo prima dell'inserimento:\n\n```js\nIMPORT('/parts/hello.html', '#box', function() {\n    console.log($('#box').html());\n}, false, function(response) {\n    return response.replace('Hello', 'Welcome');\n});\n```\n\nOra la destinazione contiene solo `<b>Welcome from the server</b>`.\n\n### Che cosa succede al contenuto\n\n- I blocchi `<style>` vengono spostati nell'`<head>`.\n- I blocchi `<script>` vengono eseguiti.\n- I componenti, le associazioni e i plugin nel contenuto vengono compilati.\n- Il testo contrassegnato con `@(...)` viene tradotto, consulta [Localizzazione](../localization/).\n\n## Importare script e fogli di stile\n\nÈ l'estensione a decidere come viene caricato un file. `.js` aggiunge un elemento `<script>` e `.css` aggiunge un elemento `<link>` all'`<head>`, e la destinazione non viene usata. Se l'indirizzo non ha un'estensione adatta, aggiungine una alla fine, separata da uno spazio:\n\n```js\nIMPORT('/assets/chart.js', function() {\n    // The script is ready\n});\n\nIMPORT('/assets/theme.css');\n\nIMPORT('/download?file=chart .js');\n```\n\nLa callback di un file `.js` o `.css` viene eseguita solo quando il file viene caricato. Non viene eseguita se il download non riesce.\n\n## Importare un file una sola volta\n\nIl prefisso `once ` (o `!`) importa un file una sola volta. Le importazioni successive dello stesso indirizzo non fanno nulla e chiamano la callback con lo stato `0`:\n\n```js\nIMPORT('once /parts/hello.html', '#box', function(status) {\n    console.log(status); // 1\n\n    IMPORT('once /parts/hello.html', '#box', function(status) {\n        console.log(status); // 0\n    });\n});\n```\n\n## Importare un file in base a una condizione\n\nUn path tra parentesi angolari salta l'importazione quando il valore del path è truthy. Aggiungi `()` per chiamare una funzione e usarne il risultato. È il modo abituale per caricare una libreria solo quando manca:\n\n```js\nIMPORT('<window.Chart> /assets/chart.js', function(status) {\n    // status is 0 when window.Chart already exists\n});\n```\n\n## Importare più file\n\nUn array importa i file uno dopo l'altro. La callback viene eseguita dopo l'ultimo e non riceve alcuno stato:\n\n```js\nIMPORT(['/parts/hello.html', '/parts/widget.html'], '#box', function() {\n    // Both files are in #box\n});\n```\n\n## Memorizzare una risposta nella cache\n\n`IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])` funziona come `IMPORT()` e conserva l'HTML scaricato per il tempo indicato:\n\n```js\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#box');\n```\n\n## L'elemento ui-import\n\n`<ui-import>` importa un file quando l'elemento compare nella pagina. Il contenuto sostituisce tutto ciò che l'elemento contiene:\n\n```html\n<ui-import config=\"url:/parts/widget.html;path:orders;id:w1\"></ui-import>\n```\n\nLe impostazioni più usate dell'attributo `config`:\n\n| Impostazione | Descrizione |\n| --- | --- |\n| `url` | L'indirizzo del file. |\n| `path` | Il valore del segnaposto `~PATH~`. |\n| `id` | Il valore del segnaposto `~ID~`. |\n| `replace` | `true` sostituisce l'elemento stesso con il contenuto. |\n| `target` | Un selettore dell'elemento che riceve il contenuto. |\n| `make` | Il path di una funzione che riceve `(response, element, path)` e restituisce il testo da inserire. |\n| `init` | Il path di una funzione che viene eseguita dopo l'importazione e riceve l'elemento. |\n| `cache` | Per quanto tempo conservare la risposta, ad esempio `5 minutes`. |\n| `reevaluate` | `true` mantiene script e stili quando lo stesso indirizzo viene importato di nuovo. |\n\n```html\n<ui-import config=\"url:/parts/hello.html;make:prepare;init:ready\"></ui-import>\n\n<script>\n    function prepare(response, element, path) {\n        return response.replace('server', 'browser');\n    }\n\n    function ready(element) {\n        console.log(element.text()); // Hello from the browser\n    }\n</script>\n```\n\nLa prima importazione di un indirizzo esegue i suoi script e stili. Le importazioni successive dello stesso indirizzo li rimuovono dal contenuto, quindi un file inserito tre volte in una pagina non esegue il suo script tre volte. Usa `reevaluate:true` quando ogni copia deve eseguire il proprio script. Il [riferimento di ui-import](../../reference/ui-import/) descrive tutte le impostazioni.\n\n## Riutilizzare un file con i segnaposto\n\nI segnaposto permettono a un file di servire più punti. `<ui-import>` sostituisce `~PATH~` con `path` e `~ID~` con `id`. `PLUGIN(function(` nel file riceve il path come nome del plugin:\n\n```html\n<!-- /parts/plugin.html -->\n<ui-plugin path=\"~PATH~\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n    PLUGIN(function(exports) {\n        exports.set('title', 'Plugin ' + exports.name);\n    });\n</script>\n```\n\n```html\n<ui-import config=\"url:/parts/plugin.html;path:orders\"></ui-import>\n<ui-import config=\"url:/parts/plugin.html;path:users;reevaluate:true\"></ui-import>\n```\n\nOra la pagina esegue i plugin `orders` e `users`, che mostrano `Plugin orders` e `Plugin users`. Consulta [Plugin](../plugins/).\n\n## Importare da un componente\n\nUn componente importa nel proprio elemento con `self.import(url, [callback], [insert], [preparator])`. Consulta [Creare componenti](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTh1oM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/importing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Import obsahu","summary":"Načítavaj HTML, skripty a štýly na požiadanie pomocou IMPORT() a elementu ui-import.","markdown":"---\ntitle: Import obsahu\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/importing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Import obsahu\n\n> Načítavaj HTML, skripty a štýly na požiadanie pomocou IMPORT() a elementu ui-import.\n\nAplikácia nemusí načítať všetko naraz. `IMPORT()` stiahne HTML, skripty a štýly, keď o ne požiadaš, a element `<ui-import>` robí to isté priamo zo značiek.\n\n## Import HTML\n\n`IMPORT(url, [target], [callback], [insert], [preparator])` stiahne súbor a pridá ho na stránku.\n\n| Argument | Typ | Popis |\n| --- | --- | --- |\n| `url` | String alebo Array | Adresa súboru alebo zoznam adries. |\n| `target` | String, jQuery alebo Element | Kam obsah pôjde. Predvolene `body`. |\n| `callback` | Function | Spustí sa po dokončení importu a dostane stav. |\n| `insert` | Boolean | `false` nahradí obsah cieľa. Akákoľvek iná hodnota obsah pripojí na koniec. |\n| `preparator` | Function | Dostane stiahnutý text a vráti text na vloženie. |\n\n```html\n<div id=\"box\"><i>Loading</i></div>\n\n<script>\n    IMPORT('/parts/hello.html', '#box', function(status) {\n        console.log(status);\n    });\n</script>\n```\n\nAk `/parts/hello.html` obsahuje `<b>Hello from the server</b>`, stav je `1` a cieľ obsahuje `<i>Loading</i><b>Hello from the server</b>`. Stav je `0`, keď sa nič neimportovalo: odpoveď bola prázdna alebo sa súbor preskočil na základe niektorej z podmienok popísaných nižšie.\n\nArgument `target` môžeš vynechať a callback odovzdať ako druhý argument.\n\n### Nahradenie a úprava obsahu\n\nOdovzdaj `false`, ak chceš nahradiť obsah cieľa, a funkciu, ak chceš text pred vložením upraviť:\n\n```js\nIMPORT('/parts/hello.html', '#box', function() {\n    console.log($('#box').html());\n}, false, function(response) {\n    return response.replace('Hello', 'Welcome');\n});\n```\n\nCieľ teraz obsahuje iba `<b>Welcome from the server</b>`.\n\n### Čo sa stane s obsahom\n\n- Bloky `<style>` sa presunú do `<head>`.\n- Bloky `<script>` sa spustia.\n- Komponenty, väzby a pluginy v obsahu sa skompilujú.\n- Text označený pomocou `@(...)` sa preloží, pozri [Lokalizácia](../localization/).\n\n## Import skriptov a štýlov\n\nO spôsobe načítania súboru rozhoduje prípona. `.js` pridá do `<head>` element `<script>` a `.css` element `<link>` a cieľ sa nepoužije. Ak adresa nemá vhodnú príponu, pridaj ju na koniec, oddelenú medzerou:\n\n```js\nIMPORT('/assets/chart.js', function() {\n    // The script is ready\n});\n\nIMPORT('/assets/theme.css');\n\nIMPORT('/download?file=chart .js');\n```\n\nCallback súboru `.js` alebo `.css` sa spustí iba vtedy, keď sa súbor načíta. Keď sťahovanie zlyhá, nespustí sa.\n\n## Jednorazový import súboru\n\nPredpona `once ` (alebo `!`) importuje súbor iba raz. Ďalšie importy tej istej adresy nič neurobia a zavolajú callback so stavom `0`:\n\n```js\nIMPORT('once /parts/hello.html', '#box', function(status) {\n    console.log(status); // 1\n\n    IMPORT('once /parts/hello.html', '#box', function(status) {\n        console.log(status); // 0\n    });\n});\n```\n\n## Podmienený import súboru\n\nPath v lomených zátvorkách import preskočí, keď je hodnota tohto path pravdivá. Pridaj `()`, ak chceš zavolať funkciu a použiť jej výsledok. Takto sa zvyčajne načíta knižnica iba vtedy, keď chýba:\n\n```js\nIMPORT('<window.Chart> /assets/chart.js', function(status) {\n    // status is 0 when window.Chart already exists\n});\n```\n\n## Import viacerých súborov\n\nPole importuje súbory jeden po druhom. Callback sa spustí po poslednom z nich a nedostane žiadny stav:\n\n```js\nIMPORT(['/parts/hello.html', '/parts/widget.html'], '#box', function() {\n    // Both files are in #box\n});\n```\n\n## Ukladanie odpovede do cache\n\n`IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])` funguje ako `IMPORT()` a stiahnuté HTML uchováva po zadaný čas:\n\n```js\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#box');\n```\n\n## Element ui-import\n\n`<ui-import>` importuje súbor, keď sa element objaví na stránke. Obsah nahradí všetko, čo element obsahuje:\n\n```html\n<ui-import config=\"url:/parts/widget.html;path:orders;id:w1\"></ui-import>\n```\n\nNajpoužívanejšie nastavenia atribútu `config`:\n\n| Nastavenie | Popis |\n| --- | --- |\n| `url` | Adresa súboru. |\n| `path` | Hodnota zástupného symbolu `~PATH~`. |\n| `id` | Hodnota zástupného symbolu `~ID~`. |\n| `replace` | `true` nahradí obsahom samotný element. |\n| `target` | Selektor elementu, ktorý dostane obsah. |\n| `make` | Path funkcie, ktorá dostane `(response, element, path)` a vráti text na vloženie. |\n| `init` | Path funkcie, ktorá sa spustí po importe a dostane element. |\n| `cache` | Ako dlho sa má odpoveď uchovávať, napríklad `5 minutes`. |\n| `reevaluate` | `true` ponechá skripty a štýly, keď sa tá istá adresa importuje znova. |\n\n```html\n<ui-import config=\"url:/parts/hello.html;make:prepare;init:ready\"></ui-import>\n\n<script>\n    function prepare(response, element, path) {\n        return response.replace('server', 'browser');\n    }\n\n    function ready(element) {\n        console.log(element.text()); // Hello from the browser\n    }\n</script>\n```\n\nPrvý import adresy spustí jej skripty a štýly. Ďalšie importy tej istej adresy ich z obsahu odstránia, takže súbor umiestnený na stránke trikrát nespustí svoj skript trikrát. Ak musí skript spustiť každá kópia, použi `reevaluate:true`. Každé nastavenie popisuje [referencia ui-import](../../reference/ui-import/).\n\n## Opakované použitie súboru so zástupnými symbolmi\n\nVďaka zástupným symbolom môže jeden súbor slúžiť na viacerých miestach. `<ui-import>` nahradí `~PATH~` hodnotou `path` a `~ID~` hodnotou `id`. `PLUGIN(function(` v súbore dostane path ako názov pluginu:\n\n```html\n<!-- /parts/plugin.html -->\n<ui-plugin path=\"~PATH~\">\n    <ui-bind path=\"?.title\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<script>\n    PLUGIN(function(exports) {\n        exports.set('title', 'Plugin ' + exports.name);\n    });\n</script>\n```\n\n```html\n<ui-import config=\"url:/parts/plugin.html;path:orders\"></ui-import>\n<ui-import config=\"url:/parts/plugin.html;path:users;reevaluate:true\"></ui-import>\n```\n\nNa stránke teraz bežia pluginy `orders` a `users`, ktoré zobrazujú `Plugin orders` a `Plugin users`. Pozri [Pluginy](../plugins/).\n\n## Import z komponentu\n\nKomponent importuje do vlastného elementu pomocou `self.import(url, [callback], [insert], [preparator])`. Pozri [Vytváranie komponentov](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU624M61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/tangular/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Templates with Tangular","summary":"Render HTML from data with the Tangular template engine that ships with jComponent.","markdown":"---\ntitle: Templates with Tangular\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/tangular/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Templates with Tangular\n\n> Render HTML from data with the Tangular template engine that ships with jComponent.\n\nTangular is the template engine included in jComponent. It turns a template and a model into a string of HTML. The global objects are `Tangular` (also available as `Ta`) and `Thelpers`.\n\n## Rendering a template\n\n`Tangular.render(template, [model], [repository], [helpers])` compiles a template and runs it at once:\n\n```js\nvar model = { name: 'Peter <b>', address: { city: 'Bratislava' } };\n\nTangular.render('Hello {{ name }}, {{ address.city }}, {{ phone.number }}!', model);\n// Hello Peter &lt;b&gt;, Bratislava, !\n```\n\nThree rules show up in this example:\n\n- A value is written between `{{` and `}}`.\n- Output is HTML-encoded.\n- A missing value renders as nothing, even in a nested path such as `phone.number`.\n\n## Values and expressions\n\nA command can be a JavaScript expression. `{{ }}` writes the model itself, and the `raw` helper turns off encoding:\n\n```js\nTangular.render('{{ price * 2 }} {{ name.length }} {{ a || b }}', { price: 5, name: 'abc', a: 0, b: 'x' });\n// 10 3 x\n\nTangular.render('{{ }}', 'The model itself');\n// The model itself\n\nTangular.render('{{ name | raw }}', { name: '<b>Peter</b>' });\n// <b>Peter</b>\n```\n\nUse `raw` only with content you trust.\n\n## Conditions\n\n`{{ if }}` starts a condition and `{{ fi }}` ends it. `{{ else if }}` and `{{ else }}` are optional:\n\n```js\nvar template = '{{ if stock > 5 }}In stock{{ else if stock > 0 }}Almost gone{{ else }}Sold out{{ fi }}';\n\nTangular.render(template, { stock: 10 }); // In stock\nTangular.render(template, { stock: 2 });  // Almost gone\nTangular.render(template, { stock: 0 });  // Sold out\n```\n\n## Loops\n\n`{{ foreach item in list }}` repeats the content up to `{{ end }}`. `$index` is the position of the current item:\n\n```js\nvar model = { users: [{ name: 'Peter' }, { name: 'Lucia' }] };\n\nTangular.render('{{ foreach user in users }}{{ $index }}: {{ user.name }}, {{ end }}', model);\n// 0: Peter, 1: Lucia,\n```\n\nA loop over an object gets items with the properties `key` and `value`:\n\n```js\nvar model = { settings: { theme: 'dark', size: 12 } };\n\nTangular.render('{{ foreach item in settings }}{{ item.key }}={{ item.value }};{{ end }}', model);\n// theme=dark;size=12;\n```\n\n`{{ continue }}` skips to the next item and `{{ break }}` ends the loop:\n\n```js\nvar template = '{{ foreach id in ids }}{{ if id === 2 }}{{ continue }}{{ fi }}{{ if id === 4 }}{{ break }}{{ fi }}{{ id }} {{ end }}';\n\nTangular.render(template, { ids: [1, 2, 3, 4] });\n// 1 3\n```\n\nAn empty or missing list renders nothing. In nested loops, `$index` holds the position of the innermost loop that ran last, so an outer loop that reads `$index` after an inner loop gets the inner value:\n\n```js\nvar template = '{{ foreach row in rows }}[{{ $index }}:{{ foreach cell in row.cells }}{{ $index }}{{ cell }} {{ end }}{{ $index }}]{{ end }}';\n\nTangular.render(template, { rows: [{ cells: ['a', 'b'] }, { cells: ['c'] }] });\n// [0:0a 1b 1][1:0c 0]\n```\n\n## Helpers\n\nA helper transforms a value. Write it after a `|` character. Helpers can take arguments and can be chained:\n\n```js\nTangular.render(\"{{ count | pluralize('no items', '# item', '# items', '# items') }}\", { count: 3 });\n// 3 items\n\nTangular.render('{{ price | format(2) }}', { price: 1234.5 });\n// 1 234.50\n\nTangular.render(\"{{ note | def('none') }}\", { note: '' });\n// none\n\nTangular.render(\"{{ data | encode('json') }} {{ q | encode('url') }}\", { data: { a: 1 }, q: 'a b&c' });\n// {\"a\":1} a%20b%26c\n```\n\nThe included helpers are described in the [Tangular helpers reference](../../reference/tangular-helpers/).\n\n### Encoding with helpers\n\nA command that uses a helper is **not** encoded automatically. Add the `encode` helper at the end when the value can contain HTML:\n\n```js\nvar helpers = {\n    upper: function(value) {\n        return value.toUpperCase();\n    }\n};\n\nTangular.render('{{ name | upper }}', { name: '<i>peter</i>' }, null, helpers);\n// <I>PETER</I>\n\nTangular.render('{{ name | upper | encode }}', { name: '<i>peter</i>' }, null, helpers);\n// &lt;I&gt;PETER&lt;/I&gt;\n```\n\n### Writing a helper\n\n`Tangular.register(name, fn)` adds a helper for all templates. The function receives the value followed by the arguments from the template, and `this` is the model:\n\n```js\nTangular.register('stars', function(value) {\n    return '*'.padLeft(value, '*');\n});\n\nTangular.render('{{ rating | stars }}', { rating: 3 });\n// ***\n```\n\nTo use a helper in one template only, pass an object with helpers as the fourth argument of `Tangular.render()`. A name that matches no helper writes a warning to the console and returns the value unchanged.\n\n## Compiling a template\n\n`Tangular.compile(template)` returns a function. Compile once and call the function as often as you need, with the model, the repository and the helpers as arguments:\n\n```js\nvar row = Tangular.compile('<li>{{ name }} ({{ $.currency }})</li>');\n\nrow({ name: 'Keyboard' }, { currency: 'EUR' }); // <li>Keyboard (EUR)</li>\nrow({ name: 'Mouse' }, { currency: 'USD' });    // <li>Mouse (USD)</li>\n```\n\nStrings also have a shortcut:\n\n```js\n'Hello {{ name }}'.render({ name: 'Peter' }); // Hello Peter\n```\n\nIf a template fails while it runs, Tangular writes the error to the console and the result is `undefined`.\n\n## The repository\n\nThe repository is a second object that is available as `$` in the template. Use it for data that does not belong to the model:\n\n```js\nTangular.render('{{ foreach item in $.items }}{{ item }} {{ end }}', {}, { items: [1, 2] });\n// 1 2\n```\n\n## Custom delimiters\n\n`Tangular.compile()` accepts different delimiters as its second and third arguments. They are parts of a regular expression, so escape special characters:\n\n```js\nvar custom = Tangular.compile('Hello [[ name ]]', '\\\\[\\\\[', '\\\\]\\\\]');\n\ncustom({ name: 'Lucia' }); // Hello Lucia\n```\n\n## Templates in bindings\n\nThe `template` command of `<ui-bind>` renders a template with the value of the path and renders it again on every change. Inside the template, the value is available as `value`:\n\n```html\n<script>\n    var user = { name: 'Peter', roles: ['admin', 'editor'] };\n</script>\n\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\">\n        <b>{{ value.name }}</b>\n        {{ foreach role in value.roles }}<span>{{ role }}</span>{{ end }}\n    </script>\n</ui-bind>\n```\n\nSee [Data binding](../data-binding/) and the [ui-bind reference](../../reference/ui-bind/).\n\n## Templates in components\n\nA component usually compiles its template once in `make` and calls it in `setter`:\n\n```js\nCOMPONENT('userlist', function(self) {\n\n    var template;\n\n    self.make = function() {\n        template = Tangular.compile('<ul>{{ foreach user in value }}<li>{{ user }}</li>{{ end }}</ul>');\n    };\n\n    self.setter = function(value) {\n        self.html(template({ value: value }));\n    };\n});\n```\n\nWith `names = ['Peter', 'Lucia']` and `<ui-component name=\"userlist\" path=\"names\">`, the component renders `<ul><li>Peter</li><li>Lucia</li></ul>`. See [Creating components](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU624M61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/tangular/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Templates mit Tangular","summary":"Rendere HTML aus Daten mit der Template-Engine Tangular, die zum Lieferumfang von jComponent gehört.","markdown":"---\ntitle: Templates mit Tangular\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/tangular/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Templates mit Tangular\n\n> Rendere HTML aus Daten mit der Template-Engine Tangular, die zum Lieferumfang von jComponent gehört.\n\nTangular ist die in jComponent enthaltene Template-Engine und macht aus einem Template und einem Modell einen HTML-String. Die globalen Objekte sind `Tangular` (auch als `Ta` verfügbar) und `Thelpers`.\n\n## Ein Template rendern\n\n`Tangular.render(template, [model], [repository], [helpers])` kompiliert ein Template und führt es sofort aus:\n\n```js\nvar model = { name: 'Peter <b>', address: { city: 'Bratislava' } };\n\nTangular.render('Hello {{ name }}, {{ address.city }}, {{ phone.number }}!', model);\n// Hello Peter &lt;b&gt;, Bratislava, !\n```\n\nDieses Beispiel zeigt drei Regeln:\n\n- Ein Wert steht zwischen `{{` und `}}`.\n- Die Ausgabe ist HTML-kodiert.\n- Ein fehlender Wert wird als nichts gerendert, auch in einem verschachtelten Path wie `phone.number`.\n\n## Werte und Ausdrücke\n\nEin Befehl kann ein JavaScript-Ausdruck sein. `{{ }}` schreibt das Modell selbst, und der Helper `raw` schaltet die Kodierung ab:\n\n```js\nTangular.render('{{ price * 2 }} {{ name.length }} {{ a || b }}', { price: 5, name: 'abc', a: 0, b: 'x' });\n// 10 3 x\n\nTangular.render('{{ }}', 'The model itself');\n// The model itself\n\nTangular.render('{{ name | raw }}', { name: '<b>Peter</b>' });\n// <b>Peter</b>\n```\n\nVerwende `raw` nur für Inhalte, denen du vertraust.\n\n## Bedingungen\n\n`{{ if }}` beginnt eine Bedingung und `{{ fi }}` beendet sie. `{{ else if }}` und `{{ else }}` sind optional:\n\n```js\nvar template = '{{ if stock > 5 }}In stock{{ else if stock > 0 }}Almost gone{{ else }}Sold out{{ fi }}';\n\nTangular.render(template, { stock: 10 }); // In stock\nTangular.render(template, { stock: 2 });  // Almost gone\nTangular.render(template, { stock: 0 });  // Sold out\n```\n\n## Schleifen\n\n`{{ foreach item in list }}` wiederholt den Inhalt bis `{{ end }}`. `$index` ist die Position des aktuellen Eintrags:\n\n```js\nvar model = { users: [{ name: 'Peter' }, { name: 'Lucia' }] };\n\nTangular.render('{{ foreach user in users }}{{ $index }}: {{ user.name }}, {{ end }}', model);\n// 0: Peter, 1: Lucia,\n```\n\nEine Schleife über ein Objekt liefert Einträge mit den Eigenschaften `key` und `value`:\n\n```js\nvar model = { settings: { theme: 'dark', size: 12 } };\n\nTangular.render('{{ foreach item in settings }}{{ item.key }}={{ item.value }};{{ end }}', model);\n// theme=dark;size=12;\n```\n\n`{{ continue }}` springt zum nächsten Eintrag, und `{{ break }}` beendet die Schleife:\n\n```js\nvar template = '{{ foreach id in ids }}{{ if id === 2 }}{{ continue }}{{ fi }}{{ if id === 4 }}{{ break }}{{ fi }}{{ id }} {{ end }}';\n\nTangular.render(template, { ids: [1, 2, 3, 4] });\n// 1 3\n```\n\nEine leere oder fehlende Liste rendert nichts. In verschachtelten Schleifen enthält `$index` die Position der innersten Schleife, die zuletzt gelaufen ist. Eine äußere Schleife, die `$index` nach einer inneren Schleife liest, erhält also den inneren Wert:\n\n```js\nvar template = '{{ foreach row in rows }}[{{ $index }}:{{ foreach cell in row.cells }}{{ $index }}{{ cell }} {{ end }}{{ $index }}]{{ end }}';\n\nTangular.render(template, { rows: [{ cells: ['a', 'b'] }, { cells: ['c'] }] });\n// [0:0a 1b 1][1:0c 0]\n```\n\n## Helper\n\nEin Helper wandelt einen Wert um. Schreibe ihn hinter ein `|`-Zeichen. Helper können Argumente annehmen und verkettet werden:\n\n```js\nTangular.render(\"{{ count | pluralize('no items', '# item', '# items', '# items') }}\", { count: 3 });\n// 3 items\n\nTangular.render('{{ price | format(2) }}', { price: 1234.5 });\n// 1 234.50\n\nTangular.render(\"{{ note | def('none') }}\", { note: '' });\n// none\n\nTangular.render(\"{{ data | encode('json') }} {{ q | encode('url') }}\", { data: { a: 1 }, q: 'a b&c' });\n// {\"a\":1} a%20b%26c\n```\n\nDie enthaltenen Helper sind in der [Referenz der Tangular-Helper](../../reference/tangular-helpers/) beschrieben.\n\n### Kodierung mit Helpern\n\nEin Befehl mit einem Helper wird **nicht** automatisch kodiert. Füge am Ende den Helper `encode` hinzu, wenn der Wert HTML enthalten kann:\n\n```js\nvar helpers = {\n    upper: function(value) {\n        return value.toUpperCase();\n    }\n};\n\nTangular.render('{{ name | upper }}', { name: '<i>peter</i>' }, null, helpers);\n// <I>PETER</I>\n\nTangular.render('{{ name | upper | encode }}', { name: '<i>peter</i>' }, null, helpers);\n// &lt;I&gt;PETER&lt;/I&gt;\n```\n\n### Einen Helper schreiben\n\n`Tangular.register(name, fn)` fügt einen Helper für alle Templates hinzu. Die Funktion erhält den Wert, gefolgt von den Argumenten aus dem Template, und `this` ist das Modell:\n\n```js\nTangular.register('stars', function(value) {\n    return '*'.padLeft(value, '*');\n});\n\nTangular.render('{{ rating | stars }}', { rating: 3 });\n// ***\n```\n\nUm einen Helper nur in einem Template zu verwenden, übergib ein Objekt mit Helpern als viertes Argument von `Tangular.render()`. Ein Name, zu dem es keinen Helper gibt, schreibt eine Warnung in die Konsole und gibt den Wert unverändert zurück.\n\n## Ein Template kompilieren\n\n`Tangular.compile(template)` gibt eine Funktion zurück. Kompiliere einmal und rufe die Funktion so oft wie nötig auf, mit dem Modell, dem Repository und den Helpern als Argumenten:\n\n```js\nvar row = Tangular.compile('<li>{{ name }} ({{ $.currency }})</li>');\n\nrow({ name: 'Keyboard' }, { currency: 'EUR' }); // <li>Keyboard (EUR)</li>\nrow({ name: 'Mouse' }, { currency: 'USD' });    // <li>Mouse (USD)</li>\n```\n\nAuch Strings haben eine Kurzform:\n\n```js\n'Hello {{ name }}'.render({ name: 'Peter' }); // Hello Peter\n```\n\nSchlägt ein Template bei der Ausführung fehl, schreibt Tangular den Fehler in die Konsole, und das Ergebnis ist `undefined`.\n\n## Das Repository\n\nDas Repository ist ein zweites Objekt, das im Template als `$` verfügbar ist. Verwende es für Daten, die nicht zum Modell gehören:\n\n```js\nTangular.render('{{ foreach item in $.items }}{{ item }} {{ end }}', {}, { items: [1, 2] });\n// 1 2\n```\n\n## Eigene Begrenzungszeichen\n\n`Tangular.compile()` akzeptiert als zweites und drittes Argument andere Begrenzungszeichen. Diese sind Teile eines regulären Ausdrucks, maskiere also Sonderzeichen:\n\n```js\nvar custom = Tangular.compile('Hello [[ name ]]', '\\\\[\\\\[', '\\\\]\\\\]');\n\ncustom({ name: 'Lucia' }); // Hello Lucia\n```\n\n## Templates in Bindungen\n\nDer Befehl `template` von `<ui-bind>` rendert ein Template mit dem Wert des Paths und rendert es bei jeder Änderung neu. Innerhalb des Templates ist der Wert als `value` verfügbar:\n\n```html\n<script>\n    var user = { name: 'Peter', roles: ['admin', 'editor'] };\n</script>\n\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\">\n        <b>{{ value.name }}</b>\n        {{ foreach role in value.roles }}<span>{{ role }}</span>{{ end }}\n    </script>\n</ui-bind>\n```\n\nSiehe [Datenbindung](../data-binding/) und die [ui-bind-Referenz](../../reference/ui-bind/).\n\n## Templates in Komponenten\n\nEine Komponente kompiliert ihr Template üblicherweise einmal in `make` und ruft es in `setter` auf:\n\n```js\nCOMPONENT('userlist', function(self) {\n\n    var template;\n\n    self.make = function() {\n        template = Tangular.compile('<ul>{{ foreach user in value }}<li>{{ user }}</li>{{ end }}</ul>');\n    };\n\n    self.setter = function(value) {\n        self.html(template({ value: value }));\n    };\n});\n```\n\nMit `names = ['Peter', 'Lucia']` und `<ui-component name=\"userlist\" path=\"names\">` rendert die Komponente `<ul><li>Peter</li><li>Lucia</li></ul>`. Siehe [Komponenten erstellen](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU624M61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/tangular/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Plantillas con Tangular","summary":"Renderiza HTML a partir de datos con el motor de plantillas Tangular que incluye jComponent.","markdown":"---\ntitle: Plantillas con Tangular\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/tangular/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Plantillas con Tangular\n\n> Renderiza HTML a partir de datos con el motor de plantillas Tangular que incluye jComponent.\n\nTangular es el motor de plantillas incluido en jComponent. Convierte una plantilla y un modelo en una cadena de HTML. Los objetos globales son `Tangular` (también disponible como `Ta`) y `Thelpers`.\n\n## Renderizar una plantilla\n\n`Tangular.render(template, [model], [repository], [helpers])` compila una plantilla y la ejecuta de inmediato:\n\n```js\nvar model = { name: 'Peter <b>', address: { city: 'Bratislava' } };\n\nTangular.render('Hello {{ name }}, {{ address.city }}, {{ phone.number }}!', model);\n// Hello Peter &lt;b&gt;, Bratislava, !\n```\n\nEste ejemplo muestra tres reglas:\n\n- Un valor se escribe entre `{{` y `}}`.\n- La salida se codifica como HTML.\n- Un valor que falta no renderiza nada, incluso en un path anidado como `phone.number`.\n\n## Valores y expresiones\n\nUn comando puede ser una expresión JavaScript. `{{ }}` escribe el propio modelo, y el helper `raw` desactiva la codificación:\n\n```js\nTangular.render('{{ price * 2 }} {{ name.length }} {{ a || b }}', { price: 5, name: 'abc', a: 0, b: 'x' });\n// 10 3 x\n\nTangular.render('{{ }}', 'The model itself');\n// The model itself\n\nTangular.render('{{ name | raw }}', { name: '<b>Peter</b>' });\n// <b>Peter</b>\n```\n\nUsa `raw` solo con contenido de confianza.\n\n## Condiciones\n\n`{{ if }}` inicia una condición y `{{ fi }}` la termina. `{{ else if }}` y `{{ else }}` son opcionales:\n\n```js\nvar template = '{{ if stock > 5 }}In stock{{ else if stock > 0 }}Almost gone{{ else }}Sold out{{ fi }}';\n\nTangular.render(template, { stock: 10 }); // In stock\nTangular.render(template, { stock: 2 });  // Almost gone\nTangular.render(template, { stock: 0 });  // Sold out\n```\n\n## Bucles\n\n`{{ foreach item in list }}` repite el contenido hasta `{{ end }}`. `$index` es la posición del elemento actual:\n\n```js\nvar model = { users: [{ name: 'Peter' }, { name: 'Lucia' }] };\n\nTangular.render('{{ foreach user in users }}{{ $index }}: {{ user.name }}, {{ end }}', model);\n// 0: Peter, 1: Lucia,\n```\n\nUn bucle sobre un objeto obtiene elementos con las propiedades `key` y `value`:\n\n```js\nvar model = { settings: { theme: 'dark', size: 12 } };\n\nTangular.render('{{ foreach item in settings }}{{ item.key }}={{ item.value }};{{ end }}', model);\n// theme=dark;size=12;\n```\n\n`{{ continue }}` salta al siguiente elemento y `{{ break }}` termina el bucle:\n\n```js\nvar template = '{{ foreach id in ids }}{{ if id === 2 }}{{ continue }}{{ fi }}{{ if id === 4 }}{{ break }}{{ fi }}{{ id }} {{ end }}';\n\nTangular.render(template, { ids: [1, 2, 3, 4] });\n// 1 3\n```\n\nUna lista vacía o inexistente no renderiza nada. En los bucles anidados, `$index` contiene la posición del bucle más interno que se ha ejecutado en último lugar, así que un bucle exterior que lea `$index` después de un bucle interior obtiene el valor interior:\n\n```js\nvar template = '{{ foreach row in rows }}[{{ $index }}:{{ foreach cell in row.cells }}{{ $index }}{{ cell }} {{ end }}{{ $index }}]{{ end }}';\n\nTangular.render(template, { rows: [{ cells: ['a', 'b'] }, { cells: ['c'] }] });\n// [0:0a 1b 1][1:0c 0]\n```\n\n## Helpers\n\nUn helper transforma un valor. Escríbelo después de un carácter `|`. Los helpers admiten argumentos y se pueden encadenar:\n\n```js\nTangular.render(\"{{ count | pluralize('no items', '# item', '# items', '# items') }}\", { count: 3 });\n// 3 items\n\nTangular.render('{{ price | format(2) }}', { price: 1234.5 });\n// 1 234.50\n\nTangular.render(\"{{ note | def('none') }}\", { note: '' });\n// none\n\nTangular.render(\"{{ data | encode('json') }} {{ q | encode('url') }}\", { data: { a: 1 }, q: 'a b&c' });\n// {\"a\":1} a%20b%26c\n```\n\nLos helpers incluidos se describen en la [referencia de helpers de Tangular](../../reference/tangular-helpers/).\n\n### Codificar con helpers\n\nUn comando que usa un helper **no** se codifica automáticamente. Añade el helper `encode` al final cuando el valor pueda contener HTML:\n\n```js\nvar helpers = {\n    upper: function(value) {\n        return value.toUpperCase();\n    }\n};\n\nTangular.render('{{ name | upper }}', { name: '<i>peter</i>' }, null, helpers);\n// <I>PETER</I>\n\nTangular.render('{{ name | upper | encode }}', { name: '<i>peter</i>' }, null, helpers);\n// &lt;I&gt;PETER&lt;/I&gt;\n```\n\n### Escribir un helper\n\n`Tangular.register(name, fn)` añade un helper para todas las plantillas. La función recibe el valor seguido de los argumentos de la plantilla, y `this` es el modelo:\n\n```js\nTangular.register('stars', function(value) {\n    return '*'.padLeft(value, '*');\n});\n\nTangular.render('{{ rating | stars }}', { rating: 3 });\n// ***\n```\n\nPara usar un helper en una sola plantilla, pasa un objeto con helpers como cuarto argumento de `Tangular.render()`. Un nombre que no coincide con ningún helper escribe un aviso en la consola y devuelve el valor sin cambios.\n\n## Compilar una plantilla\n\n`Tangular.compile(template)` devuelve una función. Compila una vez y llama a la función tantas veces como necesites, con el modelo, el repositorio y los helpers como argumentos:\n\n```js\nvar row = Tangular.compile('<li>{{ name }} ({{ $.currency }})</li>');\n\nrow({ name: 'Keyboard' }, { currency: 'EUR' }); // <li>Keyboard (EUR)</li>\nrow({ name: 'Mouse' }, { currency: 'USD' });    // <li>Mouse (USD)</li>\n```\n\nLas cadenas también tienen un atajo:\n\n```js\n'Hello {{ name }}'.render({ name: 'Peter' }); // Hello Peter\n```\n\nSi una plantilla falla durante la ejecución, Tangular escribe el error en la consola y el resultado es `undefined`.\n\n## El repositorio\n\nEl repositorio es un segundo objeto que está disponible como `$` en la plantilla. Úsalo para datos que no pertenecen al modelo:\n\n```js\nTangular.render('{{ foreach item in $.items }}{{ item }} {{ end }}', {}, { items: [1, 2] });\n// 1 2\n```\n\n## Delimitadores personalizados\n\n`Tangular.compile()` acepta otros delimitadores como segundo y tercer argumento. Son partes de una expresión regular, así que escapa los caracteres especiales:\n\n```js\nvar custom = Tangular.compile('Hello [[ name ]]', '\\\\[\\\\[', '\\\\]\\\\]');\n\ncustom({ name: 'Lucia' }); // Hello Lucia\n```\n\n## Plantillas en enlaces\n\nEl comando `template` de `<ui-bind>` renderiza una plantilla con el valor del path y la vuelve a renderizar en cada cambio. Dentro de la plantilla, el valor está disponible como `value`:\n\n```html\n<script>\n    var user = { name: 'Peter', roles: ['admin', 'editor'] };\n</script>\n\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\">\n        <b>{{ value.name }}</b>\n        {{ foreach role in value.roles }}<span>{{ role }}</span>{{ end }}\n    </script>\n</ui-bind>\n```\n\nConsulta [Enlace de datos](../data-binding/) y la [referencia de ui-bind](../../reference/ui-bind/).\n\n## Plantillas en componentes\n\nUn componente normalmente compila su plantilla una vez en `make` y la llama en `setter`:\n\n```js\nCOMPONENT('userlist', function(self) {\n\n    var template;\n\n    self.make = function() {\n        template = Tangular.compile('<ul>{{ foreach user in value }}<li>{{ user }}</li>{{ end }}</ul>');\n    };\n\n    self.setter = function(value) {\n        self.html(template({ value: value }));\n    };\n});\n```\n\nCon `names = ['Peter', 'Lucia']` y `<ui-component name=\"userlist\" path=\"names\">`, el componente renderiza `<ul><li>Peter</li><li>Lucia</li></ul>`. Consulta [Crear componentes](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU624M61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/tangular/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Modèles avec Tangular","summary":"Génère du HTML à partir de données avec le moteur de modèles Tangular fourni avec jComponent.","markdown":"---\ntitle: \"Modèles avec Tangular\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/tangular/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Modèles avec Tangular\n\n> Génère du HTML à partir de données avec le moteur de modèles Tangular fourni avec jComponent.\n\nTangular est le moteur de modèles inclus dans jComponent. Il transforme un modèle et un modèle de données en une chaîne HTML. Les objets globaux sont `Tangular` (aussi disponible sous le nom `Ta`) et `Thelpers`.\n\n## Afficher un modèle\n\n`Tangular.render(template, [model], [repository], [helpers])` compile un modèle et l'exécute aussitôt :\n\n```js\nvar model = { name: 'Peter <b>', address: { city: 'Bratislava' } };\n\nTangular.render('Hello {{ name }}, {{ address.city }}, {{ phone.number }}!', model);\n// Hello Peter &lt;b&gt;, Bratislava, !\n```\n\nCet exemple illustre trois règles :\n\n- Une valeur s'écrit entre `{{` et `}}`.\n- La sortie est encodée en HTML.\n- Une valeur absente n'affiche rien, même dans un path imbriqué comme `phone.number`.\n\n## Valeurs et expressions\n\nUne commande peut être une expression JavaScript. `{{ }}` écrit le modèle de données lui-même, et le helper `raw` désactive l'encodage :\n\n```js\nTangular.render('{{ price * 2 }} {{ name.length }} {{ a || b }}', { price: 5, name: 'abc', a: 0, b: 'x' });\n// 10 3 x\n\nTangular.render('{{ }}', 'The model itself');\n// The model itself\n\nTangular.render('{{ name | raw }}', { name: '<b>Peter</b>' });\n// <b>Peter</b>\n```\n\nN'utilise `raw` qu'avec du contenu de confiance.\n\n## Conditions\n\n`{{ if }}` ouvre une condition et `{{ fi }}` la ferme. `{{ else if }}` et `{{ else }}` sont facultatifs :\n\n```js\nvar template = '{{ if stock > 5 }}In stock{{ else if stock > 0 }}Almost gone{{ else }}Sold out{{ fi }}';\n\nTangular.render(template, { stock: 10 }); // In stock\nTangular.render(template, { stock: 2 });  // Almost gone\nTangular.render(template, { stock: 0 });  // Sold out\n```\n\n## Boucles\n\n`{{ foreach item in list }}` répète le contenu jusqu'à `{{ end }}`. `$index` est la position de l'élément courant :\n\n```js\nvar model = { users: [{ name: 'Peter' }, { name: 'Lucia' }] };\n\nTangular.render('{{ foreach user in users }}{{ $index }}: {{ user.name }}, {{ end }}', model);\n// 0: Peter, 1: Lucia,\n```\n\nUne boucle sur un objet obtient des éléments dotés des propriétés `key` et `value` :\n\n```js\nvar model = { settings: { theme: 'dark', size: 12 } };\n\nTangular.render('{{ foreach item in settings }}{{ item.key }}={{ item.value }};{{ end }}', model);\n// theme=dark;size=12;\n```\n\n`{{ continue }}` passe à l'élément suivant et `{{ break }}` termine la boucle :\n\n```js\nvar template = '{{ foreach id in ids }}{{ if id === 2 }}{{ continue }}{{ fi }}{{ if id === 4 }}{{ break }}{{ fi }}{{ id }} {{ end }}';\n\nTangular.render(template, { ids: [1, 2, 3, 4] });\n// 1 3\n```\n\nUne liste vide ou absente n'affiche rien. Dans des boucles imbriquées, `$index` contient la position de la boucle la plus interne exécutée en dernier : une boucle externe qui lit `$index` après une boucle interne obtient donc la valeur interne :\n\n```js\nvar template = '{{ foreach row in rows }}[{{ $index }}:{{ foreach cell in row.cells }}{{ $index }}{{ cell }} {{ end }}{{ $index }}]{{ end }}';\n\nTangular.render(template, { rows: [{ cells: ['a', 'b'] }, { cells: ['c'] }] });\n// [0:0a 1b 1][1:0c 0]\n```\n\n## Helpers\n\nUn helper transforme une valeur. Écris-le après un caractère `|`. Les helpers peuvent prendre des arguments et s'enchaîner :\n\n```js\nTangular.render(\"{{ count | pluralize('no items', '# item', '# items', '# items') }}\", { count: 3 });\n// 3 items\n\nTangular.render('{{ price | format(2) }}', { price: 1234.5 });\n// 1 234.50\n\nTangular.render(\"{{ note | def('none') }}\", { note: '' });\n// none\n\nTangular.render(\"{{ data | encode('json') }} {{ q | encode('url') }}\", { data: { a: 1 }, q: 'a b&c' });\n// {\"a\":1} a%20b%26c\n```\n\nLes helpers inclus sont décrits dans la [référence des helpers Tangular](../../reference/tangular-helpers/).\n\n### Encoder avec les helpers\n\nUne commande qui utilise un helper n'est **pas** encodée automatiquement. Ajoute le helper `encode` à la fin quand la valeur peut contenir du HTML :\n\n```js\nvar helpers = {\n    upper: function(value) {\n        return value.toUpperCase();\n    }\n};\n\nTangular.render('{{ name | upper }}', { name: '<i>peter</i>' }, null, helpers);\n// <I>PETER</I>\n\nTangular.render('{{ name | upper | encode }}', { name: '<i>peter</i>' }, null, helpers);\n// &lt;I&gt;PETER&lt;/I&gt;\n```\n\n### Écrire un helper\n\n`Tangular.register(name, fn)` ajoute un helper pour tous les modèles. La fonction reçoit la valeur suivie des arguments du modèle, et `this` est le modèle de données :\n\n```js\nTangular.register('stars', function(value) {\n    return '*'.padLeft(value, '*');\n});\n\nTangular.render('{{ rating | stars }}', { rating: 3 });\n// ***\n```\n\nPour utiliser un helper dans un seul modèle, passe un objet contenant les helpers comme quatrième argument de `Tangular.render()`. Un nom qui ne correspond à aucun helper écrit un avertissement dans la console et renvoie la valeur inchangée.\n\n## Compiler un modèle\n\n`Tangular.compile(template)` renvoie une fonction. Compile une seule fois et appelle la fonction aussi souvent que nécessaire, avec le modèle de données, le dépôt et les helpers comme arguments :\n\n```js\nvar row = Tangular.compile('<li>{{ name }} ({{ $.currency }})</li>');\n\nrow({ name: 'Keyboard' }, { currency: 'EUR' }); // <li>Keyboard (EUR)</li>\nrow({ name: 'Mouse' }, { currency: 'USD' });    // <li>Mouse (USD)</li>\n```\n\nLes chaînes disposent aussi d'un raccourci :\n\n```js\n'Hello {{ name }}'.render({ name: 'Peter' }); // Hello Peter\n```\n\nSi un modèle échoue pendant son exécution, Tangular écrit l'erreur dans la console et le résultat est `undefined`.\n\n## Le dépôt\n\nLe dépôt est un second objet, disponible sous le nom `$` dans le modèle. Utilise-le pour les données qui n'appartiennent pas au modèle de données :\n\n```js\nTangular.render('{{ foreach item in $.items }}{{ item }} {{ end }}', {}, { items: [1, 2] });\n// 1 2\n```\n\n## Délimiteurs personnalisés\n\n`Tangular.compile()` accepte d'autres délimiteurs comme deuxième et troisième arguments. Ce sont des fragments d'expression régulière : échappe donc les caractères spéciaux :\n\n```js\nvar custom = Tangular.compile('Hello [[ name ]]', '\\\\[\\\\[', '\\\\]\\\\]');\n\ncustom({ name: 'Lucia' }); // Hello Lucia\n```\n\n## Modèles dans les liaisons\n\nLa commande `template` de `<ui-bind>` affiche un modèle avec la valeur du path et l'affiche de nouveau à chaque changement. Dans le modèle, la valeur est disponible sous le nom `value` :\n\n```html\n<script>\n    var user = { name: 'Peter', roles: ['admin', 'editor'] };\n</script>\n\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\">\n        <b>{{ value.name }}</b>\n        {{ foreach role in value.roles }}<span>{{ role }}</span>{{ end }}\n    </script>\n</ui-bind>\n```\n\nConsulte [Liaison de données](../data-binding/) et la [référence ui-bind](../../reference/ui-bind/).\n\n## Modèles dans les composants\n\nUn composant compile généralement son modèle une seule fois dans `make` et l'appelle dans `setter` :\n\n```js\nCOMPONENT('userlist', function(self) {\n\n    var template;\n\n    self.make = function() {\n        template = Tangular.compile('<ul>{{ foreach user in value }}<li>{{ user }}</li>{{ end }}</ul>');\n    };\n\n    self.setter = function(value) {\n        self.html(template({ value: value }));\n    };\n});\n```\n\nAvec `names = ['Peter', 'Lucia']` et `<ui-component name=\"userlist\" path=\"names\">`, le composant affiche `<ul><li>Peter</li><li>Lucia</li></ul>`. Consulte [Créer des composants](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU624M61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/tangular/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Template con Tangular","summary":"Genera HTML dai dati con il motore di template Tangular incluso in jComponent.","markdown":"---\ntitle: Template con Tangular\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/tangular/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Template con Tangular\n\n> Genera HTML dai dati con il motore di template Tangular incluso in jComponent.\n\nTangular è il motore di template incluso in jComponent. Trasforma un template e un modello in una stringa di HTML. Gli oggetti globali sono `Tangular` (disponibile anche come `Ta`) e `Thelpers`.\n\n## Renderizzare un template\n\n`Tangular.render(template, [model], [repository], [helpers])` compila un template e lo esegue subito:\n\n```js\nvar model = { name: 'Peter <b>', address: { city: 'Bratislava' } };\n\nTangular.render('Hello {{ name }}, {{ address.city }}, {{ phone.number }}!', model);\n// Hello Peter &lt;b&gt;, Bratislava, !\n```\n\nIn questo esempio emergono tre regole:\n\n- Un valore si scrive tra `{{` e `}}`.\n- L'output viene codificato in HTML.\n- Un valore mancante non produce alcun output, anche in un path annidato come `phone.number`.\n\n## Valori ed espressioni\n\nUn comando può essere un'espressione JavaScript. `{{ }}` scrive il modello stesso e l'helper `raw` disattiva la codifica:\n\n```js\nTangular.render('{{ price * 2 }} {{ name.length }} {{ a || b }}', { price: 5, name: 'abc', a: 0, b: 'x' });\n// 10 3 x\n\nTangular.render('{{ }}', 'The model itself');\n// The model itself\n\nTangular.render('{{ name | raw }}', { name: '<b>Peter</b>' });\n// <b>Peter</b>\n```\n\nUsa `raw` solo con contenuti di cui ti fidi.\n\n## Condizioni\n\n`{{ if }}` apre una condizione e `{{ fi }}` la chiude. `{{ else if }}` e `{{ else }}` sono facoltativi:\n\n```js\nvar template = '{{ if stock > 5 }}In stock{{ else if stock > 0 }}Almost gone{{ else }}Sold out{{ fi }}';\n\nTangular.render(template, { stock: 10 }); // In stock\nTangular.render(template, { stock: 2 });  // Almost gone\nTangular.render(template, { stock: 0 });  // Sold out\n```\n\n## Cicli\n\n`{{ foreach item in list }}` ripete il contenuto fino a `{{ end }}`. `$index` è la posizione dell'elemento corrente:\n\n```js\nvar model = { users: [{ name: 'Peter' }, { name: 'Lucia' }] };\n\nTangular.render('{{ foreach user in users }}{{ $index }}: {{ user.name }}, {{ end }}', model);\n// 0: Peter, 1: Lucia,\n```\n\nUn ciclo su un oggetto ottiene elementi con le proprietà `key` e `value`:\n\n```js\nvar model = { settings: { theme: 'dark', size: 12 } };\n\nTangular.render('{{ foreach item in settings }}{{ item.key }}={{ item.value }};{{ end }}', model);\n// theme=dark;size=12;\n```\n\n`{{ continue }}` passa all'elemento successivo e `{{ break }}` termina il ciclo:\n\n```js\nvar template = '{{ foreach id in ids }}{{ if id === 2 }}{{ continue }}{{ fi }}{{ if id === 4 }}{{ break }}{{ fi }}{{ id }} {{ end }}';\n\nTangular.render(template, { ids: [1, 2, 3, 4] });\n// 1 3\n```\n\nUn elenco vuoto o mancante non produce alcun output. Nei cicli annidati, `$index` contiene la posizione del ciclo più interno eseguito per ultimo, quindi un ciclo esterno che legge `$index` dopo un ciclo interno ottiene il valore di quest'ultimo:\n\n```js\nvar template = '{{ foreach row in rows }}[{{ $index }}:{{ foreach cell in row.cells }}{{ $index }}{{ cell }} {{ end }}{{ $index }}]{{ end }}';\n\nTangular.render(template, { rows: [{ cells: ['a', 'b'] }, { cells: ['c'] }] });\n// [0:0a 1b 1][1:0c 0]\n```\n\n## Helper\n\nUn helper trasforma un valore. Scrivilo dopo un carattere `|`. Gli helper possono accettare argomenti e possono essere concatenati:\n\n```js\nTangular.render(\"{{ count | pluralize('no items', '# item', '# items', '# items') }}\", { count: 3 });\n// 3 items\n\nTangular.render('{{ price | format(2) }}', { price: 1234.5 });\n// 1 234.50\n\nTangular.render(\"{{ note | def('none') }}\", { note: '' });\n// none\n\nTangular.render(\"{{ data | encode('json') }} {{ q | encode('url') }}\", { data: { a: 1 }, q: 'a b&c' });\n// {\"a\":1} a%20b%26c\n```\n\nGli helper inclusi sono descritti nel [riferimento degli helper di Tangular](../../reference/tangular-helpers/).\n\n### Codificare con gli helper\n\nUn comando che usa un helper **non** viene codificato automaticamente. Aggiungi l'helper `encode` alla fine quando il valore può contenere HTML:\n\n```js\nvar helpers = {\n    upper: function(value) {\n        return value.toUpperCase();\n    }\n};\n\nTangular.render('{{ name | upper }}', { name: '<i>peter</i>' }, null, helpers);\n// <I>PETER</I>\n\nTangular.render('{{ name | upper | encode }}', { name: '<i>peter</i>' }, null, helpers);\n// &lt;I&gt;PETER&lt;/I&gt;\n```\n\n### Scrivere un helper\n\n`Tangular.register(name, fn)` aggiunge un helper per tutti i template. La funzione riceve il valore seguito dagli argomenti del template, e `this` è il modello:\n\n```js\nTangular.register('stars', function(value) {\n    return '*'.padLeft(value, '*');\n});\n\nTangular.render('{{ rating | stars }}', { rating: 3 });\n// ***\n```\n\nPer usare un helper in un solo template, passa un oggetto con gli helper come quarto argomento di `Tangular.render()`. Un nome che non corrisponde a nessun helper scrive un avviso nella console e restituisce il valore invariato.\n\n## Compilare un template\n\n`Tangular.compile(template)` restituisce una funzione. Compila una volta e chiama la funzione tutte le volte che ti serve, passando come argomenti il modello, il repository e gli helper:\n\n```js\nvar row = Tangular.compile('<li>{{ name }} ({{ $.currency }})</li>');\n\nrow({ name: 'Keyboard' }, { currency: 'EUR' }); // <li>Keyboard (EUR)</li>\nrow({ name: 'Mouse' }, { currency: 'USD' });    // <li>Mouse (USD)</li>\n```\n\nAnche le stringhe hanno una scorciatoia:\n\n```js\n'Hello {{ name }}'.render({ name: 'Peter' }); // Hello Peter\n```\n\nSe un template genera un errore durante l'esecuzione, Tangular scrive l'errore nella console e il risultato è `undefined`.\n\n## Il repository\n\nIl repository è un secondo oggetto disponibile come `$` nel template. Usalo per i dati che non appartengono al modello:\n\n```js\nTangular.render('{{ foreach item in $.items }}{{ item }} {{ end }}', {}, { items: [1, 2] });\n// 1 2\n```\n\n## Delimitatori personalizzati\n\n`Tangular.compile()` accetta delimitatori diversi come secondo e terzo argomento. Sono parti di un'espressione regolare, quindi esegui l'escape dei caratteri speciali:\n\n```js\nvar custom = Tangular.compile('Hello [[ name ]]', '\\\\[\\\\[', '\\\\]\\\\]');\n\ncustom({ name: 'Lucia' }); // Hello Lucia\n```\n\n## Template nelle associazioni\n\nIl comando `template` di `<ui-bind>` renderizza un template con il valore del path e lo renderizza di nuovo a ogni modifica. All'interno del template, il valore è disponibile come `value`:\n\n```html\n<script>\n    var user = { name: 'Peter', roles: ['admin', 'editor'] };\n</script>\n\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\">\n        <b>{{ value.name }}</b>\n        {{ foreach role in value.roles }}<span>{{ role }}</span>{{ end }}\n    </script>\n</ui-bind>\n```\n\nConsulta [Associazione dei dati](../data-binding/) e il [riferimento di ui-bind](../../reference/ui-bind/).\n\n## Template nei componenti\n\nDi solito un componente compila il suo template una volta in `make` e lo chiama in `setter`:\n\n```js\nCOMPONENT('userlist', function(self) {\n\n    var template;\n\n    self.make = function() {\n        template = Tangular.compile('<ul>{{ foreach user in value }}<li>{{ user }}</li>{{ end }}</ul>');\n    };\n\n    self.setter = function(value) {\n        self.html(template({ value: value }));\n    };\n});\n```\n\nCon `names = ['Peter', 'Lucia']` e `<ui-component name=\"userlist\" path=\"names\">`, il componente renderizza `<ul><li>Peter</li><li>Lucia</li></ul>`. Consulta [Creare componenti](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU624M61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/tangular/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Šablóny s Tangular","summary":"Vykresľuj HTML z dát pomocou šablónovacieho nástroja Tangular, ktorý je súčasťou jComponent.","markdown":"---\ntitle: \"Šablóny s Tangular\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/tangular/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Šablóny s Tangular\n\n> Vykresľuj HTML z dát pomocou šablónovacieho nástroja Tangular, ktorý je súčasťou jComponent.\n\nTangular je šablónovací nástroj zahrnutý v jComponent. Zo šablóny a modelu vytvorí reťazec HTML. Globálne objekty sú `Tangular` (dostupný aj ako `Ta`) a `Thelpers`.\n\n## Vykreslenie šablóny\n\n`Tangular.render(template, [model], [repository], [helpers])` skompiluje šablónu a hneď ju spustí:\n\n```js\nvar model = { name: 'Peter <b>', address: { city: 'Bratislava' } };\n\nTangular.render('Hello {{ name }}, {{ address.city }}, {{ phone.number }}!', model);\n// Hello Peter &lt;b&gt;, Bratislava, !\n```\n\nV tomto príklade sa prejavujú tri pravidlá:\n\n- Hodnota sa píše medzi `{{` a `}}`.\n- Výstup je kódovaný pre HTML.\n- Chýbajúca hodnota sa nevykreslí, a to ani vo vnorenom path, ako je `phone.number`.\n\n## Hodnoty a výrazy\n\nPríkaz môže byť výraz JavaScriptu. `{{ }}` vypíše samotný model a helper `raw` vypne kódovanie:\n\n```js\nTangular.render('{{ price * 2 }} {{ name.length }} {{ a || b }}', { price: 5, name: 'abc', a: 0, b: 'x' });\n// 10 3 x\n\nTangular.render('{{ }}', 'The model itself');\n// The model itself\n\nTangular.render('{{ name | raw }}', { name: '<b>Peter</b>' });\n// <b>Peter</b>\n```\n\n`raw` používaj iba s obsahom, ktorému dôveruješ.\n\n## Podmienky\n\n`{{ if }}` začína podmienku a `{{ fi }}` ju končí. `{{ else if }}` a `{{ else }}` sú voliteľné:\n\n```js\nvar template = '{{ if stock > 5 }}In stock{{ else if stock > 0 }}Almost gone{{ else }}Sold out{{ fi }}';\n\nTangular.render(template, { stock: 10 }); // In stock\nTangular.render(template, { stock: 2 });  // Almost gone\nTangular.render(template, { stock: 0 });  // Sold out\n```\n\n## Cykly\n\n`{{ foreach item in list }}` opakuje obsah až po `{{ end }}`. `$index` je pozícia aktuálnej položky:\n\n```js\nvar model = { users: [{ name: 'Peter' }, { name: 'Lucia' }] };\n\nTangular.render('{{ foreach user in users }}{{ $index }}: {{ user.name }}, {{ end }}', model);\n// 0: Peter, 1: Lucia,\n```\n\nCyklus cez objekt dostáva položky s vlastnosťami `key` a `value`:\n\n```js\nvar model = { settings: { theme: 'dark', size: 12 } };\n\nTangular.render('{{ foreach item in settings }}{{ item.key }}={{ item.value }};{{ end }}', model);\n// theme=dark;size=12;\n```\n\n`{{ continue }}` preskočí na ďalšiu položku a `{{ break }}` cyklus ukončí:\n\n```js\nvar template = '{{ foreach id in ids }}{{ if id === 2 }}{{ continue }}{{ fi }}{{ if id === 4 }}{{ break }}{{ fi }}{{ id }} {{ end }}';\n\nTangular.render(template, { ids: [1, 2, 3, 4] });\n// 1 3\n```\n\nPrázdny alebo chýbajúci zoznam nevykreslí nič. Vo vnorených cykloch obsahuje `$index` pozíciu najvnútornejšieho cyklu, ktorý bežal naposledy, takže vonkajší cyklus, ktorý číta `$index` po vnútornom cykle, dostane vnútornú hodnotu:\n\n```js\nvar template = '{{ foreach row in rows }}[{{ $index }}:{{ foreach cell in row.cells }}{{ $index }}{{ cell }} {{ end }}{{ $index }}]{{ end }}';\n\nTangular.render(template, { rows: [{ cells: ['a', 'b'] }, { cells: ['c'] }] });\n// [0:0a 1b 1][1:0c 0]\n```\n\n## Helpery\n\nHelper transformuje hodnotu. Napíš ho za znak `|`. Helpery môžu prijímať argumenty a dajú sa reťaziť:\n\n```js\nTangular.render(\"{{ count | pluralize('no items', '# item', '# items', '# items') }}\", { count: 3 });\n// 3 items\n\nTangular.render('{{ price | format(2) }}', { price: 1234.5 });\n// 1 234.50\n\nTangular.render(\"{{ note | def('none') }}\", { note: '' });\n// none\n\nTangular.render(\"{{ data | encode('json') }} {{ q | encode('url') }}\", { data: { a: 1 }, q: 'a b&c' });\n// {\"a\":1} a%20b%26c\n```\n\nZahrnuté helpery popisuje [referencia helperov Tangular](../../reference/tangular-helpers/).\n\n### Kódovanie pomocou helperov\n\nPríkaz, ktorý používa helper, sa automaticky **nekóduje**. Keď môže hodnota obsahovať HTML, pridaj na koniec helper `encode`:\n\n```js\nvar helpers = {\n    upper: function(value) {\n        return value.toUpperCase();\n    }\n};\n\nTangular.render('{{ name | upper }}', { name: '<i>peter</i>' }, null, helpers);\n// <I>PETER</I>\n\nTangular.render('{{ name | upper | encode }}', { name: '<i>peter</i>' }, null, helpers);\n// &lt;I&gt;PETER&lt;/I&gt;\n```\n\n### Napísanie helpera\n\n`Tangular.register(name, fn)` pridá helper pre všetky šablóny. Funkcia dostane hodnotu, za ňou argumenty zo šablóny a `this` je model:\n\n```js\nTangular.register('stars', function(value) {\n    return '*'.padLeft(value, '*');\n});\n\nTangular.render('{{ rating | stars }}', { rating: 3 });\n// ***\n```\n\nAk chceš helper použiť iba v jednej šablóne, odovzdaj objekt s helpermi ako štvrtý argument `Tangular.render()`. Názov, ktorý nezodpovedá žiadnemu helperu, zapíše do konzoly upozornenie a vráti hodnotu nezmenenú.\n\n## Kompilácia šablóny\n\n`Tangular.compile(template)` vráti funkciu. Skompiluj raz a funkciu volaj tak často, ako potrebuješ, s modelom, repozitárom a helpermi ako argumentmi:\n\n```js\nvar row = Tangular.compile('<li>{{ name }} ({{ $.currency }})</li>');\n\nrow({ name: 'Keyboard' }, { currency: 'EUR' }); // <li>Keyboard (EUR)</li>\nrow({ name: 'Mouse' }, { currency: 'USD' });    // <li>Mouse (USD)</li>\n```\n\nReťazce majú aj skratku:\n\n```js\n'Hello {{ name }}'.render({ name: 'Peter' }); // Hello Peter\n```\n\nAk šablóna počas behu zlyhá, Tangular zapíše chybu do konzoly a výsledok je `undefined`.\n\n## Repozitár\n\nRepozitár je druhý objekt, ktorý je v šablóne dostupný ako `$`. Používaj ho na dáta, ktoré nepatria do modelu:\n\n```js\nTangular.render('{{ foreach item in $.items }}{{ item }} {{ end }}', {}, { items: [1, 2] });\n// 1 2\n```\n\n## Vlastné oddeľovače\n\n`Tangular.compile()` prijíma iné oddeľovače ako druhý a tretí argument. Sú to časti regulárneho výrazu, preto špeciálne znaky escapuj:\n\n```js\nvar custom = Tangular.compile('Hello [[ name ]]', '\\\\[\\\\[', '\\\\]\\\\]');\n\ncustom({ name: 'Lucia' }); // Hello Lucia\n```\n\n## Šablóny vo väzbách\n\nPríkaz `template` elementu `<ui-bind>` vykreslí šablónu s hodnotou path a pri každej zmene ju vykreslí znova. Vnútri šablóny je hodnota dostupná ako `value`:\n\n```html\n<script>\n    var user = { name: 'Peter', roles: ['admin', 'editor'] };\n</script>\n\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\">\n        <b>{{ value.name }}</b>\n        {{ foreach role in value.roles }}<span>{{ role }}</span>{{ end }}\n    </script>\n</ui-bind>\n```\n\nPozri [Dátová väzba](../data-binding/) a [referenciu ui-bind](../../reference/ui-bind/).\n\n## Šablóny v komponentoch\n\nKomponent zvyčajne skompiluje svoju šablónu raz v `make` a volá ju v `setter`:\n\n```js\nCOMPONENT('userlist', function(self) {\n\n    var template;\n\n    self.make = function() {\n        template = Tangular.compile('<ul>{{ foreach user in value }}<li>{{ user }}</li>{{ end }}</ul>');\n    };\n\n    self.setter = function(value) {\n        self.html(template({ value: value }));\n    };\n});\n```\n\nS `names = ['Peter', 'Lucia']` a `<ui-component name=\"userlist\" path=\"names\">` komponent vykreslí `<ul><li>Peter</li><li>Lucia</li></ul>`. Pozri [Vytváranie komponentov](../creating-components/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU020M61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/routing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Routing","summary":"Map URL addresses to functions with ROUTE(), navigate with REDIRECT() and read the current state from NAV.","markdown":"---\ntitle: Routing\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/routing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Routing\n\n> Map URL addresses to functions with ROUTE(), navigate with REDIRECT() and read the current state from NAV.\n\nRouting runs a function for each address of a single-page application. `ROUTE()` declares the addresses, `REDIRECT()` moves between them without reloading the page, and the global object `NAV` holds the current state.\n\nThe server has to return the application page for every address that a route handles, so that the browser can open those addresses directly.\n\n## Declaring routes\n\n`ROUTE(url, handler)` connects an address with a function. Dynamic segments are written in curly brackets, and their values arrive as arguments of the handler:\n\n```js\nROUTE('/', function() {\n    console.log('home');\n});\n\nROUTE('/products/', function() {\n    console.log('products');\n});\n\nROUTE('/products/new/', function() {\n    console.log('new product');\n});\n\nROUTE('/products/{id}/', function(id) {\n    console.log('product', id);\n});\n\nROUTE('/products/{id}/reviews/{review}/', function(id, review) {\n    console.log('review', id, review);\n});\n```\n\n```js\nREDIRECT('/products/new/');            // new product\nREDIRECT('/products/42');              // product 42\nREDIRECT('/PRODUCTS/AbC/');            // product AbC\nREDIRECT('/products/42/reviews/7/');   // review 42 7\n```\n\nInside a handler, `this` is the `NAV` object.\n\n### How an address is matched\n\n- Fixed routes win over routes with dynamic segments, so `/products/new/` is not handled by `/products/{id}/`.\n- The address must have the same number of segments as the route.\n- A missing trailing slash is added to the address.\n- The address is compared in lowercase, so write the fixed segments of a route in lowercase. The values of dynamic segments keep their original case.\n- Declaring a route with the same address replaces the earlier route.\n\n## Navigating\n\n`REDIRECT(url)` changes the address in the browser and runs the matching route. `NAV.clientside(selector)` does the same for links, so that you can write ordinary `<a>` elements:\n\n```html\n<script>\n    NAV.clientside('a.jR');\n</script>\n\n<a class=\"jR\" href=\"/docs/\">Documentation</a>\n```\n\nThe address comes from the `href`, `data-href` or `data-url` attribute. The browser's back and forward buttons run the matching routes too.\n\n`REDIRECT('../')` moves one segment up. `REDIRECT()` without an argument and `NAV.refresh()` run the current route again.\n\n## The current state\n\n| Property | Description |\n| --- | --- |\n| `NAV.url` | The current address without the query string, for example `/products/42/`. |\n| `NAV.href` | The address passed to the last navigation, with its query string. |\n| `NAV.params` | An array with the values of the dynamic segments. |\n| `NAV.query` | An object with the query string. |\n| `NAV.queryraw` | The query string as text. |\n| `NAV.is404` | `true` if no route matches the address. |\n| `NAV.history` | An array of the previous addresses. |\n| `NAV.isback` | The number of addresses you can go back to. |\n| `NAV.isforward` | The number of addresses you can go forward to. |\n| `NAV.routes` | An array of the declared routes. |\n\n```js\nROUTE('/search/', function() {\n    console.log(NAV.url, NAV.query.q, NAV.query.page);\n});\n\nREDIRECT('/search/?q=total%20js&page=2');\n// /search/ total js 2\n```\n\nThe properties `url`, `href`, `params`, `query`, `isback` and `isforward` are also [paths](../paths/), so you can bind them:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Middleware\n\nA middleware runs ahead of the handler and decides whether the handler runs. `MIDDLEWARE(name, fn)` declares one. Name it in the third argument of `ROUTE()`:\n\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n    if (user)\n        next();\n    else\n        next(false);\n});\n\nROUTE('/admin/', function() {\n    console.log('admin page');\n}, ['auth', '@admin', { title: 'Administration' }]);\n```\n\nThe array of a route can contain:\n\n| Item | Description |\n| --- | --- |\n| `'name'` | The name of a middleware. |\n| `'@name'` | A role. Middleware receives all roles in the `roles` array. |\n| An object | Options passed to the middleware as `options`. |\n\nThe middleware receives `next`, `options`, `roles` and the `route` object. Calling `next()` continues with the next middleware. `next(false)` or `next(new Error('...'))` stops the chain, and the handler does not run.\n\nYou can also pass the array as the second argument: `ROUTE('/admin/', ['auth'], handler)`.\n\n## Preparing a route\n\nA function as the third argument runs once, the first time the route is opened. Call `next` to continue to the handler. It suits loading what a part of the application needs:\n\n```js\nROUTE('/reports/', function() {\n    console.log('handler');\n}, function(next) {\n    console.log('init');\n    IMPORT('once /parts/reports.html', '#content', next);\n});\n```\n\nThe first visit prints `init` and `handler`. Each next visit prints only `handler`. To combine it with middleware, pass the middleware as the fourth argument: `ROUTE(url, handler, init, ['auth'])`.\n\n## Reacting to navigation\n\n| Event | Arguments | When it is emitted |\n| --- | --- | --- |\n| `location` | `url` | On every navigation. |\n| `404` | | No route matches the address. |\n| `route` | `url` | A route has been declared. |\n\n```js\nON('location', function(url) {\n    console.log('location', url);\n});\n\nON('404', function() {\n    console.log('not found', NAV.url);\n});\n```\n\n`NAV.status(code, [data])` emits an event named after the code, which gives you one place to handle errors:\n\n```js\nON('500', function(error) {\n    console.log('failed', error);\n});\n\nNAV.status(500, 'Database is down');\n```\n\n## Going back and forward\n\n`NAV.back()` opens the previous address and `NAV.forward()` the next one:\n\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();    // NAV.url is '/a/'\nNAV.forward(); // NAV.url is '/b/'\n```\n\n`NAV.prev()` and `NAV.next()` return the address on each side without moving.\n\n## Keeping query parameters\n\n`NAV.remember(name, value)` adds a query parameter to every next `REDIRECT()`. Use `null` as the value to stop:\n\n```js\nNAV.remember('lang', 'sk');\nREDIRECT('/items/');        // NAV.href is '/items/?lang=sk'\n\nNAV.remember('lang', null);\nREDIRECT('/items/');        // NAV.href is '/items/'\n```\n\n## Removing a route\n\n`NAV.remove(url)` deletes a route declared with that address.\n\n## Routing without the address bar\n\n`NAV.custom()` keeps the routing inside the application: `REDIRECT()` runs routes and the address in the browser stays the same. Call it ahead of the first navigation. It suits embedded applications and widgets.\n\nThe current address is stored for one month and opened again on the next visit. Pass an expiration such as `'1 day'` to change the time, or `false` to store nothing:\n\n```js\nNAV.custom();\nNAV.custom('1 day');\nNAV.custom(false);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU020M61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/routing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Routing","summary":"Ordne URL-Adressen mit ROUTE() Funktionen zu, navigiere mit REDIRECT() und lies den aktuellen Zustand aus NAV.","markdown":"---\ntitle: Routing\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/routing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Routing\n\n> Ordne URL-Adressen mit ROUTE() Funktionen zu, navigiere mit REDIRECT() und lies den aktuellen Zustand aus NAV.\n\nRouting führt für jede Adresse einer Single-Page-Anwendung eine Funktion aus. `ROUTE()` deklariert die Adressen, `REDIRECT()` wechselt zwischen ihnen, ohne die Seite neu zu laden, und das globale Objekt `NAV` enthält den aktuellen Zustand.\n\nDer Server muss für jede Adresse, die eine Route verarbeitet, die Anwendungsseite zurückgeben, damit der Browser diese Adressen direkt öffnen kann.\n\n## Routen deklarieren\n\n`ROUTE(url, handler)` verbindet eine Adresse mit einer Funktion. Dynamische Segmente stehen in geschweiften Klammern, und ihre Werte kommen als Argumente beim Handler an:\n\n```js\nROUTE('/', function() {\n    console.log('home');\n});\n\nROUTE('/products/', function() {\n    console.log('products');\n});\n\nROUTE('/products/new/', function() {\n    console.log('new product');\n});\n\nROUTE('/products/{id}/', function(id) {\n    console.log('product', id);\n});\n\nROUTE('/products/{id}/reviews/{review}/', function(id, review) {\n    console.log('review', id, review);\n});\n```\n\n```js\nREDIRECT('/products/new/');            // new product\nREDIRECT('/products/42');              // product 42\nREDIRECT('/PRODUCTS/AbC/');            // product AbC\nREDIRECT('/products/42/reviews/7/');   // review 42 7\n```\n\nInnerhalb eines Handlers ist `this` das Objekt `NAV`.\n\n### Wie eine Adresse zugeordnet wird\n\n- Feste Routen haben Vorrang vor Routen mit dynamischen Segmenten, `/products/new/` wird also nicht von `/products/{id}/` verarbeitet.\n- Die Adresse muss dieselbe Anzahl an Segmenten haben wie die Route.\n- Ein fehlender abschließender Schrägstrich wird der Adresse hinzugefügt.\n- Die Adresse wird in Kleinbuchstaben verglichen, schreibe die festen Segmente einer Route also klein. Die Werte dynamischer Segmente behalten ihre ursprüngliche Schreibweise.\n- Deklarierst du eine Route mit derselben Adresse, ersetzt sie die frühere Route.\n\n## Navigieren\n\n`REDIRECT(url)` ändert die Adresse im Browser und führt die passende Route aus. `NAV.clientside(selector)` macht dasselbe für Links, sodass du gewöhnliche `<a>`-Elemente schreiben kannst:\n\n```html\n<script>\n    NAV.clientside('a.jR');\n</script>\n\n<a class=\"jR\" href=\"/docs/\">Documentation</a>\n```\n\nDie Adresse stammt aus dem Attribut `href`, `data-href` oder `data-url`. Auch die Vor- und Zurück-Schaltflächen des Browsers führen die passenden Routen aus.\n\n`REDIRECT('../')` geht ein Segment nach oben. `REDIRECT()` ohne Argument und `NAV.refresh()` führen die aktuelle Route erneut aus.\n\n## Der aktuelle Zustand\n\n| Eigenschaft | Beschreibung |\n| --- | --- |\n| `NAV.url` | Die aktuelle Adresse ohne Query-String, zum Beispiel `/products/42/`. |\n| `NAV.href` | Die an die letzte Navigation übergebene Adresse, mit ihrem Query-String. |\n| `NAV.params` | Ein Array mit den Werten der dynamischen Segmente. |\n| `NAV.query` | Ein Objekt mit dem Query-String. |\n| `NAV.queryraw` | Der Query-String als Text. |\n| `NAV.is404` | `true`, wenn keine Route zur Adresse passt. |\n| `NAV.history` | Ein Array der vorherigen Adressen. |\n| `NAV.isback` | Die Anzahl der Adressen, zu denen du zurückgehen kannst. |\n| `NAV.isforward` | Die Anzahl der Adressen, zu denen du vorwärtsgehen kannst. |\n| `NAV.routes` | Ein Array der deklarierten Routen. |\n\n```js\nROUTE('/search/', function() {\n    console.log(NAV.url, NAV.query.q, NAV.query.page);\n});\n\nREDIRECT('/search/?q=total%20js&page=2');\n// /search/ total js 2\n```\n\nDie Eigenschaften `url`, `href`, `params`, `query`, `isback` und `isforward` sind auch [Paths](../paths/), du kannst sie also binden:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Middleware\n\nEine Middleware läuft vor dem Handler und entscheidet, ob der Handler ausgeführt wird. `MIDDLEWARE(name, fn)` deklariert eine. Gib ihren Namen im dritten Argument von `ROUTE()` an:\n\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n    if (user)\n        next();\n    else\n        next(false);\n});\n\nROUTE('/admin/', function() {\n    console.log('admin page');\n}, ['auth', '@admin', { title: 'Administration' }]);\n```\n\nDas Array einer Route kann Folgendes enthalten:\n\n| Eintrag | Beschreibung |\n| --- | --- |\n| `'name'` | Der Name einer Middleware. |\n| `'@name'` | Eine Rolle. Die Middleware erhält alle Rollen im Array `roles`. |\n| Ein Objekt | Optionen, die als `options` an die Middleware übergeben werden. |\n\nDie Middleware erhält `next`, `options`, `roles` und das Objekt `route`. Der Aufruf von `next()` fährt mit der nächsten Middleware fort. `next(false)` oder `next(new Error('...'))` stoppt die Kette, und der Handler läuft nicht.\n\nDu kannst das Array auch als zweites Argument übergeben: `ROUTE('/admin/', ['auth'], handler)`.\n\n## Eine Route vorbereiten\n\nEine Funktion als drittes Argument läuft einmal, wenn die Route zum ersten Mal geöffnet wird. Rufe `next` auf, um zum Handler weiterzugehen. Das eignet sich, um zu laden, was ein Teil der Anwendung braucht:\n\n```js\nROUTE('/reports/', function() {\n    console.log('handler');\n}, function(next) {\n    console.log('init');\n    IMPORT('once /parts/reports.html', '#content', next);\n});\n```\n\nDer erste Besuch gibt `init` und `handler` aus. Jeder weitere Besuch gibt nur `handler` aus. Um das mit Middleware zu kombinieren, übergib die Middleware als viertes Argument: `ROUTE(url, handler, init, ['auth'])`.\n\n## Auf Navigation reagieren\n\n| Event | Argumente | Wann es ausgelöst wird |\n| --- | --- | --- |\n| `location` | `url` | Bei jeder Navigation. |\n| `404` | | Keine Route passt zur Adresse. |\n| `route` | `url` | Eine Route wurde deklariert. |\n\n```js\nON('location', function(url) {\n    console.log('location', url);\n});\n\nON('404', function() {\n    console.log('not found', NAV.url);\n});\n```\n\n`NAV.status(code, [data])` löst ein nach dem Code benanntes Event aus. So hast du eine zentrale Stelle für die Fehlerbehandlung:\n\n```js\nON('500', function(error) {\n    console.log('failed', error);\n});\n\nNAV.status(500, 'Database is down');\n```\n\n## Zurück und vorwärts gehen\n\n`NAV.back()` öffnet die vorherige Adresse und `NAV.forward()` die nächste:\n\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();    // NAV.url is '/a/'\nNAV.forward(); // NAV.url is '/b/'\n```\n\n`NAV.prev()` und `NAV.next()` geben die Adresse auf der jeweiligen Seite zurück, ohne zu navigieren.\n\n## Query-Parameter beibehalten\n\n`NAV.remember(name, value)` fügt jedem weiteren `REDIRECT()` einen Query-Parameter hinzu. Verwende `null` als Wert, um das zu beenden:\n\n```js\nNAV.remember('lang', 'sk');\nREDIRECT('/items/');        // NAV.href is '/items/?lang=sk'\n\nNAV.remember('lang', null);\nREDIRECT('/items/');        // NAV.href is '/items/'\n```\n\n## Eine Route entfernen\n\n`NAV.remove(url)` löscht eine mit dieser Adresse deklarierte Route.\n\n## Routing ohne Adressleiste\n\n`NAV.custom()` hält das Routing innerhalb der Anwendung: `REDIRECT()` führt Routen aus, und die Adresse im Browser bleibt gleich. Rufe die Methode vor der ersten Navigation auf. Das eignet sich für eingebettete Anwendungen und Widgets.\n\nDie aktuelle Adresse wird einen Monat lang gespeichert und beim nächsten Besuch wieder geöffnet. Übergib eine Ablaufzeit wie `'1 day'`, um die Dauer zu ändern, oder `false`, um nichts zu speichern:\n\n```js\nNAV.custom();\nNAV.custom('1 day');\nNAV.custom(false);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU020M61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/routing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Enrutamiento","summary":"Asocia direcciones URL a funciones con ROUTE(), navega con REDIRECT() y lee el estado actual desde NAV.","markdown":"---\ntitle: Enrutamiento\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/routing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Enrutamiento\n\n> Asocia direcciones URL a funciones con ROUTE(), navega con REDIRECT() y lee el estado actual desde NAV.\n\nEl enrutamiento ejecuta una función para cada dirección de una aplicación de una sola página. `ROUTE()` declara las direcciones, `REDIRECT()` se mueve entre ellas sin recargar la página y el objeto global `NAV` contiene el estado actual.\n\nEl servidor tiene que devolver la página de la aplicación para cada dirección que gestiona una ruta, de modo que el navegador pueda abrir esas direcciones directamente.\n\n## Declarar rutas\n\n`ROUTE(url, handler)` conecta una dirección con una función. Los segmentos dinámicos se escriben entre llaves, y sus valores llegan como argumentos del manejador:\n\n```js\nROUTE('/', function() {\n    console.log('home');\n});\n\nROUTE('/products/', function() {\n    console.log('products');\n});\n\nROUTE('/products/new/', function() {\n    console.log('new product');\n});\n\nROUTE('/products/{id}/', function(id) {\n    console.log('product', id);\n});\n\nROUTE('/products/{id}/reviews/{review}/', function(id, review) {\n    console.log('review', id, review);\n});\n```\n\n```js\nREDIRECT('/products/new/');            // new product\nREDIRECT('/products/42');              // product 42\nREDIRECT('/PRODUCTS/AbC/');            // product AbC\nREDIRECT('/products/42/reviews/7/');   // review 42 7\n```\n\nDentro de un manejador, `this` es el objeto `NAV`.\n\n### Cómo se compara una dirección\n\n- Las rutas fijas tienen prioridad sobre las rutas con segmentos dinámicos, de modo que `/products/new/` no lo gestiona `/products/{id}/`.\n- La dirección debe tener el mismo número de segmentos que la ruta.\n- Si falta la barra final, se añade a la dirección.\n- La dirección se compara en minúsculas, así que escribe en minúsculas los segmentos fijos de una ruta. Los valores de los segmentos dinámicos conservan sus mayúsculas y minúsculas originales.\n- Declarar una ruta con la misma dirección sustituye a la ruta anterior.\n\n## Navegar\n\n`REDIRECT(url)` cambia la dirección en el navegador y ejecuta la ruta correspondiente. `NAV.clientside(selector)` hace lo mismo para los enlaces, de modo que puedes escribir elementos `<a>` normales:\n\n```html\n<script>\n    NAV.clientside('a.jR');\n</script>\n\n<a class=\"jR\" href=\"/docs/\">Documentation</a>\n```\n\nLa dirección procede del atributo `href`, `data-href` o `data-url`. Los botones Atrás y Adelante del navegador también ejecutan las rutas correspondientes.\n\n`REDIRECT('../')` sube un segmento. `REDIRECT()` sin argumentos y `NAV.refresh()` vuelven a ejecutar la ruta actual.\n\n## El estado actual\n\n| Propiedad | Descripción |\n| --- | --- |\n| `NAV.url` | La dirección actual sin la cadena de consulta, por ejemplo `/products/42/`. |\n| `NAV.href` | La dirección pasada a la última navegación, con su cadena de consulta. |\n| `NAV.params` | Un array con los valores de los segmentos dinámicos. |\n| `NAV.query` | Un objeto con la cadena de consulta. |\n| `NAV.queryraw` | La cadena de consulta como texto. |\n| `NAV.is404` | `true` si ninguna ruta coincide con la dirección. |\n| `NAV.history` | Un array con las direcciones anteriores. |\n| `NAV.isback` | El número de direcciones a las que puedes volver. |\n| `NAV.isforward` | El número de direcciones a las que puedes avanzar. |\n| `NAV.routes` | Un array con las rutas declaradas. |\n\n```js\nROUTE('/search/', function() {\n    console.log(NAV.url, NAV.query.q, NAV.query.page);\n});\n\nREDIRECT('/search/?q=total%20js&page=2');\n// /search/ total js 2\n```\n\nLas propiedades `url`, `href`, `params`, `query`, `isback` e `isforward` también son [paths](../paths/), así que puedes enlazarlas:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Middleware\n\nUn middleware se ejecuta antes del manejador y decide si el manejador se ejecuta. `MIDDLEWARE(name, fn)` declara uno. Indica su nombre en el tercer argumento de `ROUTE()`:\n\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n    if (user)\n        next();\n    else\n        next(false);\n});\n\nROUTE('/admin/', function() {\n    console.log('admin page');\n}, ['auth', '@admin', { title: 'Administration' }]);\n```\n\nEl array de una ruta puede contener:\n\n| Elemento | Descripción |\n| --- | --- |\n| `'name'` | El nombre de un middleware. |\n| `'@name'` | Un rol. El middleware recibe todos los roles en el array `roles`. |\n| Un objeto | Opciones que se pasan al middleware como `options`. |\n\nEl middleware recibe `next`, `options`, `roles` y el objeto `route`. Al llamar a `next()` se continúa con el siguiente middleware. `next(false)` o `next(new Error('...'))` detiene la cadena, y el manejador no se ejecuta.\n\nTambién puedes pasar el array como segundo argumento: `ROUTE('/admin/', ['auth'], handler)`.\n\n## Preparar una ruta\n\nUna función como tercer argumento se ejecuta una vez, la primera vez que se abre la ruta. Llama a `next` para continuar con el manejador. Es útil para cargar lo que necesita una parte de la aplicación:\n\n```js\nROUTE('/reports/', function() {\n    console.log('handler');\n}, function(next) {\n    console.log('init');\n    IMPORT('once /parts/reports.html', '#content', next);\n});\n```\n\nLa primera visita imprime `init` y `handler`. Cada visita siguiente imprime solo `handler`. Para combinarla con middleware, pasa el middleware como cuarto argumento: `ROUTE(url, handler, init, ['auth'])`.\n\n## Reaccionar a la navegación\n\n| Evento | Argumentos | Cuándo se emite |\n| --- | --- | --- |\n| `location` | `url` | En cada navegación. |\n| `404` | | Ninguna ruta coincide con la dirección. |\n| `route` | `url` | Se ha declarado una ruta. |\n\n```js\nON('location', function(url) {\n    console.log('location', url);\n});\n\nON('404', function() {\n    console.log('not found', NAV.url);\n});\n```\n\n`NAV.status(code, [data])` emite un evento con el nombre del código, lo que te da un único lugar para gestionar los errores:\n\n```js\nON('500', function(error) {\n    console.log('failed', error);\n});\n\nNAV.status(500, 'Database is down');\n```\n\n## Ir atrás y adelante\n\n`NAV.back()` abre la dirección anterior y `NAV.forward()` la siguiente:\n\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();    // NAV.url is '/a/'\nNAV.forward(); // NAV.url is '/b/'\n```\n\n`NAV.prev()` y `NAV.next()` devuelven la dirección de cada lado sin moverse.\n\n## Conservar los parámetros de consulta\n\n`NAV.remember(name, value)` añade un parámetro de consulta a cada `REDIRECT()` posterior. Usa `null` como valor para dejar de hacerlo:\n\n```js\nNAV.remember('lang', 'sk');\nREDIRECT('/items/');        // NAV.href is '/items/?lang=sk'\n\nNAV.remember('lang', null);\nREDIRECT('/items/');        // NAV.href is '/items/'\n```\n\n## Eliminar una ruta\n\n`NAV.remove(url)` borra una ruta declarada con esa dirección.\n\n## Enrutamiento sin la barra de direcciones\n\n`NAV.custom()` mantiene el enrutamiento dentro de la aplicación: `REDIRECT()` ejecuta las rutas y la dirección del navegador no cambia. Llámalo antes de la primera navegación. Es útil para aplicaciones incrustadas y widgets.\n\nLa dirección actual se guarda durante un mes y se vuelve a abrir en la siguiente visita. Pasa una caducidad como `'1 day'` para cambiar el tiempo, o `false` para no guardar nada:\n\n```js\nNAV.custom();\nNAV.custom('1 day');\nNAV.custom(false);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU020M61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/routing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Routage","summary":"Associe des adresses URL à des fonctions avec ROUTE(), navigue avec REDIRECT() et lis l'état actuel dans NAV.","markdown":"---\ntitle: Routage\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/routing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Routage\n\n> Associe des adresses URL à des fonctions avec ROUTE(), navigue avec REDIRECT() et lis l'état actuel dans NAV.\n\nLe routage exécute une fonction pour chaque adresse d'une application monopage. `ROUTE()` déclare les adresses, `REDIRECT()` permet de passer de l'une à l'autre sans recharger la page, et l'objet global `NAV` contient l'état actuel.\n\nLe serveur doit renvoyer la page de l'application pour chaque adresse gérée par une route, afin que le navigateur puisse ouvrir ces adresses directement.\n\n## Déclarer des routes\n\n`ROUTE(url, handler)` relie une adresse à une fonction. Les segments dynamiques s'écrivent entre accolades, et leurs valeurs arrivent comme arguments du gestionnaire :\n\n```js\nROUTE('/', function() {\n    console.log('home');\n});\n\nROUTE('/products/', function() {\n    console.log('products');\n});\n\nROUTE('/products/new/', function() {\n    console.log('new product');\n});\n\nROUTE('/products/{id}/', function(id) {\n    console.log('product', id);\n});\n\nROUTE('/products/{id}/reviews/{review}/', function(id, review) {\n    console.log('review', id, review);\n});\n```\n\n```js\nREDIRECT('/products/new/');            // new product\nREDIRECT('/products/42');              // product 42\nREDIRECT('/PRODUCTS/AbC/');            // product AbC\nREDIRECT('/products/42/reviews/7/');   // review 42 7\n```\n\nDans un gestionnaire, `this` est l'objet `NAV`.\n\n### Comment une adresse est mise en correspondance\n\n- Les routes fixes ont priorité sur les routes à segments dynamiques : `/products/new/` n'est donc pas géré par `/products/{id}/`.\n- L'adresse doit avoir le même nombre de segments que la route.\n- Une barre oblique finale manquante est ajoutée à l'adresse.\n- L'adresse est comparée en minuscules : écris donc les segments fixes d'une route en minuscules. Les valeurs des segments dynamiques conservent leur casse d'origine.\n- Déclarer une route avec la même adresse remplace la route précédente.\n\n## Naviguer\n\n`REDIRECT(url)` change l'adresse dans le navigateur et exécute la route correspondante. `NAV.clientside(selector)` fait de même pour les liens, ce qui te permet d'écrire des éléments `<a>` ordinaires :\n\n```html\n<script>\n    NAV.clientside('a.jR');\n</script>\n\n<a class=\"jR\" href=\"/docs/\">Documentation</a>\n```\n\nL'adresse provient de l'attribut `href`, `data-href` ou `data-url`. Les boutons précédent et suivant du navigateur exécutent eux aussi les routes correspondantes.\n\n`REDIRECT('../')` remonte d'un segment. `REDIRECT()` sans argument et `NAV.refresh()` exécutent de nouveau la route actuelle.\n\n## L'état actuel\n\n| Propriété | Description |\n| --- | --- |\n| `NAV.url` | L'adresse actuelle sans la chaîne de requête, par exemple `/products/42/`. |\n| `NAV.href` | L'adresse passée à la dernière navigation, avec sa chaîne de requête. |\n| `NAV.params` | Un tableau contenant les valeurs des segments dynamiques. |\n| `NAV.query` | Un objet contenant la chaîne de requête. |\n| `NAV.queryraw` | La chaîne de requête sous forme de texte. |\n| `NAV.is404` | `true` si aucune route ne correspond à l'adresse. |\n| `NAV.history` | Un tableau des adresses précédentes. |\n| `NAV.isback` | Le nombre d'adresses vers lesquelles tu peux revenir en arrière. |\n| `NAV.isforward` | Le nombre d'adresses vers lesquelles tu peux aller en avant. |\n| `NAV.routes` | Un tableau des routes déclarées. |\n\n```js\nROUTE('/search/', function() {\n    console.log(NAV.url, NAV.query.q, NAV.query.page);\n});\n\nREDIRECT('/search/?q=total%20js&page=2');\n// /search/ total js 2\n```\n\nLes propriétés `url`, `href`, `params`, `query`, `isback` et `isforward` sont aussi des [paths](../paths/), ce qui te permet de les lier :\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Middleware\n\nUn middleware s'exécute avant le gestionnaire et décide si celui-ci s'exécute. `MIDDLEWARE(name, fn)` en déclare un. Indique son nom dans le troisième argument de `ROUTE()` :\n\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n    if (user)\n        next();\n    else\n        next(false);\n});\n\nROUTE('/admin/', function() {\n    console.log('admin page');\n}, ['auth', '@admin', { title: 'Administration' }]);\n```\n\nLe tableau d'une route peut contenir :\n\n| Élément | Description |\n| --- | --- |\n| `'name'` | Le nom d'un middleware. |\n| `'@name'` | Un rôle. Le middleware reçoit tous les rôles dans le tableau `roles`. |\n| Un objet | Des options passées au middleware sous le nom `options`. |\n\nLe middleware reçoit `next`, `options`, `roles` et l'objet `route`. Appeler `next()` passe au middleware suivant. `next(false)` ou `next(new Error('...'))` interrompt la chaîne, et le gestionnaire ne s'exécute pas.\n\nTu peux aussi passer le tableau comme deuxième argument : `ROUTE('/admin/', ['auth'], handler)`.\n\n## Préparer une route\n\nUne fonction passée comme troisième argument s'exécute une seule fois, à la première ouverture de la route. Appelle `next` pour continuer vers le gestionnaire. Elle convient pour charger ce dont une partie de l'application a besoin :\n\n```js\nROUTE('/reports/', function() {\n    console.log('handler');\n}, function(next) {\n    console.log('init');\n    IMPORT('once /parts/reports.html', '#content', next);\n});\n```\n\nLa première visite affiche `init` et `handler`. Chaque visite suivante n'affiche que `handler`. Pour combiner cela avec un middleware, passe le middleware comme quatrième argument : `ROUTE(url, handler, init, ['auth'])`.\n\n## Réagir à la navigation\n\n| Événement | Arguments | Quand il est émis |\n| --- | --- | --- |\n| `location` | `url` | À chaque navigation. |\n| `404` | | Aucune route ne correspond à l'adresse. |\n| `route` | `url` | Une route a été déclaré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);\n});\n```\n\n`NAV.status(code, [data])` émet un événement nommé d'après le code, ce qui te donne un seul endroit pour gérer les erreurs :\n\n```js\nON('500', function(error) {\n    console.log('failed', error);\n});\n\nNAV.status(500, 'Database is down');\n```\n\n## Revenir en arrière et avancer\n\n`NAV.back()` ouvre l'adresse précédente et `NAV.forward()` l'adresse suivante :\n\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();    // NAV.url is '/a/'\nNAV.forward(); // NAV.url is '/b/'\n```\n\n`NAV.prev()` et `NAV.next()` renvoient l'adresse de chaque côté sans se déplacer.\n\n## Conserver des paramètres de requête\n\n`NAV.remember(name, value)` ajoute un paramètre de requête à chaque `REDIRECT()` suivant. Utilise `null` comme valeur pour arrêter :\n\n```js\nNAV.remember('lang', 'sk');\nREDIRECT('/items/');        // NAV.href is '/items/?lang=sk'\n\nNAV.remember('lang', null);\nREDIRECT('/items/');        // NAV.href is '/items/'\n```\n\n## Supprimer une route\n\n`NAV.remove(url)` supprime une route déclarée avec cette adresse.\n\n## Routage sans la barre d'adresse\n\n`NAV.custom()` garde le routage à l'intérieur de l'application : `REDIRECT()` exécute les routes et l'adresse du navigateur reste la même. Appelle-le avant la première navigation. Il convient aux applications embarquées et aux widgets.\n\nL'adresse actuelle est conservée pendant un mois et rouverte à la visite suivante. Passe une expiration comme `'1 day'` pour changer cette durée, ou `false` pour ne rien conserver :\n\n```js\nNAV.custom();\nNAV.custom('1 day');\nNAV.custom(false);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU020M61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/routing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Routing","summary":"Associa gli indirizzi URL a funzioni con ROUTE(), naviga con REDIRECT() e leggi lo stato corrente da NAV.","markdown":"---\ntitle: Routing\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/routing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Routing\n\n> Associa gli indirizzi URL a funzioni con ROUTE(), naviga con REDIRECT() e leggi lo stato corrente da NAV.\n\nIl routing esegue una funzione per ogni indirizzo di un'applicazione a pagina singola. `ROUTE()` dichiara gli indirizzi, `REDIRECT()` si sposta tra di essi senza ricaricare la pagina e l'oggetto globale `NAV` contiene lo stato corrente.\n\nIl server deve restituire la pagina dell'applicazione per ogni indirizzo gestito da una rotta, in modo che il browser possa aprire direttamente quegli indirizzi.\n\n## Dichiarare le rotte\n\n`ROUTE(url, handler)` collega un indirizzo a una funzione. I segmenti dinamici si scrivono tra parentesi graffe e i loro valori arrivano come argomenti del gestore:\n\n```js\nROUTE('/', function() {\n    console.log('home');\n});\n\nROUTE('/products/', function() {\n    console.log('products');\n});\n\nROUTE('/products/new/', function() {\n    console.log('new product');\n});\n\nROUTE('/products/{id}/', function(id) {\n    console.log('product', id);\n});\n\nROUTE('/products/{id}/reviews/{review}/', function(id, review) {\n    console.log('review', id, review);\n});\n```\n\n```js\nREDIRECT('/products/new/');            // new product\nREDIRECT('/products/42');              // product 42\nREDIRECT('/PRODUCTS/AbC/');            // product AbC\nREDIRECT('/products/42/reviews/7/');   // review 42 7\n```\n\nAll'interno di un gestore, `this` è l'oggetto `NAV`.\n\n### Come viene abbinato un indirizzo\n\n- Le rotte fisse hanno la precedenza su quelle con segmenti dinamici, quindi `/products/new/` non viene gestito da `/products/{id}/`.\n- L'indirizzo deve avere lo stesso numero di segmenti della rotta.\n- Se manca la barra finale, viene aggiunta all'indirizzo.\n- L'indirizzo viene confrontato in minuscolo, quindi scrivi in minuscolo i segmenti fissi di una rotta. I valori dei segmenti dinamici mantengono le maiuscole e le minuscole originali.\n- Dichiarare una rotta con lo stesso indirizzo sostituisce la rotta precedente.\n\n## Navigare\n\n`REDIRECT(url)` cambia l'indirizzo nel browser ed esegue la rotta corrispondente. `NAV.clientside(selector)` fa lo stesso per i link, così puoi scrivere normali elementi `<a>`:\n\n```html\n<script>\n    NAV.clientside('a.jR');\n</script>\n\n<a class=\"jR\" href=\"/docs/\">Documentation</a>\n```\n\nL'indirizzo proviene dall'attributo `href`, `data-href` o `data-url`. Anche i pulsanti indietro e avanti del browser eseguono le rotte corrispondenti.\n\n`REDIRECT('../')` sale di un segmento. `REDIRECT()` senza argomenti e `NAV.refresh()` eseguono di nuovo la rotta corrente.\n\n## Lo stato corrente\n\n| Proprietà | Descrizione |\n| --- | --- |\n| `NAV.url` | L'indirizzo corrente senza la stringa di query, ad esempio `/products/42/`. |\n| `NAV.href` | L'indirizzo passato all'ultima navigazione, con la sua stringa di query. |\n| `NAV.params` | Un array con i valori dei segmenti dinamici. |\n| `NAV.query` | Un oggetto con la stringa di query. |\n| `NAV.queryraw` | La stringa di query come testo. |\n| `NAV.is404` | `true` se nessuna rotta corrisponde all'indirizzo. |\n| `NAV.history` | Un array degli indirizzi precedenti. |\n| `NAV.isback` | Il numero di indirizzi a cui puoi tornare indietro. |\n| `NAV.isforward` | Il numero di indirizzi verso cui puoi andare avanti. |\n| `NAV.routes` | Un array delle rotte dichiarate. |\n\n```js\nROUTE('/search/', function() {\n    console.log(NAV.url, NAV.query.q, NAV.query.page);\n});\n\nREDIRECT('/search/?q=total%20js&page=2');\n// /search/ total js 2\n```\n\nLe proprietà `url`, `href`, `params`, `query`, `isback` e `isforward` sono anche [path](../paths/), quindi puoi associarle:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Middleware\n\nUn middleware viene eseguito prima del gestore e decide se il gestore debba essere eseguito. `MIDDLEWARE(name, fn)` ne dichiara uno. Indicane il nome nel terzo argomento di `ROUTE()`:\n\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n    if (user)\n        next();\n    else\n        next(false);\n});\n\nROUTE('/admin/', function() {\n    console.log('admin page');\n}, ['auth', '@admin', { title: 'Administration' }]);\n```\n\nL'array di una rotta può contenere:\n\n| Voce | Descrizione |\n| --- | --- |\n| `'name'` | Il nome di un middleware. |\n| `'@name'` | Un ruolo. Il middleware riceve tutti i ruoli nell'array `roles`. |\n| Un oggetto | Opzioni passate al middleware come `options`. |\n\nIl middleware riceve `next`, `options`, `roles` e l'oggetto `route`. Chiamare `next()` prosegue con il middleware successivo. `next(false)` o `next(new Error('...'))` interrompe la catena e il gestore non viene eseguito.\n\nPuoi anche passare l'array come secondo argomento: `ROUTE('/admin/', ['auth'], handler)`.\n\n## Preparare una rotta\n\nUna funzione come terzo argomento viene eseguita una sola volta, la prima volta che si apre la rotta. Chiama `next` per proseguire verso il gestore. È adatta a caricare ciò che serve a una parte dell'applicazione:\n\n```js\nROUTE('/reports/', function() {\n    console.log('handler');\n}, function(next) {\n    console.log('init');\n    IMPORT('once /parts/reports.html', '#content', next);\n});\n```\n\nLa prima visita stampa `init` e `handler`. Ogni visita successiva stampa solo `handler`. Per combinarla con un middleware, passa il middleware come quarto argomento: `ROUTE(url, handler, init, ['auth'])`.\n\n## Reagire alla navigazione\n\n| Evento | Argomenti | Quando viene emesso |\n| --- | --- | --- |\n| `location` | `url` | A ogni navigazione. |\n| `404` | | Nessuna rotta corrisponde all'indirizzo. |\n| `route` | `url` | È stata dichiarata una 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);\n});\n```\n\n`NAV.status(code, [data])` emette un evento con il nome del codice, così hai un unico punto in cui gestire gli errori:\n\n```js\nON('500', function(error) {\n    console.log('failed', error);\n});\n\nNAV.status(500, 'Database is down');\n```\n\n## Andare indietro e avanti\n\n`NAV.back()` apre l'indirizzo precedente e `NAV.forward()` quello successivo:\n\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();    // NAV.url is '/a/'\nNAV.forward(); // NAV.url is '/b/'\n```\n\n`NAV.prev()` e `NAV.next()` restituiscono l'indirizzo su ciascun lato senza spostarsi.\n\n## Mantenere i parametri di query\n\n`NAV.remember(name, value)` aggiunge un parametro di query a ogni `REDIRECT()` successivo. Usa `null` come valore per smettere:\n\n```js\nNAV.remember('lang', 'sk');\nREDIRECT('/items/');        // NAV.href is '/items/?lang=sk'\n\nNAV.remember('lang', null);\nREDIRECT('/items/');        // NAV.href is '/items/'\n```\n\n## Rimuovere una rotta\n\n`NAV.remove(url)` elimina una rotta dichiarata con quell'indirizzo.\n\n## Routing senza la barra degli indirizzi\n\n`NAV.custom()` mantiene il routing all'interno dell'applicazione: `REDIRECT()` esegue le rotte e l'indirizzo nel browser resta invariato. Chiamalo prima della prima navigazione. È adatto alle applicazioni incorporate e ai widget.\n\nL'indirizzo corrente viene memorizzato per un mese e riaperto alla visita successiva. Passa una scadenza come `'1 day'` per cambiare la durata, oppure `false` per non memorizzare nulla:\n\n```js\nNAV.custom();\nNAV.custom('1 day');\nNAV.custom(false);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammU020M61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/routing/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Smerovanie","summary":"Mapuj adresy URL na funkcie pomocou ROUTE(), prechádzaj medzi nimi pomocou REDIRECT() a aktuálny stav čítaj z NAV.","markdown":"---\ntitle: Smerovanie\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/routing/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Smerovanie\n\n> Mapuj adresy URL na funkcie pomocou ROUTE(), prechádzaj medzi nimi pomocou REDIRECT() a aktuálny stav čítaj z NAV.\n\nSmerovanie spúšťa funkciu pre každú adresu jednostránkovej aplikácie. `ROUTE()` deklaruje adresy, `REDIRECT()` medzi nimi prechádza bez opätovného načítania stránky a globálny objekt `NAV` obsahuje aktuálny stav.\n\nServer musí vracať stránku aplikácie pre každú adresu, ktorú obsluhuje niektorá trasa, aby ich prehliadač mohol otvoriť priamo.\n\n## Deklarácia trás\n\n`ROUTE(url, handler)` spája adresu s funkciou. Dynamické segmenty sa píšu do zložených zátvoriek a ich hodnoty prichádzajú ako argumenty obslužnej funkcie:\n\n```js\nROUTE('/', function() {\n    console.log('home');\n});\n\nROUTE('/products/', function() {\n    console.log('products');\n});\n\nROUTE('/products/new/', function() {\n    console.log('new product');\n});\n\nROUTE('/products/{id}/', function(id) {\n    console.log('product', id);\n});\n\nROUTE('/products/{id}/reviews/{review}/', function(id, review) {\n    console.log('review', id, review);\n});\n```\n\n```js\nREDIRECT('/products/new/');            // new product\nREDIRECT('/products/42');              // product 42\nREDIRECT('/PRODUCTS/AbC/');            // product AbC\nREDIRECT('/products/42/reviews/7/');   // review 42 7\n```\n\nVnútri obslužnej funkcie je `this` objekt `NAV`.\n\n### Ako sa adresa porovnáva\n\n- Pevné trasy majú prednosť pred trasami s dynamickými segmentmi, takže `/products/new/` neobslúži `/products/{id}/`.\n- Adresa musí mať rovnaký počet segmentov ako trasa.\n- Chýbajúca koncová lomka sa k adrese doplní.\n- Adresa sa porovnáva malými písmenami, preto pevné segmenty trasy píš malými písmenami. Hodnoty dynamických segmentov si zachovávajú pôvodnú veľkosť písmen.\n- Deklarácia trasy s rovnakou adresou nahradí predchádzajúcu trasu.\n\n## Navigácia\n\n`REDIRECT(url)` zmení adresu v prehliadači a spustí zodpovedajúcu trasu. `NAV.clientside(selector)` robí to isté pre odkazy, takže môžeš písať obyčajné elementy `<a>`:\n\n```html\n<script>\n    NAV.clientside('a.jR');\n</script>\n\n<a class=\"jR\" href=\"/docs/\">Documentation</a>\n```\n\nAdresa pochádza z atribútu `href`, `data-href` alebo `data-url`. Zodpovedajúce trasy spúšťajú aj tlačidlá prehliadača Späť a Dopredu.\n\n`REDIRECT('../')` prejde o jeden segment vyššie. `REDIRECT()` bez argumentu a `NAV.refresh()` znova spustia aktuálnu trasu.\n\n## Aktuálny stav\n\n| Vlastnosť | Popis |\n| --- | --- |\n| `NAV.url` | Aktuálna adresa bez reťazca dotazu, napríklad `/products/42/`. |\n| `NAV.href` | Adresa odovzdaná poslednej navigácii, vrátane reťazca dotazu. |\n| `NAV.params` | Pole s hodnotami dynamických segmentov. |\n| `NAV.query` | Objekt s reťazcom dotazu. |\n| `NAV.queryraw` | Reťazec dotazu ako text. |\n| `NAV.is404` | `true`, ak adrese nezodpovedá žiadna trasa. |\n| `NAV.history` | Pole predchádzajúcich adries. |\n| `NAV.isback` | Počet adries, na ktoré sa môžeš vrátiť. |\n| `NAV.isforward` | Počet adries, na ktoré môžeš prejsť dopredu. |\n| `NAV.routes` | Pole deklarovaných trás. |\n\n```js\nROUTE('/search/', function() {\n    console.log(NAV.url, NAV.query.q, NAV.query.page);\n});\n\nREDIRECT('/search/?q=total%20js&page=2');\n// /search/ total js 2\n```\n\nVlastnosti `url`, `href`, `params`, `query`, `isback` a `isforward` sú zároveň [paths](../paths/), takže ich môžeš naviazať:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Middleware\n\nMiddleware beží pred obslužnou funkciou a rozhoduje, či sa obslužná funkcia spustí. `MIDDLEWARE(name, fn)` ho deklaruje. Jeho názov uveď v treťom argumente `ROUTE()`:\n\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n    if (user)\n        next();\n    else\n        next(false);\n});\n\nROUTE('/admin/', function() {\n    console.log('admin page');\n}, ['auth', '@admin', { title: 'Administration' }]);\n```\n\nPole trasy môže obsahovať:\n\n| Položka | Popis |\n| --- | --- |\n| `'name'` | Názov middlewaru. |\n| `'@name'` | Rola. Middleware dostane všetky roly v poli `roles`. |\n| Objekt | Možnosti odovzdané middlewaru ako `options`. |\n\nMiddleware dostane `next`, `options`, `roles` a objekt `route`. Volanie `next()` pokračuje ďalším middlewarom. `next(false)` alebo `next(new Error('...'))` reťazec zastaví a obslužná funkcia sa nespustí.\n\nPole môžeš odovzdať aj ako druhý argument: `ROUTE('/admin/', ['auth'], handler)`.\n\n## Príprava trasy\n\nFunkcia v treťom argumente sa spustí raz, pri prvom otvorení trasy. Zavolaj `next`, aby sa pokračovalo k obslužnej funkcii. Hodí sa na načítanie toho, čo daná časť aplikácie potrebuje:\n\n```js\nROUTE('/reports/', function() {\n    console.log('handler');\n}, function(next) {\n    console.log('init');\n    IMPORT('once /parts/reports.html', '#content', next);\n});\n```\n\nPrvá návšteva vypíše `init` a `handler`. Každá ďalšia vypíše iba `handler`. Ak ju chceš skombinovať s middlewarom, odovzdaj middleware ako štvrtý argument: `ROUTE(url, handler, init, ['auth'])`.\n\n## Reakcia na navigáciu\n\n| Udalosť | Argumenty | Kedy sa vyšle |\n| --- | --- | --- |\n| `location` | `url` | Pri každej navigácii. |\n| `404` | | Adrese nezodpovedá žiadna trasa. |\n| `route` | `url` | Bola deklarovaná 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);\n});\n```\n\n`NAV.status(code, [data])` vyšle udalosť pomenovanú podľa kódu, takže chyby môžeš spracovať na jednom mieste:\n\n```js\nON('500', function(error) {\n    console.log('failed', error);\n});\n\nNAV.status(500, 'Database is down');\n```\n\n## Návrat späť a posun dopredu\n\n`NAV.back()` otvorí predchádzajúcu adresu a `NAV.forward()` nasledujúcu:\n\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();    // NAV.url is '/a/'\nNAV.forward(); // NAV.url is '/b/'\n```\n\n`NAV.prev()` a `NAV.next()` vrátia adresu na príslušnej strane bez presunu.\n\n## Zachovanie parametrov dotazu\n\n`NAV.remember(name, value)` pridá parameter dotazu ku každému ďalšiemu `REDIRECT()`. Ak to chceš zastaviť, použi ako hodnotu `null`:\n\n```js\nNAV.remember('lang', 'sk');\nREDIRECT('/items/');        // NAV.href is '/items/?lang=sk'\n\nNAV.remember('lang', null);\nREDIRECT('/items/');        // NAV.href is '/items/'\n```\n\n## Odstránenie trasy\n\n`NAV.remove(url)` vymaže trasu deklarovanú s touto adresou.\n\n## Smerovanie bez panela s adresou\n\n`NAV.custom()` drží smerovanie vnútri aplikácie: `REDIRECT()` spúšťa trasy a adresa v prehliadači zostáva rovnaká. Zavolaj ho pred prvou navigáciou. Hodí sa pre vložené aplikácie a widgety.\n\nAktuálna adresa sa uloží na jeden mesiac a pri ďalšej návšteve sa znova otvorí. Ak chceš tento čas zmeniť, odovzdaj expiráciu, napríklad `'1 day'`, alebo `false`, ak nechceš ukladať nič:\n\n```js\nNAV.custom();\nNAV.custom('1 day');\nNAV.custom(false);\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTb1kM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/forms/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Forms and validation","summary":"Validate values in components, track what the user changed and control the state of a whole form.","markdown":"---\ntitle: Forms and validation\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/forms/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Forms and validation\n\n> Validate values in components, track what the user changed and control the state of a whole form.\n\njComponent has no form object. A form is a group of [components](../creating-components/) whose paths share a prefix, such as `form.name` and `form.city`. Each component keeps its own state, and global functions read the state of the whole group through a path like `form.*`.\n\n## The state of a field\n\nEvery component with a path has these values in its `config` object:\n\n| Value | CSS class | Meaning |\n| --- | --- | --- |\n| `config.invalid` | `ui-invalid` | The `validate` function rejected the value. |\n| `config.touched` | `ui-touched` | The user changed the field. |\n| `config.modified` | `ui-modified` | The value was changed by the user or with the `@change` flag. |\n| `config.disabled` | `ui-disabled` | The field is disabled. |\n\nThe library adds and removes the CSS classes on the element of the component.\n\n## Validating a value\n\nGive the component a `validate` function. It receives the value and returns `true` when the value is valid. The library calls it when the component starts and on every change. An `<input>` with the `data-jc-bind` attribute is connected to the path of the component:\n\n```html\n<script>\n    COMPONENT('textbox', 'required:false', function(self, config) {\n\n        self.validate = function(value) {\n            return !config.required || !!value;\n        };\n\n        self.make = function() {\n            self.html('<input type=\"text\" data-jc-bind />');\n        };\n    });\n\n    var form = { name: '' };\n</script>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n```\n\nThe classes of the element follow the user:\n\n| Moment | Classes |\n| --- | --- |\n| The page opens | `ui-invalid` |\n| The user types `Peter` | `ui-modified ui-touched` |\n| The user clears the field | `ui-modified ui-touched ui-invalid` |\n\nAn empty required field is invalid from the start. To avoid showing errors on a fresh form, style only fields the user has touched:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\n`DEF.validators` contains regular expressions for `email`, `phone` and `url`:\n\n```js\nself.validate = function(value) {\n    return DEF.validators.email.test(value || '');\n};\n```\n\n## Checking a form\n\n| Function | Returns `true` when |\n| --- | --- |\n| `VALID(path)` | No component under the path is invalid. |\n| `CAN(path)` | No component is invalid **and** at least one was touched. |\n| `DISABLED(path)` | `CAN(path)` is `false`. |\n\n`CAN()` also returns `true` when there is no component under the path.\n\nAdd the flag `visible` to check only the fields the user can see:\n\n```js\nVALID('form.*');            // false, a hidden required field is empty\nVALID('form.*', 'visible'); // true\n```\n\n## Enabling a save button\n\nWatch the form and update the button. Start with a disabled button, because the components are not ready yet when the page opens:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.city\"></ui-component>\n\n<button id=\"save\" disabled>Save</button>\n\n<script>\n    WATCH('form.*', function() {\n        $('#save').prop('disabled', DISABLED('form.*'));\n    });\n</script>\n```\n\n| Moment | `VALID` | `CAN` | Button |\n| --- | --- | --- | --- |\n| The page opens | `false` | `false` | disabled |\n| The user fills in the city only | `false` | `false` | disabled |\n| The user also fills in the name | `true` | `true` | enabled |\n\n## Showing errors on submit\n\n`CHANGE(path)` marks every field as touched and modified, so the invalid ones show their errors. `ERRORS(path)` returns the components that are touched and invalid:\n\n```js\nfunction save() {\n\n    CHANGE('form.*');\n\n    if (!VALID('form.*')) {\n        console.log(ERRORS('form.*').map(com => com.path));\n        return;\n    }\n\n    console.log(GET('form @reset'));\n}\n```\n\nWith two empty required fields, this prints `['form.name', 'form.city']`. Once they are filled in, it prints the model. The `@reset` flag clears the state of the form while reading it. `CHANGE(path, false)` removes the touched and modified state.\n\n## Reading what changed\n\n`MODIFIED(path)` returns the paths of the fields that were changed. The `@modified` flag of `GET()` returns an object with only those fields:\n\n```js\nvar form = { name: 'Peter', city: 'Bratislava' };\n\nSET('form.city @change', 'Prague');\n\nMODIFIED('form.*');    // ['form.city']\nGET('form @modified'); // { city: 'Prague' }\n```\n\nThe `@change` flag tells the library to treat a value from code as if the user had entered it. The other [flags](../flags/) work with forms too.\n\n## Resetting a form\n\n`RESET(path)` clears the touched and modified state and validates the fields again. Values stay as they are:\n\n```js\nRESET('form.*');\nMODIFIED('form.*'); // []\n```\n\n## Default values\n\nThe `default` attribute of a component holds a JavaScript expression. `DEFAULT(path)` writes the default values back to the fields:\n\n```html\n<ui-component name=\"textbox\" path=\"filter.search\" default=\"'all'\"></ui-component>\n\n<script>\n    SET('filter.search @change', 'books');\n\n    DEFAULT('filter.*');\n    RESET('filter.*');\n\n    // filter.search is 'all' and the field has no state classes\n</script>\n```\n\nCall `RESET()` after `DEFAULT()` so that the CSS classes of the fields are updated.\n\n## Forms in a plugin\n\nA [plugin](../plugins/) is a natural home for a form. `exports.modified` returns the changed fields and resets the state, and `exports.form` returns the whole model and resets the state:\n\n```html\n<script>\n    PLUGIN('profile', function(exports) {\n\n        exports.set({ name: 'Peter', city: 'Bratislava' });\n\n        exports.save = function() {\n            if (CAN('profile.*'))\n                console.log(exports.modified);\n        };\n    });\n</script>\n\n<ui-plugin path=\"profile\">\n    <ui-component name=\"textbox\" path=\"?.name\" config=\"required:true\"></ui-component>\n    <ui-component name=\"textbox\" path=\"?.city\"></ui-component>\n</ui-plugin>\n```\n\nAfter `SET('profile.city @change', 'Prague')`, `PLUGINS.profile.save()` prints `{ city: 'Prague' }`.\n\n## Reacting to state changes\n\nThe `state` delegate of a component runs whenever its state may have changed. Use it to show an error message or to change the look of the field:\n\n```js\nself.state = function(type, what) {\n    self.tclass('has-error', config.touched && config.invalid);\n};\n```\n\n`type` says who caused the change:\n\n| `type` | Cause |\n| --- | --- |\n| `0` | The component has been initialized. |\n| `1` | Code, for example `SET()` or `RESET()`. |\n| `2` | The user, through an input. |\n| `3` | `DEFAULT()`. |\n\n`what` says what happened:\n\n| `what` | Change |\n| --- | --- |\n| `1` | Validation. |\n| `2` | `CHANGE()`. |\n| `3` | Initialization, `RESET()` or `DEFAULT()`. |\n| `4` | `UPD()`. |\n| `5` | A new value. |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTb1kM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/forms/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Formulare und Validierung","summary":"Validiere Werte in Komponenten, verfolge die Änderungen des Benutzers und steuere den Zustand eines ganzen Formulars.","markdown":"---\ntitle: Formulare und Validierung\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/forms/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Formulare und Validierung\n\n> Validiere Werte in Komponenten, verfolge die Änderungen des Benutzers und steuere den Zustand eines ganzen Formulars.\n\njComponent hat kein Formularobjekt. Ein Formular ist eine Gruppe von [Komponenten](../creating-components/), deren Paths ein gemeinsames Präfix haben, etwa `form.name` und `form.city`. Jede Komponente verwaltet ihren eigenen Zustand, und globale Funktionen lesen den Zustand der gesamten Gruppe über einen Path wie `form.*`.\n\n## Der Zustand eines Felds\n\nJede Komponente mit einem Path hat diese Werte in ihrem Objekt `config`:\n\n| Wert | CSS-Klasse | Bedeutung |\n| --- | --- | --- |\n| `config.invalid` | `ui-invalid` | Die Funktion `validate` hat den Wert abgelehnt. |\n| `config.touched` | `ui-touched` | Der Benutzer hat das Feld geändert. |\n| `config.modified` | `ui-modified` | Der Wert wurde vom Benutzer oder mit dem Flag `@change` geändert. |\n| `config.disabled` | `ui-disabled` | Das Feld ist deaktiviert. |\n\nDie Bibliothek fügt die CSS-Klassen am Element der Komponente hinzu und entfernt sie wieder.\n\n## Einen Wert validieren\n\nGib der Komponente eine `validate`-Funktion. Diese erhält den Wert und gibt `true` zurück, wenn der Wert gültig ist. Die Bibliothek ruft sie beim Start der Komponente und bei jeder Änderung auf. Ein `<input>` mit dem Attribut `data-jc-bind` ist mit dem Path der Komponente verbunden:\n\n```html\n<script>\n    COMPONENT('textbox', 'required:false', function(self, config) {\n\n        self.validate = function(value) {\n            return !config.required || !!value;\n        };\n\n        self.make = function() {\n            self.html('<input type=\"text\" data-jc-bind />');\n        };\n    });\n\n    var form = { name: '' };\n</script>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n```\n\nDie Klassen des Elements folgen den Aktionen des Benutzers:\n\n| Moment | Klassen |\n| --- | --- |\n| Die Seite wird geöffnet | `ui-invalid` |\n| Der Benutzer gibt `Peter` ein | `ui-modified ui-touched` |\n| Der Benutzer leert das Feld | `ui-modified ui-touched ui-invalid` |\n\nEin leeres Pflichtfeld ist von Anfang an ungültig. Damit ein frisches Formular keine Fehler anzeigt, gestalte nur Felder, die der Benutzer berührt hat:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\n`DEF.validators` enthält reguläre Ausdrücke für `email`, `phone` und `url`:\n\n```js\nself.validate = function(value) {\n    return DEF.validators.email.test(value || '');\n};\n```\n\n## Ein Formular prüfen\n\n| Funktion | Gibt `true` zurück, wenn |\n| --- | --- |\n| `VALID(path)` | Keine Komponente unter dem Path ungültig ist. |\n| `CAN(path)` | Keine Komponente ungültig ist **und** mindestens eine berührt wurde. |\n| `DISABLED(path)` | `CAN(path)` den Wert `false` hat. |\n\n`CAN()` gibt auch dann `true` zurück, wenn es unter dem Path keine Komponente gibt.\n\nFüge das Flag `visible` hinzu, um nur die Felder zu prüfen, die der Benutzer sehen kann:\n\n```js\nVALID('form.*');            // false, a hidden required field is empty\nVALID('form.*', 'visible'); // true\n```\n\n## Eine Speichern-Schaltfläche aktivieren\n\nÜberwache das Formular und aktualisiere die Schaltfläche. Beginne mit einer deaktivierten Schaltfläche, denn beim Öffnen der Seite sind die Komponenten noch nicht bereit:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.city\"></ui-component>\n\n<button id=\"save\" disabled>Save</button>\n\n<script>\n    WATCH('form.*', function() {\n        $('#save').prop('disabled', DISABLED('form.*'));\n    });\n</script>\n```\n\n| Moment | `VALID` | `CAN` | Schaltfläche |\n| --- | --- | --- | --- |\n| Die Seite wird geöffnet | `false` | `false` | deaktiviert |\n| Der Benutzer füllt nur die Stadt aus | `false` | `false` | deaktiviert |\n| Der Benutzer füllt auch den Namen aus | `true` | `true` | aktiviert |\n\n## Fehler beim Absenden anzeigen\n\n`CHANGE(path)` markiert jedes Feld als berührt und geändert, sodass die ungültigen ihre Fehler anzeigen. `ERRORS(path)` gibt die Komponenten zurück, die berührt und ungültig sind:\n\n```js\nfunction save() {\n\n    CHANGE('form.*');\n\n    if (!VALID('form.*')) {\n        console.log(ERRORS('form.*').map(com => com.path));\n        return;\n    }\n\n    console.log(GET('form @reset'));\n}\n```\n\nBei zwei leeren Pflichtfeldern gibt das `['form.name', 'form.city']` aus. Sobald beide ausgefüllt sind, wird das Modell ausgegeben. Das Flag `@reset` löscht den Zustand des Formulars beim Lesen. `CHANGE(path, false)` entfernt den Zustand berührt und geändert.\n\n## Lesen, was sich geändert hat\n\n`MODIFIED(path)` gibt die Paths der geänderten Felder zurück. Das Flag `@modified` von `GET()` gibt ein Objekt zurück, das nur diese Felder enthält:\n\n```js\nvar form = { name: 'Peter', city: 'Bratislava' };\n\nSET('form.city @change', 'Prague');\n\nMODIFIED('form.*');    // ['form.city']\nGET('form @modified'); // { city: 'Prague' }\n```\n\nDas Flag `@change` weist die Bibliothek an, einen Wert aus dem Code so zu behandeln, als hätte ihn der Benutzer eingegeben. Auch die anderen [Flags](../flags/) funktionieren mit Formularen.\n\n## Ein Formular zurücksetzen\n\n`RESET(path)` löscht den Zustand berührt und geändert und validiert die Felder erneut. Die Werte bleiben unverändert:\n\n```js\nRESET('form.*');\nMODIFIED('form.*'); // []\n```\n\n## Standardwerte\n\nDas Attribut `default` einer Komponente enthält einen JavaScript-Ausdruck. `DEFAULT(path)` schreibt die Standardwerte zurück in die Felder:\n\n```html\n<ui-component name=\"textbox\" path=\"filter.search\" default=\"'all'\"></ui-component>\n\n<script>\n    SET('filter.search @change', 'books');\n\n    DEFAULT('filter.*');\n    RESET('filter.*');\n\n    // filter.search is 'all' and the field has no state classes\n</script>\n```\n\nRufe `RESET()` nach `DEFAULT()` auf, damit die CSS-Klassen der Felder aktualisiert werden.\n\n## Formulare in einem Plugin\n\nEin [Plugin](../plugins/) ist ein natürlicher Ort für ein Formular. `exports.modified` gibt die geänderten Felder zurück und setzt den Zustand zurück, und `exports.form` gibt das gesamte Modell zurück und setzt den Zustand zurück:\n\n```html\n<script>\n    PLUGIN('profile', function(exports) {\n\n        exports.set({ name: 'Peter', city: 'Bratislava' });\n\n        exports.save = function() {\n            if (CAN('profile.*'))\n                console.log(exports.modified);\n        };\n    });\n</script>\n\n<ui-plugin path=\"profile\">\n    <ui-component name=\"textbox\" path=\"?.name\" config=\"required:true\"></ui-component>\n    <ui-component name=\"textbox\" path=\"?.city\"></ui-component>\n</ui-plugin>\n```\n\nNach `SET('profile.city @change', 'Prague')` gibt `PLUGINS.profile.save()` den Wert `{ city: 'Prague' }` aus.\n\n## Auf Zustandsänderungen reagieren\n\nDas Delegate `state` einer Komponente läuft immer dann, wenn sich ihr Zustand geändert haben könnte. Damit zeigst du eine Fehlermeldung an oder änderst das Aussehen des Felds:\n\n```js\nself.state = function(type, what) {\n    self.tclass('has-error', config.touched && config.invalid);\n};\n```\n\n`type` gibt an, wer die Änderung verursacht hat:\n\n| `type` | Ursache |\n| --- | --- |\n| `0` | Die Komponente wurde initialisiert. |\n| `1` | Code, zum Beispiel `SET()` oder `RESET()`. |\n| `2` | Der Benutzer, über ein Eingabefeld. |\n| `3` | `DEFAULT()`. |\n\n`what` gibt an, was passiert ist:\n\n| `what` | Änderung |\n| --- | --- |\n| `1` | Validierung. |\n| `2` | `CHANGE()`. |\n| `3` | Initialisierung, `RESET()` oder `DEFAULT()`. |\n| `4` | `UPD()`. |\n| `5` | Ein neuer Wert. |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTb1kM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/forms/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Formularios y validación","summary":"Valida valores en los componentes, controla qué ha cambiado el usuario y gestiona el estado de un formulario completo.","markdown":"---\ntitle: \"Formularios y validación\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/forms/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Formularios y validación\n\n> Valida valores en los componentes, controla qué ha cambiado el usuario y gestiona el estado de un formulario completo.\n\njComponent no tiene un objeto de formulario. Un formulario es un grupo de [componentes](../creating-components/) cuyos paths comparten un prefijo, como `form.name` y `form.city`. Cada componente conserva su propio estado, y las funciones globales leen el estado de todo el grupo mediante un path como `form.*`.\n\n## El estado de un campo\n\nCada componente con un path tiene estos valores en su objeto `config`:\n\n| Valor | Clase CSS | Significado |\n| --- | --- | --- |\n| `config.invalid` | `ui-invalid` | La función `validate` ha rechazado el valor. |\n| `config.touched` | `ui-touched` | El usuario ha cambiado el campo. |\n| `config.modified` | `ui-modified` | El valor lo ha cambiado el usuario o el flag `@change`. |\n| `config.disabled` | `ui-disabled` | El campo está desactivado. |\n\nLa biblioteca añade y quita las clases CSS en el elemento del componente.\n\n## Validar un valor\n\nDale al componente una función `validate`. Recibe el valor y devuelve `true` cuando el valor es válido. La biblioteca la llama cuando se inicia el componente y en cada cambio. Un `<input>` con el atributo `data-jc-bind` queda conectado al path del componente:\n\n```html\n<script>\n    COMPONENT('textbox', 'required:false', function(self, config) {\n\n        self.validate = function(value) {\n            return !config.required || !!value;\n        };\n\n        self.make = function() {\n            self.html('<input type=\"text\" data-jc-bind />');\n        };\n    });\n\n    var form = { name: '' };\n</script>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n```\n\nLas clases del elemento siguen lo que hace el usuario:\n\n| Momento | Clases |\n| --- | --- |\n| Se abre la página | `ui-invalid` |\n| El usuario escribe `Peter` | `ui-modified ui-touched` |\n| El usuario vacía el campo | `ui-modified ui-touched ui-invalid` |\n\nUn campo obligatorio vacío es inválido desde el principio. Para no mostrar errores en un formulario recién abierto, da estilo solo a los campos que el usuario ha tocado:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\n`DEF.validators` contiene expresiones regulares para `email`, `phone` y `url`:\n\n```js\nself.validate = function(value) {\n    return DEF.validators.email.test(value || '');\n};\n```\n\n## Comprobar un formulario\n\n| Función | Devuelve `true` cuando |\n| --- | --- |\n| `VALID(path)` | Ningún componente bajo el path es inválido. |\n| `CAN(path)` | Ningún componente es inválido **y** al menos uno se ha tocado. |\n| `DISABLED(path)` | `CAN(path)` es `false`. |\n\n`CAN()` también devuelve `true` cuando no hay ningún componente bajo el path.\n\nAñade el flag `visible` para comprobar solo los campos que el usuario puede ver:\n\n```js\nVALID('form.*');            // false, a hidden required field is empty\nVALID('form.*', 'visible'); // true\n```\n\n## Activar un botón de guardar\n\nObserva el formulario y actualiza el botón. Empieza con el botón desactivado, porque los componentes aún no están listos cuando se abre la página:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.city\"></ui-component>\n\n<button id=\"save\" disabled>Save</button>\n\n<script>\n    WATCH('form.*', function() {\n        $('#save').prop('disabled', DISABLED('form.*'));\n    });\n</script>\n```\n\n| Momento | `VALID` | `CAN` | Botón |\n| --- | --- | --- | --- |\n| Se abre la página | `false` | `false` | desactivado |\n| El usuario rellena solo la ciudad | `false` | `false` | desactivado |\n| El usuario rellena también el nombre | `true` | `true` | activado |\n\n## Mostrar errores al enviar\n\n`CHANGE(path)` marca todos los campos como tocados y modificados, de modo que los inválidos muestran sus errores. `ERRORS(path)` devuelve los componentes que están tocados y son inválidos:\n\n```js\nfunction save() {\n\n    CHANGE('form.*');\n\n    if (!VALID('form.*')) {\n        console.log(ERRORS('form.*').map(com => com.path));\n        return;\n    }\n\n    console.log(GET('form @reset'));\n}\n```\n\nCon dos campos obligatorios vacíos, esto imprime `['form.name', 'form.city']`. Cuando están rellenos, imprime el modelo. El flag `@reset` borra el estado del formulario mientras lo lee. `CHANGE(path, false)` quita el estado de tocado y modificado.\n\n## Leer lo que ha cambiado\n\n`MODIFIED(path)` devuelve los paths de los campos que han cambiado. El flag `@modified` de `GET()` devuelve un objeto solo con esos campos:\n\n```js\nvar form = { name: 'Peter', city: 'Bratislava' };\n\nSET('form.city @change', 'Prague');\n\nMODIFIED('form.*');    // ['form.city']\nGET('form @modified'); // { city: 'Prague' }\n```\n\nEl flag `@change` indica a la biblioteca que trate un valor asignado desde el código como si lo hubiera introducido el usuario. Los demás [flags](../flags/) también funcionan con formularios.\n\n## Restablecer un formulario\n\n`RESET(path)` borra el estado de tocado y modificado y vuelve a validar los campos. Los valores no cambian:\n\n```js\nRESET('form.*');\nMODIFIED('form.*'); // []\n```\n\n## Valores predeterminados\n\nEl atributo `default` de un componente contiene una expresión JavaScript. `DEFAULT(path)` vuelve a escribir los valores predeterminados en los campos:\n\n```html\n<ui-component name=\"textbox\" path=\"filter.search\" default=\"'all'\"></ui-component>\n\n<script>\n    SET('filter.search @change', 'books');\n\n    DEFAULT('filter.*');\n    RESET('filter.*');\n\n    // filter.search is 'all' and the field has no state classes\n</script>\n```\n\nLlama a `RESET()` después de `DEFAULT()` para que se actualicen las clases CSS de los campos.\n\n## Formularios en un plugin\n\nUn [plugin](../plugins/) es el lugar natural para un formulario. `exports.modified` devuelve los campos cambiados y restablece el estado, y `exports.form` devuelve el modelo completo y restablece el estado:\n\n```html\n<script>\n    PLUGIN('profile', function(exports) {\n\n        exports.set({ name: 'Peter', city: 'Bratislava' });\n\n        exports.save = function() {\n            if (CAN('profile.*'))\n                console.log(exports.modified);\n        };\n    });\n</script>\n\n<ui-plugin path=\"profile\">\n    <ui-component name=\"textbox\" path=\"?.name\" config=\"required:true\"></ui-component>\n    <ui-component name=\"textbox\" path=\"?.city\"></ui-component>\n</ui-plugin>\n```\n\nDespués de `SET('profile.city @change', 'Prague')`, `PLUGINS.profile.save()` imprime `{ city: 'Prague' }`.\n\n## Reaccionar a los cambios de estado\n\nEl delegate `state` de un componente se ejecuta siempre que su estado puede haber cambiado. Úsalo para mostrar un mensaje de error o cambiar el aspecto del campo:\n\n```js\nself.state = function(type, what) {\n    self.tclass('has-error', config.touched && config.invalid);\n};\n```\n\n`type` indica quién ha provocado el cambio:\n\n| `type` | Causa |\n| --- | --- |\n| `0` | El componente se ha inicializado. |\n| `1` | El código, por ejemplo `SET()` o `RESET()`. |\n| `2` | El usuario, a través de un campo. |\n| `3` | `DEFAULT()`. |\n\n`what` indica qué ha ocurrido:\n\n| `what` | Cambio |\n| --- | --- |\n| `1` | Validación. |\n| `2` | `CHANGE()`. |\n| `3` | Inicialización, `RESET()` o `DEFAULT()`. |\n| `4` | `UPD()`. |\n| `5` | Un valor nuevo. |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTb1kM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/forms/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Formulaires et validation","summary":"Valide les valeurs dans les composants, suis ce que l'utilisateur a modifié et contrôle l'état d'un formulaire entier.","markdown":"---\ntitle: Formulaires et validation\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/forms/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Formulaires et validation\n\n> Valide les valeurs dans les composants, suis ce que l'utilisateur a modifié et contrôle l'état d'un formulaire entier.\n\njComponent n'a pas d'objet formulaire. Un formulaire est un groupe de [composants](../creating-components/) dont les paths partagent un préfixe, comme `form.name` et `form.city`. Chaque composant conserve son propre état, et des fonctions globales lisent l'état de tout le groupe à travers un path comme `form.*`.\n\n## L'état d'un champ\n\nChaque composant doté d'un path possède ces valeurs dans son objet `config` :\n\n| Valeur | Classe CSS | Signification |\n| --- | --- | --- |\n| `config.invalid` | `ui-invalid` | La fonction `validate` a rejeté la valeur. |\n| `config.touched` | `ui-touched` | L'utilisateur a modifié le champ. |\n| `config.modified` | `ui-modified` | La valeur a été modifiée par l'utilisateur ou avec le flag `@change`. |\n| `config.disabled` | `ui-disabled` | Le champ est désactivé. |\n\nLa bibliothèque ajoute et retire les classes CSS sur l'élément du composant.\n\n## Valider une valeur\n\nDonne au composant une fonction `validate`. Elle reçoit la valeur et renvoie `true` quand la valeur est valide. La bibliothèque l'appelle au démarrage du composant et à chaque changement. Un `<input>` portant l'attribut `data-jc-bind` est relié au path du composant :\n\n```html\n<script>\n    COMPONENT('textbox', 'required:false', function(self, config) {\n\n        self.validate = function(value) {\n            return !config.required || !!value;\n        };\n\n        self.make = function() {\n            self.html('<input type=\"text\" data-jc-bind />');\n        };\n    });\n\n    var form = { name: '' };\n</script>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n```\n\nLes classes de l'élément suivent les actions de l'utilisateur :\n\n| Moment | Classes |\n| --- | --- |\n| La page s'ouvre | `ui-invalid` |\n| L'utilisateur saisit `Peter` | `ui-modified ui-touched` |\n| L'utilisateur vide le champ | `ui-modified ui-touched ui-invalid` |\n\nUn champ obligatoire vide est invalide dès le départ. Pour éviter d'afficher des erreurs sur un formulaire tout neuf, ne stylise que les champs que l'utilisateur a touchés :\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\n`DEF.validators` contient des expressions régulières pour `email`, `phone` et `url` :\n\n```js\nself.validate = function(value) {\n    return DEF.validators.email.test(value || '');\n};\n```\n\n## Vérifier un formulaire\n\n| Fonction | Renvoie `true` quand |\n| --- | --- |\n| `VALID(path)` | Aucun composant situé sous le path n'est invalide. |\n| `CAN(path)` | Aucun composant n'est invalide **et** au moins un a été touché. |\n| `DISABLED(path)` | `CAN(path)` vaut `false`. |\n\n`CAN()` renvoie aussi `true` quand aucun composant ne se trouve sous le path.\n\nAjoute le flag `visible` pour ne vérifier que les champs visibles par l'utilisateur :\n\n```js\nVALID('form.*');            // false, a hidden required field is empty\nVALID('form.*', 'visible'); // true\n```\n\n## Activer un bouton d'enregistrement\n\nObserve le formulaire et mets à jour le bouton. Commence avec un bouton désactivé, car les composants ne sont pas encore prêts à l'ouverture de la page :\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.city\"></ui-component>\n\n<button id=\"save\" disabled>Save</button>\n\n<script>\n    WATCH('form.*', function() {\n        $('#save').prop('disabled', DISABLED('form.*'));\n    });\n</script>\n```\n\n| Moment | `VALID` | `CAN` | Bouton |\n| --- | --- | --- | --- |\n| La page s'ouvre | `false` | `false` | désactivé |\n| L'utilisateur remplit seulement la ville | `false` | `false` | désactivé |\n| L'utilisateur remplit aussi le nom | `true` | `true` | activé |\n\n## Afficher les erreurs à l'envoi\n\n`CHANGE(path)` marque chaque champ comme touché et modifié : les champs invalides affichent donc leurs erreurs. `ERRORS(path)` renvoie les composants touchés et invalides :\n\n```js\nfunction save() {\n\n    CHANGE('form.*');\n\n    if (!VALID('form.*')) {\n        console.log(ERRORS('form.*').map(com => com.path));\n        return;\n    }\n\n    console.log(GET('form @reset'));\n}\n```\n\nAvec deux champs obligatoires vides, ce code affiche `['form.name', 'form.city']`. Une fois les champs remplis, il affiche le modèle de données. Le flag `@reset` efface l'état du formulaire pendant sa lecture. `CHANGE(path, false)` retire l'état touché et modifié.\n\n## Lire ce qui a changé\n\n`MODIFIED(path)` renvoie les paths des champs modifiés. Le flag `@modified` de `GET()` renvoie un objet contenant uniquement ces champs :\n\n```js\nvar form = { name: 'Peter', city: 'Bratislava' };\n\nSET('form.city @change', 'Prague');\n\nMODIFIED('form.*');    // ['form.city']\nGET('form @modified'); // { city: 'Prague' }\n```\n\nLe flag `@change` indique à la bibliothèque de traiter une valeur venant du code comme si l'utilisateur l'avait saisie. Les autres [flags](../flags/) fonctionnent aussi avec les formulaires.\n\n## Réinitialiser un formulaire\n\n`RESET(path)` efface l'état touché et modifié, puis valide de nouveau les champs. Les valeurs restent inchangées :\n\n```js\nRESET('form.*');\nMODIFIED('form.*'); // []\n```\n\n## Valeurs par défaut\n\nL'attribut `default` d'un composant contient une expression JavaScript. `DEFAULT(path)` réécrit les valeurs par défaut dans les champs :\n\n```html\n<ui-component name=\"textbox\" path=\"filter.search\" default=\"'all'\"></ui-component>\n\n<script>\n    SET('filter.search @change', 'books');\n\n    DEFAULT('filter.*');\n    RESET('filter.*');\n\n    // filter.search is 'all' and the field has no state classes\n</script>\n```\n\nAppelle `RESET()` après `DEFAULT()` pour que les classes CSS des champs soient mises à jour.\n\n## Formulaires dans un plugin\n\nUn [plugin](../plugins/) est l'endroit naturel pour un formulaire. `exports.modified` renvoie les champs modifiés et réinitialise l'état, et `exports.form` renvoie le modèle de données entier et réinitialise l'état :\n\n```html\n<script>\n    PLUGIN('profile', function(exports) {\n\n        exports.set({ name: 'Peter', city: 'Bratislava' });\n\n        exports.save = function() {\n            if (CAN('profile.*'))\n                console.log(exports.modified);\n        };\n    });\n</script>\n\n<ui-plugin path=\"profile\">\n    <ui-component name=\"textbox\" path=\"?.name\" config=\"required:true\"></ui-component>\n    <ui-component name=\"textbox\" path=\"?.city\"></ui-component>\n</ui-plugin>\n```\n\nAprès `SET('profile.city @change', 'Prague')`, `PLUGINS.profile.save()` affiche `{ city: 'Prague' }`.\n\n## Réagir aux changements d'état\n\nLe delegate `state` d'un composant s'exécute chaque fois que son état a pu changer. Utilise-le pour afficher un message d'erreur ou modifier l'apparence du champ :\n\n```js\nself.state = function(type, what) {\n    self.tclass('has-error', config.touched && config.invalid);\n};\n```\n\n`type` indique qui a provoqué le changement :\n\n| `type` | Cause |\n| --- | --- |\n| `0` | Le composant a été initialisé. |\n| `1` | Le code, par exemple `SET()` ou `RESET()`. |\n| `2` | L'utilisateur, via un champ de saisie. |\n| `3` | `DEFAULT()`. |\n\n`what` indique ce qui s'est passé :\n\n| `what` | Changement |\n| --- | --- |\n| `1` | Validation. |\n| `2` | `CHANGE()`. |\n| `3` | Initialisation, `RESET()` ou `DEFAULT()`. |\n| `4` | `UPD()`. |\n| `5` | Une nouvelle valeur. |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTb1kM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/forms/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Moduli e validazione","summary":"Valida i valori nei componenti, tieni traccia di ciò che l'utente ha modificato e controlla lo stato di un intero modulo.","markdown":"---\ntitle: Moduli e validazione\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/forms/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Moduli e validazione\n\n> Valida i valori nei componenti, tieni traccia di ciò che l'utente ha modificato e controlla lo stato di un intero modulo.\n\njComponent non ha un oggetto modulo. Un modulo è un gruppo di [componenti](../creating-components/) i cui path condividono un prefisso, come `form.name` e `form.city`. Ogni componente mantiene il proprio stato e le funzioni globali leggono lo stato dell'intero gruppo tramite un path come `form.*`.\n\n## Lo stato di un campo\n\nOgni componente con un path ha questi valori nel suo oggetto `config`:\n\n| Valore | Classe CSS | Significato |\n| --- | --- | --- |\n| `config.invalid` | `ui-invalid` | La funzione `validate` ha rifiutato il valore. |\n| `config.touched` | `ui-touched` | L'utente ha modificato il campo. |\n| `config.modified` | `ui-modified` | Il valore è stato modificato dall'utente o con il flag `@change`. |\n| `config.disabled` | `ui-disabled` | Il campo è disabilitato. |\n\nLa libreria aggiunge e rimuove le classi CSS sull'elemento del componente.\n\n## Validare un valore\n\nAssegna al componente una funzione `validate`. Riceve il valore e restituisce `true` quando il valore è valido. La libreria la chiama all'avvio del componente e a ogni modifica. Un `<input>` con l'attributo `data-jc-bind` è collegato al path del componente:\n\n```html\n<script>\n    COMPONENT('textbox', 'required:false', function(self, config) {\n\n        self.validate = function(value) {\n            return !config.required || !!value;\n        };\n\n        self.make = function() {\n            self.html('<input type=\"text\" data-jc-bind />');\n        };\n    });\n\n    var form = { name: '' };\n</script>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n```\n\nLe classi dell'elemento seguono le azioni dell'utente:\n\n| Momento | Classi |\n| --- | --- |\n| La pagina si apre | `ui-invalid` |\n| L'utente digita `Peter` | `ui-modified ui-touched` |\n| L'utente svuota il campo | `ui-modified ui-touched ui-invalid` |\n\nUn campo obbligatorio vuoto è non valido fin dall'inizio. Per evitare di mostrare errori su un modulo appena aperto, applica lo stile solo ai campi che l'utente ha toccato:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\n`DEF.validators` contiene espressioni regolari per `email`, `phone` e `url`:\n\n```js\nself.validate = function(value) {\n    return DEF.validators.email.test(value || '');\n};\n```\n\n## Controllare un modulo\n\n| Funzione | Restituisce `true` quando |\n| --- | --- |\n| `VALID(path)` | Nessun componente sotto il path è non valido. |\n| `CAN(path)` | Nessun componente è non valido **e** almeno uno è stato toccato. |\n| `DISABLED(path)` | `CAN(path)` è `false`. |\n\n`CAN()` restituisce `true` anche quando sotto il path non c'è alcun componente.\n\nAggiungi il flag `visible` per controllare solo i campi che l'utente può vedere:\n\n```js\nVALID('form.*');            // false, a hidden required field is empty\nVALID('form.*', 'visible'); // true\n```\n\n## Abilitare un pulsante di salvataggio\n\nOsserva il modulo e aggiorna il pulsante. Parti con un pulsante disabilitato, perché i componenti non sono ancora pronti quando la pagina si apre:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.city\"></ui-component>\n\n<button id=\"save\" disabled>Save</button>\n\n<script>\n    WATCH('form.*', function() {\n        $('#save').prop('disabled', DISABLED('form.*'));\n    });\n</script>\n```\n\n| Momento | `VALID` | `CAN` | Pulsante |\n| --- | --- | --- | --- |\n| La pagina si apre | `false` | `false` | disabilitato |\n| L'utente compila solo la città | `false` | `false` | disabilitato |\n| L'utente compila anche il nome | `true` | `true` | abilitato |\n\n## Mostrare gli errori all'invio\n\n`CHANGE(path)` contrassegna ogni campo come toccato e modificato, così quelli non validi mostrano i propri errori. `ERRORS(path)` restituisce i componenti toccati e non validi:\n\n```js\nfunction save() {\n\n    CHANGE('form.*');\n\n    if (!VALID('form.*')) {\n        console.log(ERRORS('form.*').map(com => com.path));\n        return;\n    }\n\n    console.log(GET('form @reset'));\n}\n```\n\nCon due campi obbligatori vuoti, stampa `['form.name', 'form.city']`. Una volta compilati, stampa il modello. Il flag `@reset` azzera lo stato del modulo durante la lettura. `CHANGE(path, false)` rimuove lo stato di campo toccato e modificato.\n\n## Leggere ciò che è cambiato\n\n`MODIFIED(path)` restituisce i path dei campi modificati. Il flag `@modified` di `GET()` restituisce un oggetto con solo quei campi:\n\n```js\nvar form = { name: 'Peter', city: 'Bratislava' };\n\nSET('form.city @change', 'Prague');\n\nMODIFIED('form.*');    // ['form.city']\nGET('form @modified'); // { city: 'Prague' }\n```\n\nIl flag `@change` indica alla libreria di trattare un valore proveniente dal codice come se lo avesse inserito l'utente. Anche gli altri [flag](../flags/) funzionano con i moduli.\n\n## Reimpostare un modulo\n\n`RESET(path)` azzera lo stato di campo toccato e modificato e valida di nuovo i campi. I valori restano invariati:\n\n```js\nRESET('form.*');\nMODIFIED('form.*'); // []\n```\n\n## Valori predefiniti\n\nL'attributo `default` di un componente contiene un'espressione JavaScript. `DEFAULT(path)` riscrive i valori predefiniti nei campi:\n\n```html\n<ui-component name=\"textbox\" path=\"filter.search\" default=\"'all'\"></ui-component>\n\n<script>\n    SET('filter.search @change', 'books');\n\n    DEFAULT('filter.*');\n    RESET('filter.*');\n\n    // filter.search is 'all' and the field has no state classes\n</script>\n```\n\nChiama `RESET()` dopo `DEFAULT()` affinché le classi CSS dei campi vengano aggiornate.\n\n## Moduli in un plugin\n\nUn [plugin](../plugins/) è il posto naturale per un modulo. `exports.modified` restituisce i campi modificati e reimposta lo stato, mentre `exports.form` restituisce l'intero modello e reimposta lo stato:\n\n```html\n<script>\n    PLUGIN('profile', function(exports) {\n\n        exports.set({ name: 'Peter', city: 'Bratislava' });\n\n        exports.save = function() {\n            if (CAN('profile.*'))\n                console.log(exports.modified);\n        };\n    });\n</script>\n\n<ui-plugin path=\"profile\">\n    <ui-component name=\"textbox\" path=\"?.name\" config=\"required:true\"></ui-component>\n    <ui-component name=\"textbox\" path=\"?.city\"></ui-component>\n</ui-plugin>\n```\n\nDopo `SET('profile.city @change', 'Prague')`, `PLUGINS.profile.save()` stampa `{ city: 'Prague' }`.\n\n## Reagire ai cambiamenti di stato\n\nIl delegate `state` di un componente viene eseguito ogni volta che il suo stato può essere cambiato. Usalo per mostrare un messaggio di errore o per cambiare l'aspetto del campo:\n\n```js\nself.state = function(type, what) {\n    self.tclass('has-error', config.touched && config.invalid);\n};\n```\n\n`type` indica chi ha causato la modifica:\n\n| `type` | Causa |\n| --- | --- |\n| `0` | Il componente è stato inizializzato. |\n| `1` | Il codice, ad esempio `SET()` o `RESET()`. |\n| `2` | L'utente, tramite un campo di input. |\n| `3` | `DEFAULT()`. |\n\n`what` indica che cosa è successo:\n\n| `what` | Modifica |\n| --- | --- |\n| `1` | Validazione. |\n| `2` | `CHANGE()`. |\n| `3` | Inizializzazione, `RESET()` o `DEFAULT()`. |\n| `4` | `UPD()`. |\n| `5` | Un nuovo valore. |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTb1kM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/forms/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Formuláre a validácia","summary":"Validuj hodnoty v komponentoch, sleduj, čo používateľ zmenil, a ovládaj stav celého formulára.","markdown":"---\ntitle: \"Formuláre a validácia\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/forms/\nupdated: 2026-11-18T13:55:49.124Z\n---\n\n# Formuláre a validácia\n\n> Validuj hodnoty v komponentoch, sleduj, čo používateľ zmenil, a ovládaj stav celého formulára.\n\njComponent nemá objekt formulára. Formulár je skupina [komponentov](../creating-components/), ktorých paths majú spoločnú predponu, napríklad `form.name` a `form.city`. Každý komponent si udržiava vlastný stav a globálne funkcie čítajú stav celej skupiny cez path v tvare `form.*`.\n\n## Stav poľa\n\nKaždý komponent s path má v objekte `config` tieto hodnoty:\n\n| Hodnota | CSS trieda | Význam |\n| --- | --- | --- |\n| `config.invalid` | `ui-invalid` | Funkcia `validate` hodnotu odmietla. |\n| `config.touched` | `ui-touched` | Používateľ pole zmenil. |\n| `config.modified` | `ui-modified` | Hodnotu zmenil používateľ alebo flag `@change`. |\n| `config.disabled` | `ui-disabled` | Pole je zakázané. |\n\nKnižnica pridáva a odstraňuje CSS triedy na elemente komponentu.\n\n## Validácia hodnoty\n\nDaj komponentu funkciu `validate`. Dostane hodnotu a vráti `true`, keď je hodnota platná. Knižnica ju volá pri štarte komponentu a pri každej zmene. Element `<input>` s atribútom `data-jc-bind` je pripojený k path komponentu:\n\n```html\n<script>\n    COMPONENT('textbox', 'required:false', function(self, config) {\n\n        self.validate = function(value) {\n            return !config.required || !!value;\n        };\n\n        self.make = function() {\n            self.html('<input type=\"text\" data-jc-bind />');\n        };\n    });\n\n    var form = { name: '' };\n</script>\n\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n```\n\nTriedy elementu sa menia podľa konania používateľa:\n\n| Moment | Triedy |\n| --- | --- |\n| Stránka sa otvorí | `ui-invalid` |\n| Používateľ napíše `Peter` | `ui-modified ui-touched` |\n| Používateľ pole vymaže | `ui-modified ui-touched ui-invalid` |\n\nPrázdne povinné pole je neplatné od začiatku. Aby sa na novom formulári nezobrazovali chyby, štýluj iba polia, ktorých sa používateľ dotkol:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\n`DEF.validators` obsahuje regulárne výrazy pre `email`, `phone` a `url`:\n\n```js\nself.validate = function(value) {\n    return DEF.validators.email.test(value || '');\n};\n```\n\n## Kontrola formulára\n\n| Funkcia | Vráti `true`, keď |\n| --- | --- |\n| `VALID(path)` | Žiadny komponent pod daným path nie je neplatný. |\n| `CAN(path)` | Žiadny komponent nie je neplatný **a** aspoň jedného sa používateľ dotkol. |\n| `DISABLED(path)` | `CAN(path)` je `false`. |\n\n`CAN()` vráti `true` aj vtedy, keď pod daným path nie je žiadny komponent.\n\nPridaj flag `visible`, ak chceš kontrolovať iba polia, ktoré používateľ vidí:\n\n```js\nVALID('form.*');            // false, a hidden required field is empty\nVALID('form.*', 'visible'); // true\n```\n\n## Povolenie tlačidla na uloženie\n\nSleduj formulár a aktualizuj tlačidlo. Začni so zakázaným tlačidlom, pretože pri otvorení stránky komponenty ešte nie sú pripravené:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.city\"></ui-component>\n\n<button id=\"save\" disabled>Save</button>\n\n<script>\n    WATCH('form.*', function() {\n        $('#save').prop('disabled', DISABLED('form.*'));\n    });\n</script>\n```\n\n| Moment | `VALID` | `CAN` | Tlačidlo |\n| --- | --- | --- | --- |\n| Stránka sa otvorí | `false` | `false` | zakázané |\n| Používateľ vyplní iba mesto | `false` | `false` | zakázané |\n| Používateľ vyplní aj meno | `true` | `true` | povolené |\n\n## Zobrazenie chýb pri odoslaní\n\n`CHANGE(path)` označí každé pole ako dotknuté a zmenené, takže neplatné polia zobrazia svoje chyby. `ERRORS(path)` vráti komponenty, ktoré sú dotknuté a neplatné:\n\n```js\nfunction save() {\n\n    CHANGE('form.*');\n\n    if (!VALID('form.*')) {\n        console.log(ERRORS('form.*').map(com => com.path));\n        return;\n    }\n\n    console.log(GET('form @reset'));\n}\n```\n\nPri dvoch prázdnych povinných poliach sa vypíše `['form.name', 'form.city']`. Po ich vyplnení sa vypíše model. Flag `@reset` pri čítaní vymaže stav formulára. `CHANGE(path, false)` odstráni stav dotknutia a zmeny.\n\n## Čítanie zmien\n\n`MODIFIED(path)` vráti paths polí, ktoré sa zmenili. Flag `@modified` funkcie `GET()` vráti objekt iba s týmito poľami:\n\n```js\nvar form = { name: 'Peter', city: 'Bratislava' };\n\nSET('form.city @change', 'Prague');\n\nMODIFIED('form.*');    // ['form.city']\nGET('form @modified'); // { city: 'Prague' }\n```\n\nFlag `@change` povie knižnici, aby s hodnotou z kódu zaobchádzala tak, akoby ju zadal používateľ. S formulármi fungujú aj ostatné [flagy](../flags/).\n\n## Vynulovanie formulára\n\n`RESET(path)` vymaže stav dotknutia a zmeny a znova validuje polia. Hodnoty zostávajú nezmenené:\n\n```js\nRESET('form.*');\nMODIFIED('form.*'); // []\n```\n\n## Predvolené hodnoty\n\nAtribút `default` komponentu obsahuje výraz JavaScriptu. `DEFAULT(path)` zapíše predvolené hodnoty späť do polí:\n\n```html\n<ui-component name=\"textbox\" path=\"filter.search\" default=\"'all'\"></ui-component>\n\n<script>\n    SET('filter.search @change', 'books');\n\n    DEFAULT('filter.*');\n    RESET('filter.*');\n\n    // filter.search is 'all' and the field has no state classes\n</script>\n```\n\nPo `DEFAULT()` zavolaj `RESET()`, aby sa aktualizovali CSS triedy polí.\n\n## Formuláre v plugine\n\n[Plugin](../plugins/) je pre formulár prirodzeným miestom. `exports.modified` vráti zmenené polia a vynuluje stav a `exports.form` vráti celý model a vynuluje stav:\n\n```html\n<script>\n    PLUGIN('profile', function(exports) {\n\n        exports.set({ name: 'Peter', city: 'Bratislava' });\n\n        exports.save = function() {\n            if (CAN('profile.*'))\n                console.log(exports.modified);\n        };\n    });\n</script>\n\n<ui-plugin path=\"profile\">\n    <ui-component name=\"textbox\" path=\"?.name\" config=\"required:true\"></ui-component>\n    <ui-component name=\"textbox\" path=\"?.city\"></ui-component>\n</ui-plugin>\n```\n\nPo `SET('profile.city @change', 'Prague')` vypíše `PLUGINS.profile.save()` hodnotu `{ city: 'Prague' }`.\n\n## Reakcia na zmeny stavu\n\nDelegate `state` komponentu sa spúšťa vždy, keď sa jeho stav mohol zmeniť. Použi ho na zobrazenie chybovej správy alebo na zmenu vzhľadu poľa:\n\n```js\nself.state = function(type, what) {\n    self.tclass('has-error', config.touched && config.invalid);\n};\n```\n\n`type` hovorí, kto zmenu spôsobil:\n\n| `type` | Príčina |\n| --- | --- |\n| `0` | Komponent bol inicializovaný. |\n| `1` | Kód, napríklad `SET()` alebo `RESET()`. |\n| `2` | Používateľ prostredníctvom vstupu. |\n| `3` | `DEFAULT()`. |\n\n`what` hovorí, čo sa stalo:\n\n| `what` | Zmena |\n| --- | --- |\n| `1` | Validácia. |\n| `2` | `CHANGE()`. |\n| `3` | Inicializácia, `RESET()` alebo `DEFAULT()`. |\n| `4` | `UPD()`. |\n| `5` | Nová hodnota. |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:49.124Z"}
{"id":"JammTo1sM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/guides/localization/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"en","title":"Localization","summary":"Translate texts and adapt dates, numbers, currencies and plurals to the language of the user.","markdown":"---\ntitle: Localization\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/guides/localization/\nupdated: 2026-11-18T13:55:54.124Z\n---\n\n# Localization\n\n> Translate texts and adapt dates, numbers, currencies and plurals to the language of the user.\n\nLocalization has two parts: translating the texts of the interface with a dictionary, and formatting dates, numbers and currencies the way the user expects.\n\n## Marking text for translation\n\nWrite a translatable text as `@(text)`. `TRANSLATE(text)` replaces every marked text with its translation from `DEF.dictionary`. A text without a translation stays in the original language:\n\n```js\nDEF.dictionary[HASH('Save').toString(36)] = 'Guardar';\nDEF.dictionary[HASH('Cancel').toString(36)] = 'Cancelar';\n\nTRANSLATE('@(Save) | @(Cancel) | @(Delete)');\n// Guardar | Cancelar | Delete\n```\n\nThe marked text can contain parentheses, as in `@(Save (draft))`.\n\n## Dictionary keys\n\nThe key of a translation is the hash of the original text in base 36:\n\n```js\nHASH('Save').toString(36); // '1j2ql'\n```\n\nThe same key with the prefix `T` works as well. The library looks for the key without the prefix first.\n\n## Loading translations\n\n`LOCALIZE(text)` adds translations from a text with one `key : translation` per line. Empty lines, lines without a colon and lines that start with `//` are skipped. Only the first colon separates the key, so a translation can contain colons:\n\n```js\nvar key1 = HASH('Save').toString(36);\nvar key2 = HASH('Opening hours').toString(36);\n\nLOCALIZE([\n    '// Spanish',\n    key1 + ' : Guardar',\n    key2 + ' : Abierto: 9:00 - 17:00'\n].join('\\n'));\n\nTRANSLATE('@(Opening hours)'); // Abierto: 9:00 - 17:00\n```\n\nLoad the dictionary ahead of the components, because the texts are translated when the components start.\n\n## Where texts are translated\n\nThe library translates marked texts in:\n\n- the `config` attribute of `<ui-component>` and `<ui-bind>`,\n- templates of `<ui-bind>`,\n- content loaded with [IMPORT() and ui-import](../importing/),\n- text passed to `ADAPT()`.\n\nStatic HTML of the page is not translated:\n\n```html\n<script>\n    LOCALIZE(HASH('Your name').toString(36) + ': Tu nombre');\n\n    COMPONENT('label', function(self, config) {\n        self.make = function() {\n            self.text(config.title);\n        };\n    });\n\n    var user = { name: 'Peter' };\n</script>\n\n<!-- Tu nombre -->\n<ui-component name=\"label\" config=\"title:@(Your name)\"></ui-component>\n\n<!-- Tu nombre: Peter -->\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\"><b>@(Your name)</b>: {{ value.name }}</script>\n</ui-bind>\n\n<!-- @(Your name) -->\n<p>@(Your name)</p>\n```\n\n## Dates and numbers\n\nThese settings of [DEF](../../reference/def/) control the default formats:\n\n| Setting | Default | Description |\n| --- | --- | --- |\n| `DEF.dateformat` | `yyyy-MM-dd` | The format of `date.format()` without an argument. |\n| `DEF.thousandsseparator` | a space | The separator of thousands. |\n| `DEF.decimalseparator` | `.` | The decimal separator. |\n\nThe names of months and days are in the global arrays `MONTHS` and `DAYS`. `DAYS` starts with Sunday:\n\n```js\nMONTHS = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'.split(',');\nDAYS = 'domingo,lunes,martes,miércoles,jueves,viernes,sábado'.split(',');\n\nDEF.dateformat = 'dd.MM.yyyy';\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\nvar date = new Date(2024, 2, 5, 14, 7);\n\ndate.format();                     // 05.03.2024\ndate.format('dddd, d. MMMM yyyy'); // martes, 5. marzo 2024\n(1234567.891).format(2);           // 1.234.567,89\n```\n\n[Tangular](../tangular/) helpers use the same settings:\n\n```js\nTangular.render('{{ date | format }} {{ price | format(2) }}', { date: date, price: 1500 });\n// 05.03.2024 1.500,00\n```\n\nThe tokens of a date format are listed in the [Date reference](../../reference/date/).\n\n## Currencies\n\n`DEF.currencies` holds one formatting function per currency, and `DEF.currency` is the default one. `number.currency([name])` uses them. An unknown currency formats the number with two decimals:\n\n```js\nDEF.currencies.eur = function(value) {\n    return value.format(2) + ' EUR';\n};\n\nDEF.currencies.usd = function(value) {\n    return '$' + value.format(2);\n};\n\nDEF.currency = 'eur';\n\n(1250).currency();      // 1 250.00 EUR\n(1250).currency('usd'); // $1 250.00\n(1250).currency('gbp'); // 1 250.00\n```\n\nThe `currency` helper in Tangular does the same:\n\n```js\nTangular.render(\"{{ price | currency }} {{ price | currency('usd') }}\", { price: 10 });\n// 10.00 EUR $10.00\n```\n\n## Plurals\n\n`number.pluralize(zero, one, few, other)` chooses a text by the number. `few` covers the numbers from 2 to 4. `#` writes the number and `##` writes it formatted:\n\n```js\n(0).pluralize('no files', '# file', '# files', '# files'); // no files\n(1).pluralize('no files', '# file', '# files', '# files'); // 1 file\n(3).pluralize('no files', '# file', '# files', '# files'); // 3 files\n\n(1500).pluralize('none', 'one', 'few', '## files');        // 1 500 files\n```\n\n## Keeping formats in one place\n\n`ENV(name, value)` stores a value, and formatting methods read it when you write its name in square brackets. A translation of the application can then change the formats in one place:\n\n```js\nENV('files', 'no files,# file,# files,# files');\n(2).pluralize('[files]'); // 2 files\n\nENV('short', 'dd/MM');\nnew Date(2024, 2, 5).format('[short]'); // 05/03\n```\n\n## Telling the server the language\n\n`DEF.language` adds a language parameter to every request made with `AJAX()`. `DEF.languagehtml` adds it only to addresses that contain `.html`, which is useful when the server translates templates. `DEF.languagekey` is the name of the parameter:\n\n```js\nDEF.language = 'sk';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?language=sk\n\nDEF.language = '';\nDEF.languagehtml = 'de';\nAJAX('GET /templates/form.html', callback);\n// GET /templates/form.html?language=de\n\nDEF.languagehtml = '';\nDEF.language = 'en';\nDEF.languagekey = 'lang';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?lang=en\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:54.124Z"}
{"id":"JammTo1sM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/localization/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"de","title":"Lokalisierung","summary":"Übersetze Texte und passe Datumsangaben, Zahlen, Währungen und Pluralformen an die Sprache des Benutzers an.","markdown":"---\ntitle: Lokalisierung\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/guides/localization/\nupdated: 2026-11-18T13:55:54.124Z\n---\n\n# Lokalisierung\n\n> Übersetze Texte und passe Datumsangaben, Zahlen, Währungen und Pluralformen an die Sprache des Benutzers an.\n\nLokalisierung besteht aus zwei Teilen: die Texte der Oberfläche mit einem Wörterbuch übersetzen und Datumsangaben, Zahlen und Währungen so formatieren, wie der Benutzer es erwartet.\n\n## Text zum Übersetzen markieren\n\nSchreibe einen übersetzbaren Text als `@(text)`. `TRANSLATE(text)` ersetzt jeden markierten Text durch seine Übersetzung aus `DEF.dictionary`. Ein Text ohne Übersetzung bleibt in der Originalsprache:\n\n```js\nDEF.dictionary[HASH('Save').toString(36)] = 'Guardar';\nDEF.dictionary[HASH('Cancel').toString(36)] = 'Cancelar';\n\nTRANSLATE('@(Save) | @(Cancel) | @(Delete)');\n// Guardar | Cancelar | Delete\n```\n\nDer markierte Text darf Klammern enthalten, wie in `@(Save (draft))`.\n\n## Wörterbuchschlüssel\n\nDer Schlüssel einer Übersetzung ist der Hash des Originaltexts zur Basis 36:\n\n```js\nHASH('Save').toString(36); // '1j2ql'\n```\n\nDerselbe Schlüssel mit dem Präfix `T` funktioniert ebenfalls. Die Bibliothek sucht zuerst nach dem Schlüssel ohne Präfix.\n\n## Übersetzungen laden\n\n`LOCALIZE(text)` fügt Übersetzungen aus einem Text mit einem `key : translation` pro Zeile hinzu. Leere Zeilen, Zeilen ohne Doppelpunkt und Zeilen, die mit `//` beginnen, werden übersprungen. Nur der erste Doppelpunkt trennt den Schlüssel ab, eine Übersetzung darf also Doppelpunkte enthalten:\n\n```js\nvar key1 = HASH('Save').toString(36);\nvar key2 = HASH('Opening hours').toString(36);\n\nLOCALIZE([\n    '// Spanish',\n    key1 + ' : Guardar',\n    key2 + ' : Abierto: 9:00 - 17:00'\n].join('\\n'));\n\nTRANSLATE('@(Opening hours)'); // Abierto: 9:00 - 17:00\n```\n\nLade das Wörterbuch vor den Komponenten, denn die Texte werden beim Start der Komponenten übersetzt.\n\n## Wo Texte übersetzt werden\n\nDie Bibliothek übersetzt markierte Texte in:\n\n- dem Attribut `config` von `<ui-component>` und `<ui-bind>`,\n- Templates von `<ui-bind>`,\n- Inhalten, die mit [IMPORT() und ui-import](../importing/) geladen werden,\n- Text, der an `ADAPT()` übergeben wird.\n\nStatisches HTML der Seite wird nicht übersetzt:\n\n```html\n<script>\n    LOCALIZE(HASH('Your name').toString(36) + ': Tu nombre');\n\n    COMPONENT('label', function(self, config) {\n        self.make = function() {\n            self.text(config.title);\n        };\n    });\n\n    var user = { name: 'Peter' };\n</script>\n\n<!-- Tu nombre -->\n<ui-component name=\"label\" config=\"title:@(Your name)\"></ui-component>\n\n<!-- Tu nombre: Peter -->\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\"><b>@(Your name)</b>: {{ value.name }}</script>\n</ui-bind>\n\n<!-- @(Your name) -->\n<p>@(Your name)</p>\n```\n\n## Datumsangaben und Zahlen\n\nDiese Einstellungen von [DEF](../../reference/def/) steuern die Standardformate:\n\n| Einstellung | Standardwert | Beschreibung |\n| --- | --- | --- |\n| `DEF.dateformat` | `yyyy-MM-dd` | Das Format von `date.format()` ohne Argument. |\n| `DEF.thousandsseparator` | ein Leerzeichen | Das Tausendertrennzeichen. |\n| `DEF.decimalseparator` | `.` | Das Dezimaltrennzeichen. |\n\nDie Namen der Monate und Tage stehen in den globalen Arrays `MONTHS` und `DAYS`. `DAYS` beginnt mit Sonntag:\n\n```js\nMONTHS = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'.split(',');\nDAYS = 'domingo,lunes,martes,miércoles,jueves,viernes,sábado'.split(',');\n\nDEF.dateformat = 'dd.MM.yyyy';\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\nvar date = new Date(2024, 2, 5, 14, 7);\n\ndate.format();                     // 05.03.2024\ndate.format('dddd, d. MMMM yyyy'); // martes, 5. marzo 2024\n(1234567.891).format(2);           // 1.234.567,89\n```\n\nDie Helper von [Tangular](../tangular/) verwenden dieselben Einstellungen:\n\n```js\nTangular.render('{{ date | format }} {{ price | format(2) }}', { date: date, price: 1500 });\n// 05.03.2024 1.500,00\n```\n\nDie Platzhalter eines Datumsformats sind in der [Date-Referenz](../../reference/date/) aufgeführt.\n\n## Währungen\n\n`DEF.currencies` enthält eine Formatierungsfunktion pro Währung, und `DEF.currency` ist die Standardwährung. `number.currency([name])` verwendet sie. Bei einer unbekannten Währung wird die Zahl mit zwei Dezimalstellen formatiert:\n\n```js\nDEF.currencies.eur = function(value) {\n    return value.format(2) + ' EUR';\n};\n\nDEF.currencies.usd = function(value) {\n    return '$' + value.format(2);\n};\n\nDEF.currency = 'eur';\n\n(1250).currency();      // 1 250.00 EUR\n(1250).currency('usd'); // $1 250.00\n(1250).currency('gbp'); // 1 250.00\n```\n\nDer Helper `currency` in Tangular macht dasselbe:\n\n```js\nTangular.render(\"{{ price | currency }} {{ price | currency('usd') }}\", { price: 10 });\n// 10.00 EUR $10.00\n```\n\n## Pluralformen\n\n`number.pluralize(zero, one, few, other)` wählt einen Text anhand der Zahl aus. `few` deckt die Zahlen von 2 bis 4 ab. `#` schreibt die Zahl und `##` schreibt sie formatiert:\n\n```js\n(0).pluralize('no files', '# file', '# files', '# files'); // no files\n(1).pluralize('no files', '# file', '# files', '# files'); // 1 file\n(3).pluralize('no files', '# file', '# files', '# files'); // 3 files\n\n(1500).pluralize('none', 'one', 'few', '## files');        // 1 500 files\n```\n\n## Formate an einer Stelle halten\n\n`ENV(name, value)` speichert einen Wert, und Formatierungsmethoden lesen ihn, wenn du seinen Namen in eckige Klammern schreibst. Eine Übersetzung der Anwendung kann die Formate dann an einer Stelle ändern:\n\n```js\nENV('files', 'no files,# file,# files,# files');\n(2).pluralize('[files]'); // 2 files\n\nENV('short', 'dd/MM');\nnew Date(2024, 2, 5).format('[short]'); // 05/03\n```\n\n## Dem Server die Sprache mitteilen\n\n`DEF.language` fügt jeder mit `AJAX()` gestellten Anfrage einen Sprachparameter hinzu. `DEF.languagehtml` fügt ihn nur Adressen hinzu, die `.html` enthalten. Das ist nützlich, wenn der Server Templates übersetzt. `DEF.languagekey` ist der Name des Parameters:\n\n```js\nDEF.language = 'sk';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?language=sk\n\nDEF.language = '';\nDEF.languagehtml = 'de';\nAJAX('GET /templates/form.html', callback);\n// GET /templates/form.html?language=de\n\nDEF.languagehtml = '';\nDEF.language = 'en';\nDEF.languagekey = 'lang';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?lang=en\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:54.124Z"}
{"id":"JammTo1sM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/localization/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"es","title":"Localización","summary":"Traduce textos y adapta fechas, números, monedas y plurales al idioma del usuario.","markdown":"---\ntitle: \"Localización\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/guides/localization/\nupdated: 2026-11-18T13:55:54.124Z\n---\n\n# Localización\n\n> Traduce textos y adapta fechas, números, monedas y plurales al idioma del usuario.\n\nLa localización tiene dos partes: traducir los textos de la interfaz con un diccionario y dar formato a fechas, números y monedas como espera el usuario.\n\n## Marcar texto para traducir\n\nEscribe un texto traducible como `@(text)`. `TRANSLATE(text)` sustituye cada texto marcado por su traducción de `DEF.dictionary`. Un texto sin traducción se queda en el idioma original:\n\n```js\nDEF.dictionary[HASH('Save').toString(36)] = 'Guardar';\nDEF.dictionary[HASH('Cancel').toString(36)] = 'Cancelar';\n\nTRANSLATE('@(Save) | @(Cancel) | @(Delete)');\n// Guardar | Cancelar | Delete\n```\n\nEl texto marcado puede contener paréntesis, como en `@(Save (draft))`.\n\n## Claves del diccionario\n\nLa clave de una traducción es el hash del texto original en base 36:\n\n```js\nHASH('Save').toString(36); // '1j2ql'\n```\n\nLa misma clave con el prefijo `T` también funciona. La biblioteca busca primero la clave sin el prefijo.\n\n## Cargar traducciones\n\n`LOCALIZE(text)` añade traducciones a partir de un texto con un `key : translation` por línea. Se omiten las líneas vacías, las líneas sin dos puntos y las que empiezan por `//`. Solo los primeros dos puntos separan la clave, así que una traducción puede contener dos puntos:\n\n```js\nvar key1 = HASH('Save').toString(36);\nvar key2 = HASH('Opening hours').toString(36);\n\nLOCALIZE([\n    '// Spanish',\n    key1 + ' : Guardar',\n    key2 + ' : Abierto: 9:00 - 17:00'\n].join('\\n'));\n\nTRANSLATE('@(Opening hours)'); // Abierto: 9:00 - 17:00\n```\n\nCarga el diccionario antes que los componentes, porque los textos se traducen cuando se inician los componentes.\n\n## Dónde se traducen los textos\n\nLa biblioteca traduce los textos marcados en:\n\n- el atributo `config` de `<ui-component>` y `<ui-bind>`,\n- las plantillas de `<ui-bind>`,\n- el contenido cargado con [IMPORT() y ui-import](../importing/),\n- el texto que se pasa a `ADAPT()`.\n\nEl HTML estático de la página no se traduce:\n\n```html\n<script>\n    LOCALIZE(HASH('Your name').toString(36) + ': Tu nombre');\n\n    COMPONENT('label', function(self, config) {\n        self.make = function() {\n            self.text(config.title);\n        };\n    });\n\n    var user = { name: 'Peter' };\n</script>\n\n<!-- Tu nombre -->\n<ui-component name=\"label\" config=\"title:@(Your name)\"></ui-component>\n\n<!-- Tu nombre: Peter -->\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\"><b>@(Your name)</b>: {{ value.name }}</script>\n</ui-bind>\n\n<!-- @(Your name) -->\n<p>@(Your name)</p>\n```\n\n## Fechas y números\n\nEstos ajustes de [DEF](../../reference/def/) controlan los formatos predeterminados:\n\n| Ajuste | Valor predeterminado | Descripción |\n| --- | --- | --- |\n| `DEF.dateformat` | `yyyy-MM-dd` | El formato de `date.format()` sin argumento. |\n| `DEF.thousandsseparator` | un espacio | El separador de miles. |\n| `DEF.decimalseparator` | `.` | El separador decimal. |\n\nLos nombres de los meses y los días están en los arrays globales `MONTHS` y `DAYS`. `DAYS` empieza por el domingo:\n\n```js\nMONTHS = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'.split(',');\nDAYS = 'domingo,lunes,martes,miércoles,jueves,viernes,sábado'.split(',');\n\nDEF.dateformat = 'dd.MM.yyyy';\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\nvar date = new Date(2024, 2, 5, 14, 7);\n\ndate.format();                     // 05.03.2024\ndate.format('dddd, d. MMMM yyyy'); // martes, 5. marzo 2024\n(1234567.891).format(2);           // 1.234.567,89\n```\n\nLos helpers de [Tangular](../tangular/) usan los mismos ajustes:\n\n```js\nTangular.render('{{ date | format }} {{ price | format(2) }}', { date: date, price: 1500 });\n// 05.03.2024 1.500,00\n```\n\nLos tokens de un formato de fecha se enumeran en la [referencia de Date](../../reference/date/).\n\n## Monedas\n\n`DEF.currencies` contiene una función de formato por moneda, y `DEF.currency` es la predeterminada. `number.currency([name])` las usa. Una moneda desconocida da formato al número con dos decimales:\n\n```js\nDEF.currencies.eur = function(value) {\n    return value.format(2) + ' EUR';\n};\n\nDEF.currencies.usd = function(value) {\n    return '$' + value.format(2);\n};\n\nDEF.currency = 'eur';\n\n(1250).currency();      // 1 250.00 EUR\n(1250).currency('usd'); // $1 250.00\n(1250).currency('gbp'); // 1 250.00\n```\n\nEl helper `currency` de Tangular hace lo mismo:\n\n```js\nTangular.render(\"{{ price | currency }} {{ price | currency('usd') }}\", { price: 10 });\n// 10.00 EUR $10.00\n```\n\n## Plurales\n\n`number.pluralize(zero, one, few, other)` elige un texto según el número. `few` cubre los números del 2 al 4. `#` escribe el número y `##` lo escribe con formato:\n\n```js\n(0).pluralize('no files', '# file', '# files', '# files'); // no files\n(1).pluralize('no files', '# file', '# files', '# files'); // 1 file\n(3).pluralize('no files', '# file', '# files', '# files'); // 3 files\n\n(1500).pluralize('none', 'one', 'few', '## files');        // 1 500 files\n```\n\n## Mantener los formatos en un solo lugar\n\n`ENV(name, value)` guarda un valor, y los métodos de formato lo leen cuando escribes su nombre entre corchetes. Así, una traducción de la aplicación puede cambiar los formatos en un solo lugar:\n\n```js\nENV('files', 'no files,# file,# files,# files');\n(2).pluralize('[files]'); // 2 files\n\nENV('short', 'dd/MM');\nnew Date(2024, 2, 5).format('[short]'); // 05/03\n```\n\n## Indicar el idioma al servidor\n\n`DEF.language` añade un parámetro de idioma a cada petición hecha con `AJAX()`. `DEF.languagehtml` lo añade solo a las direcciones que contienen `.html`, lo que resulta útil cuando el servidor traduce las plantillas. `DEF.languagekey` es el nombre del parámetro:\n\n```js\nDEF.language = 'sk';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?language=sk\n\nDEF.language = '';\nDEF.languagehtml = 'de';\nAJAX('GET /templates/form.html', callback);\n// GET /templates/form.html?language=de\n\nDEF.languagehtml = '';\nDEF.language = 'en';\nDEF.languagekey = 'lang';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?lang=en\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:54.124Z"}
{"id":"JammTo1sM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/localization/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"fr","title":"Localisation","summary":"Traduis les textes et adapte les dates, les nombres, les devises et les pluriels à la langue de l'utilisateur.","markdown":"---\ntitle: Localisation\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/guides/localization/\nupdated: 2026-11-18T13:55:54.124Z\n---\n\n# Localisation\n\n> Traduis les textes et adapte les dates, les nombres, les devises et les pluriels à la langue de l'utilisateur.\n\nLa localisation comporte deux volets : traduire les textes de l'interface à l'aide d'un dictionnaire, et formater les dates, les nombres et les devises comme l'utilisateur s'y attend.\n\n## Marquer un texte à traduire\n\nÉcris un texte traduisible sous la forme `@(text)`. `TRANSLATE(text)` remplace chaque texte marqué par sa traduction issue de `DEF.dictionary`. Un texte sans traduction reste dans la langue d'origine :\n\n```js\nDEF.dictionary[HASH('Save').toString(36)] = 'Guardar';\nDEF.dictionary[HASH('Cancel').toString(36)] = 'Cancelar';\n\nTRANSLATE('@(Save) | @(Cancel) | @(Delete)');\n// Guardar | Cancelar | Delete\n```\n\nLe texte marqué peut contenir des parenthèses, comme dans `@(Save (draft))`.\n\n## Clés du dictionnaire\n\nLa clé d'une traduction est le hachage du texte d'origine en base 36 :\n\n```js\nHASH('Save').toString(36); // '1j2ql'\n```\n\nLa même clé avec le préfixe `T` fonctionne également. La bibliothèque cherche d'abord la clé sans le préfixe.\n\n## Charger les traductions\n\n`LOCALIZE(text)` ajoute des traductions à partir d'un texte contenant une paire `key : translation` par ligne. Les lignes vides, les lignes sans deux-points et les lignes qui commencent par `//` sont ignorées. Seul le premier deux-points sépare la clé : une traduction peut donc contenir des deux-points :\n\n```js\nvar key1 = HASH('Save').toString(36);\nvar key2 = HASH('Opening hours').toString(36);\n\nLOCALIZE([\n    '// Spanish',\n    key1 + ' : Guardar',\n    key2 + ' : Abierto: 9:00 - 17:00'\n].join('\\n'));\n\nTRANSLATE('@(Opening hours)'); // Abierto: 9:00 - 17:00\n```\n\nCharge le dictionnaire avant les composants, car les textes sont traduits au démarrage des composants.\n\n## Où les textes sont traduits\n\nLa bibliothèque traduit les textes marqués dans :\n\n- l'attribut `config` de `<ui-component>` et de `<ui-bind>`,\n- les modèles de `<ui-bind>`,\n- le contenu chargé avec [IMPORT() et ui-import](../importing/),\n- le texte passé à `ADAPT()`.\n\nLe HTML statique de la page n'est pas traduit :\n\n```html\n<script>\n    LOCALIZE(HASH('Your name').toString(36) + ': Tu nombre');\n\n    COMPONENT('label', function(self, config) {\n        self.make = function() {\n            self.text(config.title);\n        };\n    });\n\n    var user = { name: 'Peter' };\n</script>\n\n<!-- Tu nombre -->\n<ui-component name=\"label\" config=\"title:@(Your name)\"></ui-component>\n\n<!-- Tu nombre: Peter -->\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\"><b>@(Your name)</b>: {{ value.name }}</script>\n</ui-bind>\n\n<!-- @(Your name) -->\n<p>@(Your name)</p>\n```\n\n## Dates et nombres\n\nCes réglages de [DEF](../../reference/def/) déterminent les formats par défaut :\n\n| Réglage | Valeur par défaut | Description |\n| --- | --- | --- |\n| `DEF.dateformat` | `yyyy-MM-dd` | Le format de `date.format()` sans argument. |\n| `DEF.thousandsseparator` | une espace | Le séparateur des milliers. |\n| `DEF.decimalseparator` | `.` | Le séparateur décimal. |\n\nLes noms des mois et des jours se trouvent dans les tableaux globaux `MONTHS` et `DAYS`. `DAYS` commence par le dimanche :\n\n```js\nMONTHS = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'.split(',');\nDAYS = 'domingo,lunes,martes,miércoles,jueves,viernes,sábado'.split(',');\n\nDEF.dateformat = 'dd.MM.yyyy';\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\nvar date = new Date(2024, 2, 5, 14, 7);\n\ndate.format();                     // 05.03.2024\ndate.format('dddd, d. MMMM yyyy'); // martes, 5. marzo 2024\n(1234567.891).format(2);           // 1.234.567,89\n```\n\nLes helpers de [Tangular](../tangular/) utilisent les mêmes réglages :\n\n```js\nTangular.render('{{ date | format }} {{ price | format(2) }}', { date: date, price: 1500 });\n// 05.03.2024 1.500,00\n```\n\nLes jetons d'un format de date sont listés dans la [référence Date](../../reference/date/).\n\n## Devises\n\n`DEF.currencies` contient une fonction de formatage par devise, et `DEF.currency` désigne la devise par défaut. `number.currency([name])` les utilise. Une devise inconnue formate le nombre avec deux décimales :\n\n```js\nDEF.currencies.eur = function(value) {\n    return value.format(2) + ' EUR';\n};\n\nDEF.currencies.usd = function(value) {\n    return '$' + value.format(2);\n};\n\nDEF.currency = 'eur';\n\n(1250).currency();      // 1 250.00 EUR\n(1250).currency('usd'); // $1 250.00\n(1250).currency('gbp'); // 1 250.00\n```\n\nLe helper `currency` de Tangular fait de même :\n\n```js\nTangular.render(\"{{ price | currency }} {{ price | currency('usd') }}\", { price: 10 });\n// 10.00 EUR $10.00\n```\n\n## Pluriels\n\n`number.pluralize(zero, one, few, other)` choisit un texte selon le nombre. `few` couvre les nombres de 2 à 4. `#` écrit le nombre et `##` l'écrit formaté :\n\n```js\n(0).pluralize('no files', '# file', '# files', '# files'); // no files\n(1).pluralize('no files', '# file', '# files', '# files'); // 1 file\n(3).pluralize('no files', '# file', '# files', '# files'); // 3 files\n\n(1500).pluralize('none', 'one', 'few', '## files');        // 1 500 files\n```\n\n## Regrouper les formats au même endroit\n\n`ENV(name, value)` stocke une valeur, et les méthodes de formatage la lisent quand tu écris son nom entre crochets. Une traduction de l'application peut ainsi modifier les formats à un seul endroit :\n\n```js\nENV('files', 'no files,# file,# files,# files');\n(2).pluralize('[files]'); // 2 files\n\nENV('short', 'dd/MM');\nnew Date(2024, 2, 5).format('[short]'); // 05/03\n```\n\n## Indiquer la langue au serveur\n\n`DEF.language` ajoute un paramètre de langue à chaque requête effectuée avec `AJAX()`. `DEF.languagehtml` ne l'ajoute qu'aux adresses contenant `.html`, ce qui est utile quand le serveur traduit les modèles. `DEF.languagekey` est le nom du paramètre :\n\n```js\nDEF.language = 'sk';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?language=sk\n\nDEF.language = '';\nDEF.languagehtml = 'de';\nAJAX('GET /templates/form.html', callback);\n// GET /templates/form.html?language=de\n\nDEF.languagehtml = '';\nDEF.language = 'en';\nDEF.languagekey = 'lang';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?lang=en\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:54.124Z"}
{"id":"JammTo1sM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/localization/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"it","title":"Localizzazione","summary":"Traduci i testi e adatta date, numeri, valute e plurali alla lingua dell'utente.","markdown":"---\ntitle: Localizzazione\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/guides/localization/\nupdated: 2026-11-18T13:55:54.124Z\n---\n\n# Localizzazione\n\n> Traduci i testi e adatta date, numeri, valute e plurali alla lingua dell'utente.\n\nLa localizzazione ha due parti: tradurre i testi dell'interfaccia con un dizionario e formattare date, numeri e valute nel modo che l'utente si aspetta.\n\n## Contrassegnare il testo da tradurre\n\nScrivi un testo traducibile come `@(text)`. `TRANSLATE(text)` sostituisce ogni testo contrassegnato con la sua traduzione presa da `DEF.dictionary`. Un testo senza traduzione resta nella lingua originale:\n\n```js\nDEF.dictionary[HASH('Save').toString(36)] = 'Guardar';\nDEF.dictionary[HASH('Cancel').toString(36)] = 'Cancelar';\n\nTRANSLATE('@(Save) | @(Cancel) | @(Delete)');\n// Guardar | Cancelar | Delete\n```\n\nIl testo contrassegnato può contenere parentesi, come in `@(Save (draft))`.\n\n## Chiavi del dizionario\n\nLa chiave di una traduzione è l'hash del testo originale in base 36:\n\n```js\nHASH('Save').toString(36); // '1j2ql'\n```\n\nFunziona anche la stessa chiave con il prefisso `T`. La libreria cerca prima la chiave senza prefisso.\n\n## Caricare le traduzioni\n\n`LOCALIZE(text)` aggiunge le traduzioni da un testo con una coppia `key : translation` per riga. Le righe vuote, le righe senza due punti e le righe che iniziano con `//` vengono saltate. Solo i primi due punti separano la chiave, quindi una traduzione può contenere il carattere due punti:\n\n```js\nvar key1 = HASH('Save').toString(36);\nvar key2 = HASH('Opening hours').toString(36);\n\nLOCALIZE([\n    '// Spanish',\n    key1 + ' : Guardar',\n    key2 + ' : Abierto: 9:00 - 17:00'\n].join('\\n'));\n\nTRANSLATE('@(Opening hours)'); // Abierto: 9:00 - 17:00\n```\n\nCarica il dizionario prima dei componenti, perché i testi vengono tradotti all'avvio dei componenti.\n\n## Dove vengono tradotti i testi\n\nLa libreria traduce i testi contrassegnati in:\n\n- l'attributo `config` di `<ui-component>` e `<ui-bind>`,\n- i template di `<ui-bind>`,\n- i contenuti caricati con [IMPORT() e ui-import](../importing/),\n- il testo passato ad `ADAPT()`.\n\nL'HTML statico della pagina non viene tradotto:\n\n```html\n<script>\n    LOCALIZE(HASH('Your name').toString(36) + ': Tu nombre');\n\n    COMPONENT('label', function(self, config) {\n        self.make = function() {\n            self.text(config.title);\n        };\n    });\n\n    var user = { name: 'Peter' };\n</script>\n\n<!-- Tu nombre -->\n<ui-component name=\"label\" config=\"title:@(Your name)\"></ui-component>\n\n<!-- Tu nombre: Peter -->\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\"><b>@(Your name)</b>: {{ value.name }}</script>\n</ui-bind>\n\n<!-- @(Your name) -->\n<p>@(Your name)</p>\n```\n\n## Date e numeri\n\nQueste impostazioni di [DEF](../../reference/def/) controllano i formati predefiniti:\n\n| Impostazione | Valore predefinito | Descrizione |\n| --- | --- | --- |\n| `DEF.dateformat` | `yyyy-MM-dd` | Il formato di `date.format()` senza argomenti. |\n| `DEF.thousandsseparator` | uno spazio | Il separatore delle migliaia. |\n| `DEF.decimalseparator` | `.` | Il separatore decimale. |\n\nI nomi dei mesi e dei giorni si trovano negli array globali `MONTHS` e `DAYS`. `DAYS` inizia dalla domenica:\n\n```js\nMONTHS = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'.split(',');\nDAYS = 'domingo,lunes,martes,miércoles,jueves,viernes,sábado'.split(',');\n\nDEF.dateformat = 'dd.MM.yyyy';\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\nvar date = new Date(2024, 2, 5, 14, 7);\n\ndate.format();                     // 05.03.2024\ndate.format('dddd, d. MMMM yyyy'); // martes, 5. marzo 2024\n(1234567.891).format(2);           // 1.234.567,89\n```\n\nGli helper di [Tangular](../tangular/) usano le stesse impostazioni:\n\n```js\nTangular.render('{{ date | format }} {{ price | format(2) }}', { date: date, price: 1500 });\n// 05.03.2024 1.500,00\n```\n\nI token di un formato di data sono elencati nel [riferimento di Date](../../reference/date/).\n\n## Valute\n\n`DEF.currencies` contiene una funzione di formattazione per ogni valuta e `DEF.currency` è quella predefinita. `number.currency([name])` le usa. Una valuta sconosciuta formatta il numero con due decimali:\n\n```js\nDEF.currencies.eur = function(value) {\n    return value.format(2) + ' EUR';\n};\n\nDEF.currencies.usd = function(value) {\n    return '$' + value.format(2);\n};\n\nDEF.currency = 'eur';\n\n(1250).currency();      // 1 250.00 EUR\n(1250).currency('usd'); // $1 250.00\n(1250).currency('gbp'); // 1 250.00\n```\n\nL'helper `currency` di Tangular fa lo stesso:\n\n```js\nTangular.render(\"{{ price | currency }} {{ price | currency('usd') }}\", { price: 10 });\n// 10.00 EUR $10.00\n```\n\n## Plurali\n\n`number.pluralize(zero, one, few, other)` sceglie un testo in base al numero. `few` copre i numeri da 2 a 4. `#` scrive il numero e `##` lo scrive formattato:\n\n```js\n(0).pluralize('no files', '# file', '# files', '# files'); // no files\n(1).pluralize('no files', '# file', '# files', '# files'); // 1 file\n(3).pluralize('no files', '# file', '# files', '# files'); // 3 files\n\n(1500).pluralize('none', 'one', 'few', '## files');        // 1 500 files\n```\n\n## Tenere i formati in un unico punto\n\n`ENV(name, value)` memorizza un valore, e i metodi di formattazione lo leggono quando ne scrivi il nome tra parentesi quadre. Una traduzione dell'applicazione può così cambiare i formati in un unico punto:\n\n```js\nENV('files', 'no files,# file,# files,# files');\n(2).pluralize('[files]'); // 2 files\n\nENV('short', 'dd/MM');\nnew Date(2024, 2, 5).format('[short]'); // 05/03\n```\n\n## Comunicare la lingua al server\n\n`DEF.language` aggiunge un parametro di lingua a ogni richiesta effettuata con `AJAX()`. `DEF.languagehtml` lo aggiunge solo agli indirizzi che contengono `.html`, il che è utile quando il server traduce i template. `DEF.languagekey` è il nome del parametro:\n\n```js\nDEF.language = 'sk';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?language=sk\n\nDEF.language = '';\nDEF.languagehtml = 'de';\nAJAX('GET /templates/form.html', callback);\n// GET /templates/form.html?language=de\n\nDEF.languagehtml = '';\nDEF.language = 'en';\nDEF.languagekey = 'lang';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?lang=en\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:54.124Z"}
{"id":"JammTo1sM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/localization/","project":"jcomponent-v19","version":"19-194","section":"guides","language":"sk","title":"Lokalizácia","summary":"Prekladaj texty a prispôsobuj dátumy, čísla, meny a množné čísla jazyku používateľa.","markdown":"---\ntitle: \"Lokalizácia\"\nproject: jComponent V19\nversion: 19.194\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/guides/localization/\nupdated: 2026-11-18T13:55:54.124Z\n---\n\n# Lokalizácia\n\n> Prekladaj texty a prispôsobuj dátumy, čísla, meny a množné čísla jazyku používateľa.\n\nLokalizácia má dve časti: preklad textov rozhrania pomocou slovníka a formátovanie dátumov, čísel a mien tak, ako to používateľ očakáva.\n\n## Označenie textu na preklad\n\nPreložiteľný text zapíš ako `@(text)`. `TRANSLATE(text)` nahradí každý označený text jeho prekladom z `DEF.dictionary`. Text bez prekladu zostane v pôvodnom jazyku:\n\n```js\nDEF.dictionary[HASH('Save').toString(36)] = 'Guardar';\nDEF.dictionary[HASH('Cancel').toString(36)] = 'Cancelar';\n\nTRANSLATE('@(Save) | @(Cancel) | @(Delete)');\n// Guardar | Cancelar | Delete\n```\n\nOznačený text môže obsahovať zátvorky, napríklad `@(Save (draft))`.\n\n## Kľúče slovníka\n\nKľúčom prekladu je hash pôvodného textu v sústave so základom 36:\n\n```js\nHASH('Save').toString(36); // '1j2ql'\n```\n\nFunguje aj rovnaký kľúč s predponou `T`. Knižnica najprv hľadá kľúč bez predpony.\n\n## Načítanie prekladov\n\n`LOCALIZE(text)` pridá preklady z textu, ktorý má na každom riadku jeden záznam `key : translation`. Prázdne riadky, riadky bez dvojbodky a riadky začínajúce na `//` sa preskočia. Kľúč oddeľuje iba prvá dvojbodka, takže preklad môže dvojbodky obsahovať:\n\n```js\nvar key1 = HASH('Save').toString(36);\nvar key2 = HASH('Opening hours').toString(36);\n\nLOCALIZE([\n    '// Spanish',\n    key1 + ' : Guardar',\n    key2 + ' : Abierto: 9:00 - 17:00'\n].join('\\n'));\n\nTRANSLATE('@(Opening hours)'); // Abierto: 9:00 - 17:00\n```\n\nSlovník načítaj pred komponentmi, pretože texty sa prekladajú pri štarte komponentov.\n\n## Kde sa texty prekladajú\n\nKnižnica prekladá označené texty v týchto miestach:\n\n- atribút `config` elementov `<ui-component>` a `<ui-bind>`,\n- šablóny elementu `<ui-bind>`,\n- obsah načítaný pomocou [IMPORT() a ui-import](../importing/),\n- text odovzdaný funkcii `ADAPT()`.\n\nStatické HTML stránky sa neprekladá:\n\n```html\n<script>\n    LOCALIZE(HASH('Your name').toString(36) + ': Tu nombre');\n\n    COMPONENT('label', function(self, config) {\n        self.make = function() {\n            self.text(config.title);\n        };\n    });\n\n    var user = { name: 'Peter' };\n</script>\n\n<!-- Tu nombre -->\n<ui-component name=\"label\" config=\"title:@(Your name)\"></ui-component>\n\n<!-- Tu nombre: Peter -->\n<ui-bind path=\"user\" config=\"template\">\n    <script type=\"text/html\"><b>@(Your name)</b>: {{ value.name }}</script>\n</ui-bind>\n\n<!-- @(Your name) -->\n<p>@(Your name)</p>\n```\n\n## Dátumy a čísla\n\nTieto nastavenia [DEF](../../reference/def/) určujú predvolené formáty:\n\n| Nastavenie | Predvolená hodnota | Popis |\n| --- | --- | --- |\n| `DEF.dateformat` | `yyyy-MM-dd` | Formát `date.format()` bez argumentu. |\n| `DEF.thousandsseparator` | medzera | Oddeľovač tisícov. |\n| `DEF.decimalseparator` | `.` | Desatinný oddeľovač. |\n\nNázvy mesiacov a dní sú v globálnych poliach `MONTHS` a `DAYS`. `DAYS` začína nedeľou:\n\n```js\nMONTHS = 'enero,febrero,marzo,abril,mayo,junio,julio,agosto,septiembre,octubre,noviembre,diciembre'.split(',');\nDAYS = 'domingo,lunes,martes,miércoles,jueves,viernes,sábado'.split(',');\n\nDEF.dateformat = 'dd.MM.yyyy';\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\nvar date = new Date(2024, 2, 5, 14, 7);\n\ndate.format();                     // 05.03.2024\ndate.format('dddd, d. MMMM yyyy'); // martes, 5. marzo 2024\n(1234567.891).format(2);           // 1.234.567,89\n```\n\nHelpery [Tangular](../tangular/) používajú rovnaké nastavenia:\n\n```js\nTangular.render('{{ date | format }} {{ price | format(2) }}', { date: date, price: 1500 });\n// 05.03.2024 1.500,00\n```\n\nTokeny formátu dátumu uvádza [referencia Date](../../reference/date/).\n\n## Meny\n\n`DEF.currencies` obsahuje pre každú menu jednu formátovaciu funkciu a `DEF.currency` je predvolená mena. Používa ich `number.currency([name])`. Neznáma mena naformátuje číslo na dve desatinné miesta:\n\n```js\nDEF.currencies.eur = function(value) {\n    return value.format(2) + ' EUR';\n};\n\nDEF.currencies.usd = function(value) {\n    return '$' + value.format(2);\n};\n\nDEF.currency = 'eur';\n\n(1250).currency();      // 1 250.00 EUR\n(1250).currency('usd'); // $1 250.00\n(1250).currency('gbp'); // 1 250.00\n```\n\nRovnako funguje helper `currency` v Tangulare:\n\n```js\nTangular.render(\"{{ price | currency }} {{ price | currency('usd') }}\", { price: 10 });\n// 10.00 EUR $10.00\n```\n\n## Množné čísla\n\n`number.pluralize(zero, one, few, other)` vyberie text podľa čísla. `few` pokrýva čísla od 2 do 4. `#` vypíše číslo a `##` ho vypíše naformátované:\n\n```js\n(0).pluralize('no files', '# file', '# files', '# files'); // no files\n(1).pluralize('no files', '# file', '# files', '# files'); // 1 file\n(3).pluralize('no files', '# file', '# files', '# files'); // 3 files\n\n(1500).pluralize('none', 'one', 'few', '## files');        // 1 500 files\n```\n\n## Formáty na jednom mieste\n\n`ENV(name, value)` uloží hodnotu a formátovacie metódy ju načítajú, keď napíšeš jej názov do hranatých zátvoriek. Preklad aplikácie potom môže zmeniť formáty na jednom mieste:\n\n```js\nENV('files', 'no files,# file,# files,# files');\n(2).pluralize('[files]'); // 2 files\n\nENV('short', 'dd/MM');\nnew Date(2024, 2, 5).format('[short]'); // 05/03\n```\n\n## Oznámenie jazyka serveru\n\n`DEF.language` pridá parameter jazyka ku každej požiadavke odoslanej cez `AJAX()`. `DEF.languagehtml` ho pridá iba k adresám, ktoré obsahujú `.html`, čo sa hodí, keď šablóny prekladá server. `DEF.languagekey` je názov parametra:\n\n```js\nDEF.language = 'sk';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?language=sk\n\nDEF.language = '';\nDEF.languagehtml = 'de';\nAJAX('GET /templates/form.html', callback);\n// GET /templates/form.html?language=de\n\nDEF.languagehtml = '';\nDEF.language = 'en';\nDEF.languagekey = 'lang';\nAJAX('GET /api/products/', callback);\n// GET /api/products/?lang=en\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:54.124Z"}
{"id":"JammaB9IM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/globals/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Global functions","summary":"The functions and objects that jComponent adds to the window object.","markdown":"---\ntitle: Global functions\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/globals/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Global functions\n\n> The functions and objects that jComponent adds to the window object.\n\njComponent adds these functions and objects to `window`, so they can be used anywhere without an import. To learn how paths work first, read [Paths](../../guides/paths/).\n\n## API\n\n### ACMD(name, [...args])\n\nType: `method`\n\nCreates a function that calls [CMD()](#cmd) later.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the command. |\n| `...args` | `Object` | no |  | The first arguments. |\n\nReturns: `Function` The function to call.\n\nThe argument of the created function is added as the last argument of the command.\n\nExample: Use it as a callback\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nACMD('refresh')(1);\n```\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrepares imported text for a path and an identifier.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The value for `~PATH~` and `CLASS`. |\n| `id` | `String` | yes |  | The value for `~ID~`. |\n| `text` | `String` | yes |  | The text. |\n\nReturns: `String` The changed text.\n\nThe text is translated, `--name--` variables are replaced, `~CDN~` becomes `DEF.cdn`, `~PATH~` and `CLASS` become the path, and `~ID~` becomes the identifier.\n\nExample: Replace the markers\n```js\nconsole.log(ADAPT('users', 'form1', '~PATH~ and ~ID~')); // users and form1\n```\n\n### ADD(value, [element], [config], [content])\n\nType: `method`\n\nAdds a component to the page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object|Array` | yes |  | The component. |\n| `element` | `Element|jQuery|Component` | no | `document.body` | The parent element. |\n| `config` | `Object|String` | no |  | The configuration. |\n| `content` | `String` | no |  | The inner HTML. |\n\nA string has the form `name__path__config`. A leading `!` skips the component when it is already declared. An object can have the fields `name`, `path`, `config`, `element` and `prepend`. An array adds several components.\n\nExample: Add a component\n```js\nADD('box__data.title__size:10');\nsetTimeout(function() {\n\tconsole.log(FIND('box').config.size); // 10\n}, 1200);\n```\n\n### AEXEC(path, [...args])\n\nType: `method`\n\nCreates a function that calls [EXEC()](#exec) later.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The target. |\n| `...args` | `Object` | no |  | The first arguments. |\n\nReturns: `Function` The function to call.\n\nThe argument of the created function is added as the last argument.\n\nExample: Use it as a callback\n```js\nwindow.save = value => console.log(value); // 5\nAEXEC('save')(5);\n```\n\n### AJAX(url, [data], [callback], [delay])\n\nType: `method`\n\nSends an HTTP request.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The method and the URL. |\n| `data` | `Object|String` | no |  | The data. A `GET` request sends it in the query string. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, or a path. |\n| `delay` | `Number` | no |  | Waits this many milliseconds before sending. |\n\nReturns: `Promise` Only when no callback is given.\n\nThe URL has the form `METHOD /path/`. More items can follow it, separated by a space:\n\n| Item | Meaning |\n| --- | --- |\n| `!METHOD` | Sends cookies with the request |\n| `{ \"Name\": \"value\" }` | Request headers |\n| `<5 minutes>` | Caches the response, as in [AJAXCACHE()](#ajaxcache) |\n| `(name)` | Applies the settings from [AJAXCONFIG()](#ajaxconfig) |\n| `repeat` | Repeats the request when the server is not available |\n| `cancel` | Cancels the previous unfinished request to the same URL |\n| `urlencoded` | Sends the data as a URL-encoded form |\n| `json` | Accepts only a JSON response |\n| `error` | Passes the response through [ERROR()](#error) |\n| `noencrypt`, `nodecrypt`, `nocsrf` | Skips encryption, decryption or the CSRF header |\n| `#id` | Names the request for `cancel`, or waits for a code list |\n| `@flag` | Emits a custom flag |\n\nThe callback receives the response, the status code on an error, and an object with the details of the request. A string callback is a path where the response is stored. Without a callback, the function returns a Promise, which is rejected on a status above 399.\n\nExample: Send data\n```js\nAJAX('POST /api/users/', { name: 'Peter' }, function(response, err) {\n\tconsole.log(response.method, response.url); // POST /api/users/\n\tconsole.log(response.body); // {\"name\":\"Peter\"}\n});\n```\n\nExample: Use a Promise\n```js\n(async function() {\n\tvar response = await AJAX('GET /api/users/');\n\tconsole.log(response.url); // /api/users/\n})();\n```\n\nExample: Handle an error\n```js\nAJAX('GET /api/missing/', function(response, err) {\n\tconsole.log(err, response); // 404 Not found\n});\n```\n\n### AJAXCACHE(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nSends a request and caches the response.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The method and the URL. |\n| `data` | `Object` | no |  | The data. |\n| `callback` | `Function|String` | yes |  | `function(response, cached)`, or a path. |\n| `expire` | `String` | yes |  | For example `5 minutes` or `session`. |\n| `delay` | `Number` | no |  | Waits this many milliseconds before reading. |\n| `clear` | `Boolean` | no |  | With `true`, ignores the stored response. |\n\nThe callback receives the response and `true` when it comes from the cache. The value `session` for `expire` keeps the response in memory until the page is reloaded.\n\nExample: Cache a response\n```js\nAJAXCACHE('GET /api/users/', function(response, cached) {\n\tconsole.log('first', cached); // first false\n\tAJAXCACHE('GET /api/users/', function(response, cached) {\n\t\tconsole.log('second', cached); // second true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nReturns the cached response and then checks the server for a newer one.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The method and the URL. |\n| `data` | `Object` | no |  | The data. |\n| `callback` | `Function|String` | yes |  | `function(response, cached, updated)`, or a path. |\n| `expire` | `String` | yes |  | For example `5 minutes`. |\n| `delay` | `Number` | no |  | Waits this many milliseconds before reading. |\n| `clear` | `Boolean` | no |  | With `true`, ignores the stored response. |\n\nWhen the server returns different data, the callback runs again with `false` and `true` as its second and third arguments.\n\nExample: Refresh a cached response\n```js\nAJAXCACHE('GET /api/time/', function() {\n\tAJAXCACHEREVIEW('GET /api/time/', function(response, cached, updated) {\n\t\tconsole.log(response.value, cached, updated === true); // 2 false true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCONFIG(name, fn)\n\nType: `method`\n\nDeclares settings that a request can apply by name.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the settings. |\n| `fn` | `Function` | yes |  | `function(options)`. |\n\nA request applies them with `(name)` in its URL. The function receives the options of the request.\n\nExample: Add a header\n```js\nAJAXCONFIG('secure', function(options) {\n\toptions.headers['X-Token'] = 'abc';\n});\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-Token']); // abc\n\topt.respond({});\n});\nAJAX('GET /api/users/ (secure)', NOOP);\n```\n\n### API(url, [data], [callback])\n\nType: `method`\n\nCalls a Total.js API endpoint.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The endpoint and the schema. |\n| `data` | `Object` | no |  | The data. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, or a path. |\n\nReturns: `Object|Promise` The object described above, or a Promise.\n\nThe URL has the form `/api/ schema`. The request is a `POST` with the name of the schema and the data in its body. Without a callback, the function returns a Promise. With a callback, it returns an object with `params(value)`, which fills the parameters of the schema, and `data(value)`, which replaces the data.\n\nExample: Call an endpoint\n```js\nAPI('/api/ users_save', { name: 'Peter' }, function(response) {\n\tconsole.log(response.url); // /api/\n\tconsole.log(response.body); // {\"schema\":\"users_save\",\"data\":{\"name\":\"Peter\"}}\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nSets the look of the application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | The CSS variables and the fields `dark` and `large`. |\n\nEvery field becomes a CSS variable on `:root`. `dark` and `large` switch the classes `ui-dark` and `ui-large` on the body. `color` is a six-digit hexadecimal color, which also sets `DEF.color` and the variable `--rgb`.\n\nExample: Use a dark theme\n```js\nAPPEARANCE({ dark: true, color: '#336699' });\nconsole.log($('#cssappearance').html()); // :root{--color:#336699;--rgb:51,102,153}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\n### ASETTER(selector, method, [...args])\n\nType: `method`\n\nCreates a function that calls [SETTER()](#setter) later.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | A selector as in [FIND()](#find). |\n| `method` | `String` | yes |  | The name of the method. |\n| `...args` | `Object` | no |  | The first arguments of the method. |\n\nReturns: `Function` The function to call.\n\nThe argument of the created function is added as the last argument of the method, so it fits a request callback.\n\nExample: Use it as a callback\n```js\nON('ready', function() {\n\tvar fn = ASETTER('box', 'hello');\n\tfn('Peter');\n\tconsole.log(typeof(fn)); // function\n});\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nReads a `data-` attribute from an element or its parents.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery|Event|Object` | yes |  | The source. |\n| `name` | `String` | no | `id` | The name of the attribute. |\n\nReturns: `String` The value.\n\nA plain object returns its field of that name.\n\nExample: Read an identifier\n```html\n<div id=\"row\" data-id=\"15\" data-type=\"user\"></div>\n<script>\nconsole.log(ATTRD($('#row'))); // 15\nconsole.log(ATTRD($('#row'), 'type')); // user\n</script>\n```\n\n### BIND(path)\n\nType: `method`\n\nRefreshes the data bindings of a path without notifying components or watchers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Array` | yes |  | One path or a list of paths. |\n\nExample: Refresh a binding\n```html\n<span id=\"name\" data-bind=\"user.name__text\"></span>\n<script>\nSET('user', { name: 'Peter' });\nsetTimeout(function() {\n\tGET('user').name = 'Anna';\n\tBIND('user.name');\n\tsetTimeout(function() {\n\t\tconsole.log($('#name').text()); // Anna\n\t}, 300);\n}, 300);\n</script>\n```\n\n### BLOCKED(name, timeout, [callback])\n\nType: `method`\n\nLimits how often an action can run.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the action. |\n| `timeout` | `Number|String` | yes |  | Milliseconds, or a value such as `5 seconds`. |\n| `callback` | `Function` | no |  | Runs when the action is not blocked. |\n\nReturns: `Boolean` `true` when the action is blocked.\n\nThe first call returns `false` and blocks the name for the given time. A block longer than 10 seconds is kept in the browser storage.\n\nExample: Allow one call per second\n```js\nconsole.log(BLOCKED('save', 1000)); // false\nconsole.log(BLOCKED('save', 1000)); // true\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nReads or writes a value in the browser 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|Number` | no |  | For example `1 day`, `session`, or milliseconds. |\n\nReturns: `Object` The stored value.\n\nA value is stored only with an expiration. The value `session` keeps it in memory until the page is reloaded.\n\nExample: Store a value\n```js\nCACHE('profile', { name: 'Peter' }, '1 day');\nconsole.log(CACHE('profile')); // {\"name\":\"Peter\"}\n```\n\n### CACHEPATH(path, expire, [rebind])\n\nType: `method`\n\nKeeps the value of a path in the browser cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `expire` | `String` | yes |  | For example `1 month`. |\n| `rebind` | `Boolean` | no | `true` | With `false`, the stored value is not restored. |\n\nEvery change of the path is stored, and the stored value is restored on the next visit. With the form `path__value`, the expression is the value used when nothing is stored.\n\nExample: Remember a value\n```js\nCACHEPATH('settings.theme', '1 month');\nSET('settings.theme', 'dark');\nconsole.log(CACHE('PATHS')); // {\"settings.theme\":\"dark\"}\n```\n\n### CAN(path, [flags])\n\nType: `method`\n\nTells whether a form can be submitted.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it. |\n| `flags` | `String|Array` | no |  | `visible` or `hidden` limits the check to those components. |\n\nReturns: `Boolean` The result.\n\nThe result is `true` when at least one component on the path is touched and none is invalid. A path with no components also returns `true`.\n\nExample: Enable a submit button\n```js\nON('ready', function() {\n\tconsole.log(CAN('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tCHANGE('form.name');\n\tconsole.log(CAN('form.*')); // true\n});\n```\n\n### CHANGE(path, [value])\n\nType: `method`\n\nMarks the components on a path as touched and modified.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Boolean` | no | `true` | With `false`, the marks are removed. |\n\nExample: Mark a field as changed\n```js\nON('ready', function() {\n\tCHANGE('form.age');\n\tconsole.log(MODIFIED('form.*')); // [\"form.age\"]\n});\n```\n\n### CL(name, callback)\n\nType: `method`\n\nWaits until code lists are loaded.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `callback` | `Function` | yes |  | Runs when the lists are ready. |\n\nSeveral names can be separated by a comma. Loaded values are stored in `DEF.cl`.\n\nExample: Wait for a code list\n```js\nCL_INIT('countries', next => next(['SK', 'CZ']));\nCL('countries', function() {\n\tconsole.log(DEF.cl.countries); // [\"SK\",\"CZ\"]\n});\n```\n\n### CL_INIT(name, source, [expire], [init])\n\nType: `method`\n\nDeclares how a code list is loaded.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `source` | `Function|String` | yes |  | The loader. |\n| `expire` | `String` | no |  | The list is loaded again after this time. |\n| `init` | `Boolean` | no |  | With `true`, loads the list immediately. |\n\nThe source is a function that receives `next(value)`, or a string. A string that starts with an HTTP method goes to [AJAX()](#ajax), and any other string to [TAPI()](#tapi). `CLINIT()` is the same function.\n\nExample: Load a list from a URL\n```js\nCL_INIT('roles', 'GET /api/roles/', true);\nsetTimeout(function() {\n\tconsole.log(DEF.cl.roles.url); // /api/roles/\n}, 300);\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nCancels a named timer.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the timer. |\n\nReturns: `Boolean` `true` when a timer was running.\n\nExample: Cancel a timer\n```js\nsetTimeout2('save', NOOP, 1000);\nconsole.log(clearTimeout2('save')); // true\nconsole.log(clearTimeout2('save')); // false\n```\n\n### CLINIT(name, source, [expire], [init])\n\nType: `method`\n\nThe same function as [CL_INIT()](#cl-init).\n\nExample: Same function\n```js\nconsole.log(CLINIT === CL_INIT); // true\n```\n\n### CLONE(value, [nopath])\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 or a path. |\n| `nopath` | `Boolean` | no |  | With `true`, a string is returned as it is. |\n\nReturns: `Object` The copy.\n\nA string is treated as a path, and the value of the path is cloned.\n\nExample: Clone a value\n```js\nSET('user', { name: 'Peter' });\nvar copy = CLONE('user');\ncopy.name = 'Anna';\nconsole.log(GET('user.name')); // Peter\nconsole.log(copy.name); // Anna\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nLoads code lists again.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `callback` | `Function` | no |  | Runs when the lists are loaded. |\n\nSeveral names can be separated by a comma.\n\nExample: Reload a list\n```js\nvar count = 0;\nCL_INIT('numbers', next => next([++count]), true);\nsetTimeout(function() {\n\tCLRELOAD('numbers', function() {\n\t\tconsole.log(DEF.cl.numbers); // [2]\n\t});\n}, 100);\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuns a command in all components that registered it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the command. |\n| `a` | `Object` | no |  | Up to five arguments, `a` to `e`. |\n\nComponents register commands with `self.command()`.\n\nExample: Run a command\n```js\nON('ready', function() {\n\tCMD('box.ping', 5);\n});\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // box.ping 5\n});\n```\n\n### COMPILE([container])\n\nType: `method`\n\nSearches the page for new components and bindings.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limits the search to this element. |\n\nCall it after adding HTML by hand.\n\nExample: Compile new HTML\n```js\n$(document.body).append('<ui-component name=\"box\" path=\"data.new\"></ui-component>');\nCOMPILE();\nsetTimeout(function() {\n\tconsole.log(FIND('box').path); // data.new\n}, 500);\n```\n\n### COMPONENT(name, [config], declaration, [dependencies])\n\nType: `method`\n\nDeclares a component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the component. |\n| `config` | `String|Object` | no |  | The default configuration. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n| `dependencies` | `Array` | no |  | Files to import first, or component names that start with `@`. |\n\nSeveral names can be separated by a comma. A version can follow the name: `box@2`. The whole topic is explained in [Creating components](../../guides/creating-components/), and the object the declaration receives is described in [Component](../component/).\n\nExample: Declare a component\n```html\n<ui-component name=\"hello\"></ui-component>\n<script>\nCOMPONENT('hello', 'name:World', function(self, config) {\n\tself.make = () => self.element.text('Hello ' + config.name);\n});\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // Hello World\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nLists the components on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path with optional flags. |\n\nReturns: `Array` The components.\n\nThe path is written without `.*`. Flags after the path filter the list: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` and `@enabled`.\n\nExample: Filter the components\n```js\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tSET('form.name', 'Peter');\n\tconsole.log(COMPONENTS('form @invalid').map(com => com.path)); // [\"form.age\"]\n});\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nSets the configuration of components before they start.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Which components to configure. |\n| `config` | `Object|String|Function` | yes |  | The configuration, or a function that returns it. |\n\nThe selector is a component name, `.path`, `#id`, or a function that receives the component and returns a boolean. Parts separated by a space must all match, and a comma separates alternatives. Call it before the components are compiled.\n\nExample: Configure by name\n```js\nCONFIG('box', { size: 10 });\nON('ready', function() {\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### COOKIES\n\nType: `property`\n\nAn object for reading and writing cookies.\n\nIt has the methods `get(name)`, `set(name, value, expire, [samesite])` and `rem(name)`. `expire` is a `Date` or a value such as `1 day`.\n\nExample: Read the value\n```js\nCOOKIES.set('theme', 'dark', '1 day');\nconsole.log(COOKIES.get('theme') === 'dark' || location.protocol === 'file:'); // true\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopies the fields of one object to another.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | The object to read. |\n| `target` | `Object` | yes |  | The object to write. |\n\nReturns: `Object` The target object.\n\nObjects inside the source are cloned.\n\nExample: Copy fields\n```js\nvar target = COPY({ a: 1 }, { b: 2 });\nconsole.log(target); // {\"b\":2,\"a\":1}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nThe same function as [STYLE()](#style).\n\nExample: Same function\n```js\nconsole.log(CSS === STYLE); // true\n```\n\n### DAPI(name, [data], [callback])\n\nType: `method`\n\nCalls the API endpoint set in `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the schema. |\n| `data` | `Object` | no |  | The data. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, or a path. |\n\nReturns: `Object|Promise` The same as [API()](#api).\n\n`DEF.api` is a URL, or a function that receives the name and the data and returns the value for [API()](#api).\n\nExample: Use the default endpoint\n```js\nDEF.api = '/api/';\nDAPI('users_list', null, function(response) {\n\tconsole.log(response.url, response.body.schema); // /api/ users_list\n});\n```\n\n### DAYS\n\nType: `property`\n\nThe names of the days, starting with Sunday.\n\nExample: Read the value\n```js\nconsole.log(DAYS[0]); // Sunday\n```\n\n### DEBUG()\n\nType: `method`\n\nTurns on the debug mode.\n\nCalls of missing methods write a warning to the console, and [API()](#api) adds the schema to the URL. The mode cannot be turned on after `DEF.secret()` has set a key.\n\nExample: Warn about a missing method\n```js\nDEBUG();\nEXEC('missing.method');\nconsole.log('done'); // done\n```\n\n### DECRYPT(value, [key], [type])\n\nType: `method`\n\nDecodes a value from [ENCRYPT()](#encrypt).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The encoded value. |\n| `key` | `String` | no |  | The key. |\n| `type` | `String` | no |  | The prefix of the value. |\n\nReturns: `Object` The value, or `undefined` when the key or the prefix does not match.\n\nJSON is parsed back to an object.\n\nExample: Use a wrong key\n```js\nvar token = ENCRYPT('Peter', 'secret');\nconsole.log(DECRYPT(token, 'secret')); // Peter\nconsole.log(DECRYPT(token, 'other') === undefined); // true\n```\n\n### DEF\n\nType: `property`\n\nThe configuration of the library. See [DEF](../def/).\n\nExample: Read the value\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEFAULT(path, [delay], [reset])\n\nType: `method`\n\nRestores the default values of the components on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it, or `path__value`. |\n| `delay` | `Number` | no |  | A delay in milliseconds. |\n| `reset` | `Boolean` | no | `true` | With `false`, the state of the components is kept. |\n\nA component takes its default value from its `default` attribute. With the form `path__value`, the expression after the two underscores is written to the path as the default value instead.\n\nExample: Write a default object\n```js\nDEFAULT('form.* __{ name: \"Peter\" }');\nsetTimeout(function() {\n\tconsole.log(GET('form')); // {\"name\":\"Peter\"}\n}, 100);\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nUpdates the children of an element so they match new HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The parent. |\n| `selector` | `String` | yes |  | A selector of the children. |\n| `html` | `String` | yes |  | The new HTML. |\n| `attribute` | `String` | no |  | The attribute to compare. |\n\nReturns: `Object` The counts `add`, `upd` and `rem`.\n\nOnly the changed children are added or removed. Children are compared by their HTML, or by the value of the attribute.\n\nExample: Update a list\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n<script>\nvar result = DIFFDOM($('#list'), 'li', '<li>B</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log($('#list').text()); // BC\n</script>\n```\n\n### DISABLED(path, [flags])\n\nType: `method`\n\nThe opposite of [CAN()](#can).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it. |\n| `flags` | `String|Array` | no |  | `visible` or `hidden` limits the check to those components. |\n\nReturns: `Boolean` The result.\n\nExample: Disable a submit button\n```js\nON('ready', function() {\n\tconsole.log(DISABLED('form.*')); // true\n});\n```\n\n### EMIT(name, [...args])\n\nType: `method`\n\nCalls the handlers of an event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `...args` | `Object` | no |  | The arguments passed to the handlers. |\n\nReturns: `Boolean` `true` when the event has at least one handler.\n\nA custom flag can follow the name, for example `EMIT('ping @saved')`.\n\nExample: Emit an event\n```js\nON('hello', name => console.log(name)); // Peter\nconsole.log(EMIT('hello', 'Peter')); // true\nconsole.log(EMIT('unknown')); // false\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nA frozen empty array.\n\nExample: Read the value\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nA frozen empty object.\n\nExample: Read the value\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nEncodes a value into a hexadecimal string signed with a key.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | The value. |\n| `key` | `String` | no |  | The key. |\n| `type` | `String` | no |  | A prefix of the result. |\n\nReturns: `String` The encoded value.\n\nThe value is encoded, not strongly encrypted. Objects are converted to JSON.\n\nExample: Encode and decode\n```js\nvar token = ENCRYPT({ id: 5 }, 'secret');\nconsole.log(DECRYPT(token, 'secret')); // {\"id\":5}\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nReads or writes an environment variable.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | The name, or an object with values. |\n| `value` | `Object` | no |  | The value. |\n\nReturns: `Object` The value of the variable.\n\nAn object as the first argument writes several variables. Paths and URLs read the variables with `[name]`. The variables are stored in `DEF.environment`.\n\nExample: Use a variable\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 name, the version and the language of the application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the application. |\n| `version` | `String` | no |  | The version. |\n| `language` | `String` | no |  | The language of imported HTML. |\n| `env` | `Object` | no |  | Environment variables for [ENV()](#env). |\n\nThe name separates the browser storage of the application. It sets `DEF.localstorage`, `DEF.version` and `DEF.languagehtml`.\n\nExample: Name the application\n```js\nENVIRONMENT('shop', '1.2', 'en', { api: '/api/' });\nconsole.log(DEF.localstorage, DEF.version, ENV('api')); // shop 1.2 /api/\n```\n\n### ERROR(value, [success], [error])\n\nType: `method`\n\nTells whether a response contains an error.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|Function` | yes |  | The response, or the success handler. |\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|Function` `true` when the value is an error, or the created callback.\n\nAn `Error`, an object with the field `error`, or an array whose first item has it counts as an error, and the event [ERROR](../events/#error-2) is emitted. `success` and `error` are functions or paths.\n\nWith a function as the first argument, `ERROR(success, [error])` returns a callback for a request.\n\nExample: Check a response\n```js\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\nconsole.log(ERROR({ id: 5 })); // false\n```\n\nExample: Create a callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 5\n});\ncallback({ id: 5 });\n```\n\n### ERRORS(path, [flags], [highlight])\n\nType: `method`\n\nLists the components that are touched and invalid.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it. |\n| `flags` | `String|Array` | no |  | `visible` or `hidden` limits the check to those components. |\n| `highlight` | `Boolean` | no |  | Refreshes the state of the found components. |\n\nReturns: `Array` The components.\n\n`ERRORS(path, true)` also refreshes the state of the components it finds.\n\nExample: Find the invalid fields\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(ERRORS('form.*').map(com => com.path)); // [\"form.name\"]\n});\n```\n\n### EVALUATE(path, expression, [nopath])\n\nType: `method`\n\nEvaluates a JavaScript expression with the value of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Object` | yes |  | The path, or the value itself when `nopath` is `true`. |\n| `expression` | `String` | yes |  | The expression. |\n| `nopath` | `Boolean` | no |  | Treats the first argument as the value. |\n\nReturns: `Object` The result of the expression.\n\nThe expression can use the variables `value` and `path`.\n\nExample: Evaluate an expression\n```js\nSET('price', 10);\nconsole.log(EVALUATE('price', 'value * 2')); // 20\nconsole.log(EVALUATE(4, 'value + 1', true)); // 5\n```\n\n### EXE([wait], path, [...args])\n\nType: `method`\n\nThe same function as [EXEC()](#exec).\n\nExample: Same function\n```js\nconsole.log(EXE === EXEC); // true\n```\n\n### EXEC([wait], path, [...args])\n\nType: `method`\n\nCalls a function, a plugin method, a component method, a command or an event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | With `true`, waits for the target. |\n| `path` | `String` | yes |  | The target. |\n| `...args` | `Object` | no |  | The arguments. |\n\nThe form of the path selects the target:\n\n| Path | Target |\n| --- | --- |\n| `plugin/method` | A method of a plugin |\n| `@plugin.method` | A method of a plugin |\n| `path.to.fn` | A function on a path |\n| `#name` | The event `name` |\n| `-selector/method` | A method of a component, as in [SETTER()](#setter) |\n| `&name` | A command, as in [CMD()](#cmd) |\n\nWith `true` as the first argument, the call waits until the target exists. `EXE()` is the same function.\n\nExample: Call a plugin method\n```js\nPLUGIN('users', function(exports) {\n\texports.hello = function(name) {\n\t\tconsole.log(name); // Peter\n\t};\n});\nEXEC(true, 'users/hello', 'Peter');\n```\n\nExample: Call a function on a path\n```js\nwindow.app = { sum: (a, b) => console.log(a + b) };\nEXEC('app.sum', 1, 2);\nconsole.log(typeof(app.sum)); // function\n```\n\n### EXT(path, value, [delay], [reset])\n\nType: `method`\n\nMerges the fields of an object into the object on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | The fields to merge. |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n| `reset` | `Boolean` | no |  | With `true`, the components on the path are also marked as not touched and not modified. |\n\nEach field is written separately, so the other fields stay. `EXTEND()` is the same function. As with [SET()](#set), the first argument can be a request and `value` the target path.\n\nExample: Merge fields\n```js\nSET('user', { name: 'Peter' });\nEXT('user', { age: 30 });\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"age\":30}\n```\n\n### EXTEND(path, value, [delay], [reset])\n\nType: `method`\n\nThe same function as [EXT()](#ext).\n\nExample: Same function\n```js\nconsole.log(EXTEND === EXT); // true\n```\n\n### EXTENSION(name, [config], declaration)\n\nType: `method`\n\nExtends a component or a plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the component, or `@plugin`. |\n| `config` | `Object|String` | no |  | Additional configuration. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n\nThe declaration runs for every instance of the component, including the existing ones. With a name that starts with `@`, it extends the plugin of that name.\n\nExample: Add a method to a component\n```js\nEXTENSION('box', function(self) {\n\tself.bye = () => 'Bye';\n});\nON('ready', function() {\n\tconsole.log(FIND('box').bye()); // Bye\n});\n```\n\n### FIND(selector, [many], [nocache], [callback])\n\nType: `method`\n\nFinds a component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Element` | yes |  | What to find. |\n| `many` | `Boolean` | no |  | With `true`, returns all matches as an array. |\n| `nocache` | `Boolean` | no |  | Skips the cache of found components. |\n| `callback` | `Function` | no |  | Waits for the component and receives it. |\n\nReturns: `Component|Array` The found component, or an array with `many`. Nothing is returned when a callback is used.\n\nThe selector is a component name, `.path`, `#id`, `name[path]` or `name@version`, and parts can be combined with a space. A DOM element or a jQuery object finds the components inside it.\n\nWith a callback, the search waits until the component exists. The callback can be the second or the third argument.\n\nExample: Find by name and path\n```js\nON('ready', function() {\n\tconsole.log(FIND('box').path); // data.box\n\tconsole.log(FIND('.data.box').name); // box\n\tconsole.log(FIND('box', true).length); // 1\n});\n```\n\nExample: Wait for a component\n```js\nFIND('box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### FN(expression)\n\nType: `method`\n\nCreates a function from a string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expression` | `String` | yes |  | The expression. |\n\nReturns: `Function` The function.\n\nThe string is an arrow function. A string that only uses the word `value` becomes a function with the argument `value`.\n\nExample: Create functions\n```js\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value > 5')(10)); // true\n```\n\n### FORMATTER(fn, [prepend])\n\nType: `method`\n\nRegisters a global formatter of component values.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | With `true`, the formatter runs first. |\n\nReturns: `Object` The formatted value, when the function runs the formatters.\n\nThe function returns the new value, and `undefined` keeps the current one. `FORMATTER(value, path, type, [format])` runs all registered formatters.\n\nExample: Format a value\n```js\nFORMATTER(function(path, value, type) {\n\tif (type === 'upper')\n\t\treturn value.toUpperCase();\n});\nconsole.log(FORMATTER('peter', 'user.name', 'upper')); // PETER\n```\n\n### FREE([delay])\n\nType: `method`\n\nRemoves unused components, bindings and watchers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `10` | The delay in milliseconds. |\n\nThe library also does this every three minutes.\n\nExample: Clean up\n```js\nFREE();\nconsole.log(typeof(FREE)); // function\n```\n\n### FUNC\n\nType: `property`\n\nAn empty object for your own shared functions.\n\nExample: Read the value\n```js\nFUNC.sum = (a, b) => a + b;\nconsole.log(FUNC.sum(1, 2)); // 3\n```\n\n### GET(path, [scope])\n\nType: `method`\n\nReads the value of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `scope` | `Object|Function|Boolean` | no |  | An object reads the path relative to that object. A function waits until the value is not `null` and then receives it. `true` resets the state of the components on the path. |\n\nReturns: `Object` The value, or `undefined` when the path has no value. With a function as the second argument, nothing is returned.\n\nFlags can follow the path. `@clone` returns a copy, `@reset` resets the state of the components after reading, and `@modified` returns only the values of the modified components.\n\nExample: Read a value\n```js\nSET('user', { name: 'Peter', age: 30 });\nconsole.log(GET('user.age')); // 30\nconsole.log(GET('name', { name: 'Anna' })); // Anna\n```\n\nExample: Wait for a value\n```js\nGET('settings.theme', function(value) {\n\tconsole.log(value); // dark\n});\nsetTimeout(() => SET('settings.theme', 'dark'), 100);\n```\n\n### GUID([size])\n\nType: `method`\n\nCreates a random identifier.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `size` | `Number` | no |  | The length. Without it, the identifier has 36 characters in the form of a UUID. |\n\nReturns: `String` The identifier.\n\nExample: Create identifiers\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value, [unsigned])\n\nType: `method`\n\nCreates a number from a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value. |\n| `unsigned` | `Boolean` | no | `true` | With `false`, the result can be negative. |\n\nReturns: `Number` The hash.\n\nObjects are hashed by their JSON form. A number is returned as it is, a boolean becomes `0` or `1`, and a date becomes its time.\n\nExample: Hash a string\n```js\nconsole.log(HASH('abc')); // 96354\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nTells whether an element is not displayed.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | The element. |\n\nReturns: `Boolean` The result. A missing element returns `true`.\n\nExample: Check an element\n```html\n<div id=\"a\" style=\"display:none\"><span></span></div>\n<script>\nconsole.log(HIDDEN($('#a')[0].firstChild)); // true\nconsole.log(HIDDEN(null)); // true\n</script>\n```\n\n### IMPORT(url, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nLoads a script, a style or HTML into the page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String|Array` | yes |  | The URL. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Where to put HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | With `false`, replaces the content of the target. |\n| `preparator` | `Function` | no |  | `function(response, output)` changes the HTML before it is inserted. |\n\nThe topic is explained in [Importing content](../../guides/importing/). An array of URLs is loaded one by one. A URL that starts with `once ` or `!` is loaded only once, and `<path>` before the URL skips the import when the path has a value. The callback receives `1` after loading and `0` when nothing was loaded.\n\nExample: Import HTML\n```html\n<div id=\"target\"></div>\n<script>\nIMPORT('/parts/hello.html', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nWorks like [IMPORT()](#import) and caches imported HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL. |\n| `expire` | `String` | yes |  | For example `5 minutes` or `session`. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Where to put HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | With `false`, replaces the content of the target. |\n| `preparator` | `Function` | no |  | `function(response, output)` changes the HTML before it is inserted. |\n\nExample: Import and cache\n```html\n<div id=\"target\"></div>\n<script>\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### INC(path, [value], [delay], [reset])\n\nType: `method`\n\nAdds a number to the value on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Number` | no | `1` | The number to add. |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n| `reset` | `Boolean` | no |  | With `true`, the components on the path are also marked as not touched and not modified. |\n\nA missing value or a value that is not a number counts as `0`.\n\nExample: Increase a counter\n```js\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 6\n```\n\n### inDOM(element)\n\nType: `method`\n\nTells whether an element is inside the page body.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | The element. |\n\nReturns: `Boolean` `true`, or `undefined` when the element is outside the body.\n\nExample: Check an element\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(inDOM(document.createElement('div')) === undefined); // true\n```\n\n### isIE\n\nType: `property`\n\n`true` in Internet Explorer.\n\nExample: Read the value\n```js\nconsole.log(typeof(isIE)); // boolean\n```\n\n### isMOBILE\n\nType: `property`\n\n`true` on a mobile device.\n\nExample: Read the value\n```js\nconsole.log(typeof(isMOBILE)); // boolean\n```\n\n### isPRIVATEMODE\n\nType: `property`\n\n`true` when the browser storage is not available.\n\nExample: Read the value\n```js\nconsole.log(typeof(isPRIVATEMODE)); // boolean\n```\n\n### isROBOT\n\nType: `property`\n\n`true` when the user agent looks like a robot.\n\nExample: Read the value\n```js\nconsole.log(typeof(isROBOT)); // boolean\n```\n\n### isSTANDALONE\n\nType: `property`\n\n`true` when the page runs as an installed application.\n\nExample: Read the value\n```js\nconsole.log(typeof(isSTANDALONE)); // boolean\n```\n\n### isTOUCH\n\nType: `property`\n\n`true` on a device with a touch screen.\n\nExample: Read the value\n```js\nconsole.log(typeof(isTOUCH)); // boolean\n```\n\n### jComponent\n\nType: `property`\n\nAnother name of `MAIN`. See [MAIN](../main/).\n\nExample: Read the value\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### LOCALIZE(text)\n\nType: `method`\n\nAdds translations to the dictionary.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | The translations. |\n\nEach line has the form `key : value`, and a line that starts with `//` is skipped. The values are stored in `DEF.dictionary`. The topic is explained in [Localization](../../guides/localization/).\n\nExample: Add translations\n```js\nLOCALIZE('// Greetings\\nhello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### M\n\nType: `property`\n\nA short name of `MAIN`. See [M](../m/).\n\nExample: Read the value\n```js\nconsole.log(M === MAIN); // true\n```\n\n### MACRO(name, declaration)\n\nType: `method`\n\nDeclares a macro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the macro. |\n| `declaration` | `Function` | yes |  | `function(self, element, cls)`. |\n\nThe topic is explained in [Macros](../../guides/macros/), and the object is described in [Macro](../macro/).\n\nExample: Declare a macro\n```js\nMACRO('upper', function(self, element) {\n\tself.setter = value => element.text((value || '').toUpperCase());\n});\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### MAIN\n\nType: `property`\n\nThe main object of the library. See [MAIN](../main/).\n\nExample: Read the value\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### MAKE([target], fn, [update])\n\nType: `method`\n\nBuilds an object in a function.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Object|String` | no |  | An object or a path. Without it, a new object is created. |\n| `fn` | `Function` | yes |  | `function(obj, path, set)`. |\n| `update` | `Boolean` | no | `true` | With `false`, an existing object on the path is written back without resetting its components. |\n\nReturns: `Object` The object.\n\nA string target is a path: the object on the path is changed, or a new one is created and written there. The function receives the object, the path and a function `set(path, value)`.\n\nExample: Build an object\n```js\nvar obj = MAKE(function(o) {\n\to.name = 'Peter';\n});\nconsole.log(obj); // {\"name\":\"Peter\"}\n```\n\nExample: Build an object on a path\n```js\nMAKE('user', function(o, path, set) {\n\to.name = 'Peter';\n\tset('address.city', 'Bratislava');\n});\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"address\":{\"city\":\"Bratislava\"}}\n```\n\n### MIDDLEWARE(name, fn)\n\nType: `method`\n\nDeclares a middleware of routes. See [Routing](../../guides/routing/).\n\n### MODIFIED(path, [flags])\n\nType: `method`\n\nLists the paths of the components that are touched and modified.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it. |\n| `flags` | `String|Array` | no |  | `visible` or `hidden` limits the search to those components. |\n\nReturns: `Array` The paths of the modified components.\n\nExample: List the changed fields\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n});\n```\n\n### MONTHS\n\nType: `property`\n\nThe names of the months.\n\nExample: Read the value\n```js\nconsole.log(MONTHS[11]); // December\n```\n\n### NAV\n\nType: `property`\n\nThe router object. See [Routing](../../guides/routing/).\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` | `Element|jQuery` | yes |  | The element. |\n\nReturns: `Number` The index.\n\nExample: Read the position\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, target, [before])\n\nType: `method`\n\nPuts an element after or before another one.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | The element to move. |\n| `target` | `Element|jQuery` | yes |  | The reference element. |\n| `before` | `Boolean` | no |  | With `true`, puts it before the target. |\n\nExample: Move an element\n```html\n<ul><li id=\"a\">A</li><li>B</li><li id=\"c\">C</li></ul>\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 by one position among its siblings.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | The element. |\n| `up` | `Boolean` | no |  | With `true`, moves it up. Otherwise it moves down. |\n\nExample: Move an element up\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BA\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nA function that does nothing.\n\nExample: Use it as an empty callback\n```js\nconsole.log(NOOP() === undefined); // true\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nTells whether the page is in the background.\n\nReturns: `Boolean` The result.\n\nExample: Check the page\n```js\nconsole.log(typeof(NOTFOCUSED())); // boolean\n```\n\n### NOTIFY(...paths)\n\nType: `method`\n\nRefreshes the components and watchers of exact paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...paths` | `String` | yes |  | One or more paths. |\n\nOnly components whose path is exactly the same are refreshed.\n\nExample: Notify a watcher\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nwindow.user = { name: 'Peter' };\nNOTIFY('user.name');\n```\n\n### NOTMODIFIED(path, [value], [fields])\n\nType: `method`\n\nTells whether a value is the same as the last time it was checked.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, or any key when `value` is given. |\n| `value` | `Object` | no |  | The value to compare. Without it, the value of the path is used. |\n| `fields` | `Array` | no |  | Compares only these fields. |\n\nReturns: `Boolean` `true` when the value has not changed.\n\nThe first check of a path returns `false`. The value is compared by a hash of its JSON form.\n\nExample: Skip work when nothing changed\n```js\nconsole.log(NOTMODIFIED('list', [1, 2])); // false\nconsole.log(NOTMODIFIED('list', [1, 2])); // true\nconsole.log(NOTMODIFIED('list', [1, 2, 3])); // false\n```\n\n### NOW\n\nType: `property`\n\nThe current date, refreshed every minute.\n\nExample: Read the value\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path, [delay])\n\nType: `method`\n\nWrites `null` to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n\n`NULL()` is the same function.\n\nExample: Clear a value\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### NULL(path, [delay])\n\nType: `method`\n\nThe same function as [NUL()](#nul).\n\nExample: Same function\n```js\nconsole.log(NULL === NUL); // true\n```\n\n### OFF(name, [path], [fn])\n\nType: `method`\n\nRemoves handlers of an event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `path` | `String|Function` | no |  | The path, or the handler when no path is needed. |\n| `fn` | `Function` | no |  | The handler. |\n\nSeveral events can be separated by `+`. The form `owner#name` removes the handlers of that owner, and `owner#` removes all of them.\n\nExample: Remove a handler\n```js\nvar fn = () => console.log('never');\nON('ping', fn);\nOFF('ping', fn);\nconsole.log(EMIT('ping')); // false\n```\n\nExample: Remove the handlers of an owner\n```js\nON('shop#ping', () => console.log('never'));\nOFF('shop#');\nconsole.log(EMIT('ping')); // false\n```\n\n### ON(name, [path], fn, [init])\n\nType: `method`\n\nRegisters a handler of an event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `path` | `String` | no |  | The path, for the event `watch`. |\n| `fn` | `Function` | yes |  | The handler. |\n| `init` | `Boolean` | no |  | With the event `watch`, the handler is also called immediately. |\n\nThe name can list several events separated by a space or ` + `. A name that starts with `^` puts the handler first. The form `owner#name` assigns the handler to an owner, so [OFF()](#off) can remove it later. The name `@flag myflag` reacts to a custom flag on a path.\n\nThe event `watch` works like [WATCH()](#watch) and uses `path` and `init`. The events of the library are listed in [Events](../events/).\n\nExample: Listen to a custom event\n```js\nON('cart.add', function(id, count) {\n\tconsole.log(id, count); // 15 2\n});\nEMIT('cart.add', 15, 2);\n```\n\nExample: React to a custom flag\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.name Peter\n});\nSET('user.name @saved', 'Peter');\n```\n\n### OPT([obj], fn)\n\nType: `method`\n\nBuilds an options object with nested paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | no |  | The object to fill. Without it, a new object is created. |\n| `fn` | `Function` | yes |  | `function(set, scope)`. |\n\nReturns: `Object` The object.\n\nThe function receives `set(path, value)` and `scope(prefix)`, which adds a prefix to the next paths.\n\nExample: Build options\n```js\nvar options = OPT(function(set, scope) {\n\tset('title', 'Users');\n\tscope('grid');\n\tset('limit', 20);\n});\nconsole.log(options); // {\"title\":\"Users\",\"grid\":{\"limit\":20}}\n```\n\n### PARSE(value, [date])\n\nType: `method`\n\nParses JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The JSON or a selector. |\n| `date` | `Boolean` | no | `DEF.jsondate` | Converts ISO dates to `Date` objects. |\n\nReturns: `Object` The value.\n\nA string that starts with `#` or `.` is a selector of an element with JSON. Invalid JSON returns `null`, and an object is returned as it is.\n\nExample: Parse JSON\n```js\nconsole.log(PARSE('{\"id\":5}').id); // 5\nconsole.log(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d instanceof Date); // true\nconsole.log(PARSE('wrong')); // null\n```\n\n### PARSER(fn, [prepend])\n\nType: `method`\n\nRegisters a global parser of component values.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | With `true`, the parser runs first. |\n\nReturns: `Object` The parsed value, when the function runs the parsers.\n\nThe function must always return the value. The built-in parser converts the types `number`, `currency`, `float`, `boolean`, `bool`, `date` and `datetime`. `PARSER(value, path, type, [format])` runs all registered parsers.\n\nExample: Parse a value\n```js\nconsole.log(PARSER('1 200.5', 'price', 'number')); // 1200.5\nconsole.log(PARSER('on', 'active', 'boolean')); // true\n```\n\n### PLUGIN(name, [fn], [init], [done])\n\nType: `method`\n\nDeclares a plugin, or returns an existing one.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the plugin. |\n| `fn` | `Function` | no |  | `function(exports)`. |\n| `init` | `Function|String` | no |  | Runs before the declaration. A string lists middleware names. |\n| `done` | `Function` | no |  | Called when the plugin is ready. |\n\nReturns: `Plugin` The plugin.\n\nThe topic is explained in [Plugins](../../guides/plugins/), and the object is described in [Plugin](../plugin/).\n\nExample: Declare a plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.count = 5;\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.users.count); // 5\n}, 500);\n```\n\n### PLUGINABLE(name, fn, [init])\n\nType: `method`\n\nRegisters a plugin that is created by its first call.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the plugin. |\n| `fn` | `Function|String` | yes |  | The declaration or a URL. |\n| `init` | `Function|String` | no |  | Runs before the declaration. |\n\nThe declaration can also be a URL of a file that declares the plugin.\n\nExample: Create a plugin on demand\n```js\nPLUGINABLE('reports', function(exports) {\n\texports.open = function() {\n\t\tconsole.log('opened'); // opened\n\t};\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.reports == null); // true\n\tEXEC('reports/open');\n}, 500);\n```\n\n### PLUGINS\n\nType: `property`\n\nAn object with all created plugins, by name.\n\nExample: Read a plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.limit = 10;\n});\nsetTimeout(function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n}, 500);\n```\n\n### PREF\n\nType: `property`\n\nStored user preferences. See [PREF](../pref/).\n\nExample: Read the value\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.theme); // dark\n```\n\n### PUSH(path, value, [delay], [reset])\n\nType: `method`\n\nAdds a value to the array on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Object|Array` | yes |  | The item or the items to add. |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n| `reset` | `Boolean` | no |  | With `true`, the components on the path are also marked as not touched and not modified. |\n\nAn array as the value adds each of its items. If the path holds no array, a new one is created. A path that starts with `^` adds to the beginning. As with [SET()](#set), the first argument can be a request and `value` the target path.\n\nExample: Add items\n```js\nPUSH('tags', 'a');\nPUSH('tags', ['b', 'c']);\nPUSH('^tags', 'first');\nconsole.log(GET('tags')); // [\"first\",\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], obj)\n\nType: `method`\n\nAdds an object to a URL as a query string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | The URL, optionally with a method. |\n| `obj` | `Object` | yes |  | The values. |\n\nReturns: `String` The URL.\n\nEmpty values are skipped, arrays are joined with a comma, and dates use the ISO format.\n\nExample: Build a URL\n```js\nconsole.log(QUERIFY('GET /users/', { page: 2, tags: ['a', 'b'] })); // GET /users/?page=2&tags=a%2Cb\nconsole.log(QUERIFY({ q: 'x y' })); // ?q=x%20y\n```\n\n### QUEUE([name], fn)\n\nType: `method`\n\nRuns functions one after another.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | The name of the queue. |\n| `fn` | `Function` | yes |  | `function(next, pending)`. |\n\nReturns: `Number` The number of waiting items.\n\nThe function receives `next` and the number of waiting items. The next item starts after `next()` is called.\n\nExample: Run in order\n```js\nQUEUE('tasks', function(next) {\n\tsetTimeout(next, 50);\n});\nQUEUE('tasks', function(next, pending) {\n\tconsole.log('second', pending); // second 0\n\tnext();\n});\n```\n\n### RECONFIGURE(selector, value)\n\nType: `method`\n\nChanges the configuration of all matching components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | A selector as in [FIND()](#find). |\n| `value` | `Object|String` | yes |  | The new configuration. |\n\nExample: Change the configuration\n```js\nON('ready', function() {\n\tRECONFIGURE('box', { size: 10 });\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### REDIRECT(url)\n\nType: `method`\n\nNavigates to a URL. See [Routing](../../guides/routing/).\n\n### REMOVECACHE(key)\n\nType: `method`\n\nRemoves a value from the browser cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The key. |\n\nExample: Remove a value\n```js\nCACHE('profile', 'Peter', '1 day');\nREMOVECACHE('profile');\nconsole.log(CACHE('profile') === undefined); // true\n```\n\n### REPEAT([condition], process, delay, [init])\n\nType: `method`\n\nRuns a function repeatedly.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | no |  | The condition. |\n| `process` | `Function` | yes |  | `function(counter, scope)`. |\n| `delay` | `Number` | yes |  | The delay in milliseconds. |\n| `init` | `Boolean` | no |  | With `true`, the first run starts immediately. |\n\nThe condition is a function or a path, and the run is skipped while it is not met. With the form `path__expression`, the expression receives the variable `value`. While the page is in the background, nothing runs unless `DEF.repeatfocus` is `false`.\n\nExample: Run every 100 ms\n```js\nREPEAT(function(counter) {\n\tif (counter === 3)\n\t\tconsole.log('third run'); // third run\n}, 100);\n```\n\n### REPO\n\nType: `property`\n\nAn empty object for your own shared data.\n\nExample: Read the value\n```js\nREPO.items = [1, 2];\nconsole.log(REPO.items.length); // 2\n```\n\n### RESET(path, [delay])\n\nType: `method`\n\nMarks the components on a path as not touched and not modified, and validates them again.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it. |\n| `delay` | `Number` | no |  | A delay in milliseconds. |\n\nExample: Reset a form\n```js\nON('ready', function() {\n\tSET('form.name', 'Peter');\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n\tRESET('form.*');\n\tconsole.log(MODIFIED('form.*').length); // 0\n});\n```\n\n### RETURN(command, [multiple])\n\nType: `method`\n\nReads a property of a component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `command` | `String` | yes |  | The selector and the property. |\n| `multiple` | `Boolean` | no |  | With `true`, reads from all matching components. |\n\nReturns: `Object|Array` The value, or an array with `multiple`.\n\nThe command has the form `selector/property`.\n\nExample: Read a property\n```js\nON('ready', function() {\n\tconsole.log(RETURN('box/title')); // Box\n\tconsole.log(RETURN('box/title', true)); // [\"Box\"]\n});\n```\n\n### REWRITE(path, value, [type])\n\nType: `method`\n\nWrites a value without refreshing components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | The new value. |\n| `type` | `Number` | no |  | The change type passed to watchers. |\n\nData bindings and watchers still run. Use the `@nowatch` flag to skip the watchers.\n\nExample: Write without a component refresh\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nREWRITE('user.name', 'Peter');\n```\n\n### REWRITE2(path, value, [type])\n\nType: `method`\n\nWrites a value without refreshing components or data bindings.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | The new value. |\n| `type` | `Number` | no |  | The change type passed to watchers. |\n\nWatchers still run.\n\nExample: Write without bindings\n```js\nREWRITE2('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\n```\n\n### ROUTE(url, fn, [middleware], [init])\n\nType: `method`\n\nDeclares a route. See [Routing](../../guides/routing/).\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\nThe options:\n\n| Option | Type | Description |\n| --- | --- | --- |\n| `orientation` | String | `x` or `y`. Without it, both directions |\n| `visibleX`, `visibleY` | Boolean | Keeps the scrollbar visible |\n| `native` | Boolean | Uses the scrollbar of the browser |\n| `wrap` | Boolean | With `false`, the content is not wrapped |\n| `controls` | jQuery | The element for the scrollbar controls |\n| `shadow` | Boolean | Adds shadows at the edges |\n| `padding` | Number | The padding of the bars. Default `5` |\n| `minsize` | Number | The smallest size of a bar. Default `50` |\n| `thickness` | Number | The thickness of a bar. Default `10` |\n| `margin`, `marginX`, `marginY` | Number | The margins |\n| `offsetX`, `offsetY` | Number | Added to the size of the view |\n| `parent` | String or Element | Takes the size from this parent |\n| `autoresize` | Boolean | With `false`, the size is not checked on resize |\n| `interval` | Number | The interval of the size check |\n| `onscroll`, `onidle`, `onresize` | Function | Handlers that receive the scrollbar |\n\nThe returned object has the methods `scrollTop([value])`, `scrollLeft([value])`, `scrollBottom([value])`, `scrollRight([value])`, `scroll(x, y)`, `resize()`, `check()`, `sync(element, [offset])`, `unsync()` and `destroy()`.\n\nExample: Create a scrollbar\n```html\n<div id=\"box\" style=\"height:100px\"><div style=\"height:500px\"></div></div>\n<script>\nvar scrollbar = SCROLLBAR($('#box'), { orientation: 'y' });\nconsole.log(typeof(scrollbar.scrollTop)); // function\nconsole.log(M.scrollbars.length); // 1\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nReturns the width of the browser scrollbar in pixels.\n\nReturns: `Number` The width.\n\nExample: Read the width\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(target, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function or writes a value, depending on the target.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Function|String` | yes |  | A function, a method or a 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\nA function is called. A string with `/`, or a path that holds a function, goes to [EXEC()](#exec). Any other string is a path, and the first argument is written to it.\n\nExample: Function or path\n```js\nSEEX(value => console.log(value), 1); // 1\nSEEX('result.value', 2);\nconsole.log(GET('result.value')); // 2\n```\n\n### SET(path, value, [delay], [reset])\n\nType: `method`\n\nWrites a value to a path and refreshes everything bound to it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | The new value. |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n| `reset` | `Boolean` | no |  | With `true`, the components on the path are also marked as not touched and not modified. |\n\nComponents, bindings and watchers on the path are refreshed. The third argument can also be `true`, which resets the state of the components right away.\n\nA path that starts with `+` adds the value to an array like [PUSH()](#push). A path that starts with `~` merges it like [EXT()](#ext). Flags can follow the path: see [Flags and path modifiers](../../guides/flags/).\n\nWhen the first argument is a request such as `GET /api/users/`, the response is written to the path given as `value`.\n\nExample: Write a value\n```js\nSET('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\nExample: Delay the write\n```js\nSET('search', 'first', 100);\nSET('search', 'second', 100);\nsetTimeout(function() {\n\tconsole.log(GET('search')); // second\n}, 300);\n```\n\nExample: Store a response\n```js\nSET('GET /api/users/', 'users.response');\nsetTimeout(function() {\n\tconsole.log(GET('users.response.url')); // /api/users/\n}, 200);\n```\n\n### SETTER(selector, method, [...args])\n\nType: `method`\n\nCalls a method of all matching components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | A selector as in [FIND()](#find). |\n| `method` | `String` | yes |  | The name of the method. |\n| `...args` | `Object` | no |  | The arguments of the method. |\n\nThe selector and the method can be joined as `selector/method`. With `true` as the first argument, the call waits for the component. A selector that starts with `!` does not start a lazy component.\n\nExample: Call a method\n```js\n// The component logs 'Hello ' + name\nON('ready', function() {\n\tSETTER('box', 'hello', 'Peter');\n\tSETTER('box/hello', 'Anna');\n});\n```\n\n### setTimeout2(name, fn, delay, [limit], [arg])\n\nType: `method`\n\nStarts a named timer and cancels the previous timer of the same name.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the timer. |\n| `fn` | `Function` | yes |  | The function. |\n| `delay` | `Number` | yes |  | The delay in milliseconds. |\n| `limit` | `Number` | no |  | How many times the timer can be postponed. |\n| `arg` | `Object` | no |  | The argument of the function. |\n\nReturns: `String` The name of the timer.\n\nWith a limit, the timer is postponed at most that many times, so the function still runs during constant calls.\n\nExample: Keep only the last call\n```js\nfunction search(value) {\n\tconsole.log(value); // last\n}\nsetTimeout2('search', search, 50, null, 'first');\nsetTimeout2('search', search, 50, null, 'last');\n```\n\n### STOPDEBUG()\n\nType: `method`\n\nKeeps pausing the browser debugger while the developer tools are open.\n\nThe function repeats itself every 5 seconds and cannot be stopped.\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 | `DEF.jsoncompress` | Compresses the output. |\n| `fields` | `Array|Object|Function` | no |  | An array of allowed fields, an object with `field: false`, or `function(key, value)`. |\n| `encrypt` | `Boolean` | no |  | Encrypts the output with the key from `DEF.secret()`. |\n\nReturns: `String` The JSON.\n\nCompression trims strings and removes empty strings, `false` and `null`.\n\nExample: Serialize a value\n```js\nconsole.log(STRINGIFY({ a: 1, b: '', c: false }, true)); // {\"a\":1}\nconsole.log(STRINGIFY({ a: 1, b: 2 }, false, ['b'])); // {\"b\":2}\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. The element gets the id `css` plus this value. |\n| `selector` | `String` | no |  | A selector that wraps the rules. |\n\nAn existing style with the same identifier is replaced. A selector is added before every rule. `CSS()` is the same function.\n\nExample: Add scoped CSS\n```js\nSTYLE('b { color: red }', 'mystyle', '#panel');\nconsole.log($('#cssmystyle').html()); // #panel b{ color: red }\n```\n\n### Ta\n\nType: `property`\n\nA short name of `Tangular`.\n\nExample: Read the value\n```js\nconsole.log(Ta === Tangular); // true\n```\n\n### Tangular\n\nType: `property`\n\nThe template engine. See [Templates with Tangular](../../guides/tangular/).\n\nExample: Read the value\n```js\nconsole.log(Tangular.render('Hello {{ name }}', { name: 'Peter' })); // Hello Peter\n```\n\n### TAPI(name, [data], [callback])\n\nType: `method`\n\nCalls an API with [DAPI()](#dapi) when `DEF.api` is set, and with [WAPI()](#wapi) otherwise.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the schema. |\n| `data` | `Object` | no |  | The data. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, or a path. |\n\nReturns: `Object|Promise` The result of the selected function.\n\nExample: Select the transport\n```js\nDEF.api = '/api/';\nTAPI('users_list', null, function(response) {\n\tconsole.log(response.url); // /api/\n});\n```\n\n### TEMP\n\nType: `property`\n\nAn object for temporary data.\n\nThe library replaces it with an empty object every five minutes.\n\nExample: Read the value\n```js\nTEMP.value = 5;\nconsole.log(TEMP.value); // 5\n```\n\n### Thelpers\n\nType: `property`\n\nThe helpers of the template engine. See [Tangular helpers](../tangular-helpers/).\n\nExample: Read the value\n```js\nconsole.log(typeof(Thelpers)); // object\n```\n\n### TOGGLE(path, [delay], [reset])\n\nType: `method`\n\nWrites the opposite boolean value to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n| `reset` | `Boolean` | no |  | With `true`, the components on the path are also marked as not touched and not modified. |\n\nExample: Switch a value\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### TRANSLATE(text)\n\nType: `method`\n\nReplaces every `@(text)` with its translation.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | The text. |\n\nReturns: `String` The translated text.\n\nThe key in `DEF.dictionary` is `HASH(text).toString(36)`, optionally with the prefix `T`. Text without a translation stays in the original language.\n\nExample: Translate text\n```js\nDEF.dictionary[HASH('Hello').toString(36)] = 'Ahoj';\nconsole.log(TRANSLATE('@(Hello), @(Peter)')); // Ahoj, Peter\n```\n\n### UNAUTHORIZED(...roles)\n\nType: `method`\n\nTells whether the current user lacks all of the given roles.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...roles` | `String` | yes |  | The roles. |\n\nReturns: `Boolean` `true` when the user has none of the roles.\n\nThe user is read from `window.user`. The fields `sa` and `su` allow everything, and the roles come from `permissions` or `roles`, as an array or an object.\n\nExample: Check a role\n```js\nwindow.user = { roles: ['editor'] };\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [fn])\n\nType: `method`\n\nRemoves a watcher.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The watched path. |\n| `fn` | `Function` | no |  | The function given to [WATCH()](#watch). |\n\nWithout a function, all watchers of the path are removed.\n\nExample: Stop watching\n```js\nvar count = 0;\nvar fn = () => count++;\nWATCH('value', fn);\nSET('value', 1);\nUNWATCH('value', fn);\nSET('value', 2);\nconsole.log(count); // 1\n```\n\n### UPD(path, [delay], [reset])\n\nType: `method`\n\nTells the library that the value on a path has changed.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the value. See [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | A number of 10 or more delays the change by that many milliseconds. A smaller number is the change type: `1` manual, `2` input, `3` default. |\n| `reset` | `Boolean` | no |  | With `true`, the components on the path are also marked as not touched and not modified. |\n\nUse it after changing an object directly. Components are refreshed and watchers are called. `UPDATE()` is the same function. The second argument can also be `true`, which resets the state of the components.\n\nExample: Refresh after a direct change\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nUPD('user.name');\n```\n\n### UPDATE(path, [delay], [reset])\n\nType: `method`\n\nThe same function as [UPD()](#upd).\n\nExample: Same function\n```js\nconsole.log(UPDATE === UPD); // true\n```\n\n### UPLOAD(url, data, [callback], [delay], [progress])\n\nType: `method`\n\nUploads data to a server.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL, optionally with a method. |\n| `data` | `FormData|Object` | yes |  | The data. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, or a path. |\n| `delay` | `Number` | no |  | Waits this many milliseconds before sending. |\n| `progress` | `Function|String` | no |  | `function(percentage)`, or a path. |\n\nReturns: `Promise` Only when no callback is given.\n\nThe default method is `POST`. `FormData` is sent as it is, and anything else as JSON. Without a callback, the function returns a Promise. `progress` can be the fourth argument when no delay is needed.\n\nExample: Upload a file\n```js\nvar data = new FormData();\ndata.append('name', 'photo.jpg');\nUPLOAD('/api/upload/', data, function(response) {\n\tconsole.log(response.url); // /api/upload/\n});\n```\n\n### VALID(path, [flags])\n\nType: `method`\n\nTells whether no component on a path is invalid.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with `.*` for everything below it. |\n| `flags` | `String|Array` | no |  | `visible` or `hidden` limits the check to those components. |\n\nReturns: `Boolean` The result.\n\nUnlike [CAN()](#can), it does not look at whether the components are touched.\n\nExample: Check a form\n```js\nON('ready', function() {\n\tconsole.log(VALID('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tconsole.log(VALID('form.*')); // true\n});\n```\n\n### VBIND(html)\n\nType: `method`\n\nCreates a virtual binder from HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | The HTML with bindings. |\n\nReturns: `VBinder` The virtual binder.\n\nThe object is described in [Virtual binder](../vbinder/), and the topic in [Virtual bindings](../../guides/virtual-bindings/).\n\nExample: Bind a detached element\n```js\nvar binder = VBIND('<div><span data-bind=\"name__text\"></span></div>');\nbinder.set({ name: 'Peter' });\nconsole.log(binder.element.find('span').text()); // Peter\n```\n\n### VBINDARRAY(html, element)\n\nType: `method`\n\nRenders an array with a virtual binder for each item.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | The HTML of one item. |\n| `element` | `Element|jQuery|Component` | yes |  | The parent element. |\n\nReturns: `Object` An object with the methods `set()`, `get()`, `upd()` and `remove()`.\n\nThe topic is explained in [Virtual bindings](../../guides/virtual-bindings/).\n\nExample: Render a list\n```html\n<ul id=\"list\"></ul>\n<script>\nvar list = VBINDARRAY('<li data-bind=\"name__text\"></li>', $('#list'));\nlist.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log($('#list').text()); // PeterAnna\n</script>\n```\n\n### VERSION(...items)\n\nType: `method`\n\nSelects the version of components that are used without a version.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...items` | `String` | yes |  | The components and their versions. |\n\nEach item has the form `name@version`, and one string can list several items separated by a comma.\n\nExample: Select a version\n```html\n<ui-component name=\"tag\"></ui-component>\n<script>\nCOMPONENT('tag@2', function(self) {\n\tself.make = () => self.element.text('two');\n});\nVERSION('tag@2');\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // two\n});\n</script>\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nTells whether an element is in the visible height of the window.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | The element. |\n| `threshold` | `Number` | no | `0` | A margin in pixels. |\n| `mode` | `String` | no | `visible` | `visible`, `above` or `below`. |\n\nReturns: `Boolean` The result.\n\nExample: Check an element\n```html\n<div id=\"box\">Box</div>\n<script>\nconsole.log(VISIBLE($('#box'))); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nA short name of `window`.\n\nExample: Read the value\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback, [interval], [timeout])\n\nType: `method`\n\nWaits until a condition is met.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | The function or the path to check. |\n| `callback` | `Function` | yes |  | `function(err, again)`. |\n| `interval` | `Number` | no | `500` | The interval of the checks in milliseconds. |\n| `timeout` | `Number` | no |  | The longest wait in milliseconds. |\n\nThe condition is a function or a path. The callback receives an error after a timeout, and a function that starts the wait again. Without a timeout, the wait never ends by itself.\n\nExample: Wait for a value\n```js\nWAIT('app.ready', function() {\n\tconsole.log(GET('app.ready')); // true\n}, 50);\nsetTimeout(() => SET('app.ready', true), 100);\n```\n\nExample: Stop after a timeout\n```js\nWAIT(() => false, function(err) {\n\tconsole.log(err.message); // Timeout.\n}, 50, 200);\n```\n\n### WAPI([name], [data], [callback], [timeout])\n\nType: `method`\n\nCalls an API over the WebSocket connection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | no |  | The name of the schema, or the connection options. |\n| `data` | `Object` | no |  | The data. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, or a path. |\n| `timeout` | `Number` | no | `10000` | The timeout in milliseconds. |\n\nReturns: `Object|Promise` The connection, or a Promise.\n\nAn object as the first argument opens the connection like [WAPI_INIT()](#wapi-init). Without arguments, the function returns the open connection. Without a callback, it returns a Promise. The default timeout of a call is 10 seconds.\n\nExample: Call over a socket\n```js\nWAPI({ url: '/api/' });\nWAPI('users_list', null, function(response) {\n\tconsole.log(response.schema); // users_list\n});\n```\n\n### WAPI_INIT(options)\n\nType: `method`\n\nOpens the WebSocket connection used by [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | The connection options. |\n\nReturns: `Object` The options object with the added methods.\n\nThe options are `url`, `reconnect` (a delay in milliseconds, or `false`), `expire` (reconnects after this time), `callback` (called once after the first connection attempt), and the handlers `open`, `close(e)` and `message(data)`.\n\nThe returned object has the methods `send(name, data, callback, [timeout])`, `on(name, fn)` for the events `open`, `close`, `message` and `reconnect`, `emit(name, ...)` and `pause(is)`.\n\nExample: Open a connection\n```js\nWAPI_INIT({\n\turl: '/api/',\n\topen: function() {\n\t\tconsole.log('connected'); // connected\n\t}\n});\nconsole.log(typeof(WAPI().send)); // function\n```\n\n### WARN(...args)\n\nType: `method`\n\nWrites a warning to the console.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...args` | `Object` | yes |  | The values to write. |\n\nExample: Write a warning\n```js\nWARN('Disk is full');\nconsole.log(typeof(WARN)); // function\n```\n\n### WATCH(path, fn, [init])\n\nType: `method`\n\nCalls a function when the value on a path changes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path to watch. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n| `init` | `Boolean` | no |  | With `true`, the function is also called immediately. |\n\nThe function receives the changed path, the value and the change type: `0` initial call, `1` manual, `2` input, `3` default. A path of `users.*` also reacts to everything below `users`. Several paths can be separated by a space, and a path that starts with `^` runs before the other watchers.\n\nExample: React to a change\n```js\nWATCH('user.name', function(path, value, type) {\n\tconsole.log(path, value, type); // user.name Peter 1\n});\nSET('user.name', 'Peter');\n```\n\nExample: Call it immediately\n```js\nSET('count', 5);\nWATCH('count', function(path, value, type) {\n\tconsole.log(value, type); // 5 0\n}, true);\n```\n\n### WATCHONCE(path, fn)\n\nType: `method`\n\nCalls a function on the next change of a path only.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path to watch. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n\nExample: React once\n```js\nWATCHONCE('count', function(path, value) {\n\tconsole.log(value); // 1\n});\nSET('count', 1);\nSET('count', 2);\n```\n\n### WH\n\nType: `property`\n\nThe height of the window in pixels.\n\nExample: Read the value\n```js\nconsole.log(typeof(WH)); // number\n```\n\n### WIDTH([element])\n\nType: `method`\n\nReturns the display size of the window or an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | The element. |\n\nReturns: `String` `xs`, `sm`, `md` or `lg`.\n\nThe limits are in `DEF.devices`.\n\nExample: Read the size of an element\n```html\n<div id=\"box\" style=\"width:1000px\"></div>\n<script>\nconsole.log(WIDTH($('#box'))); // md\n</script>\n```\n\n### WORKFLOW(declaration, [tasks], [callback])\n\nType: `method`\n\nRuns named steps that hand over a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `declaration` | `Function` | yes |  | `function($)`. |\n| `tasks` | `Object` | no |  | The steps by name. |\n| `callback` | `Function` | no |  | `function(value, err, $)`. |\n\nReturns: `Object` The workflow.\n\nThe object passed to the declaration and to every step has these members:\n\n| Member | Description |\n| --- | --- |\n| `push(name, fn)` | Adds a step: `function($, value)` |\n| `next(name, [value])` | Runs a step. An unknown name ends the workflow |\n| `next2(name)` | Returns a callback that runs the step |\n| `done([value])` | Calls the final callback with the value |\n| `invalid(err)` | Reports an error to `error` or to the final callback |\n| `callback(fn)` | Replaces the final callback |\n| `clone()` | Creates a workflow with the same steps |\n| `destroy()` | Ends the workflow |\n| `value`, `current`, `prev` | The value, the current step and the previous step |\n\nExample: Run two steps\n```js\nWORKFLOW(function($) {\n\t$.push('load', ($, value) => $.next('save', value + 1));\n\t$.push('save', ($, value) => $.done(value * 2));\n\t$.next('load', 1);\n}, function(value) {\n\tconsole.log(value); // 4\n});\n```\n\n### WW\n\nType: `property`\n\nThe width of the window in pixels.\n\nExample: Read the value\n```js\nconsole.log(typeof(WW)); // number\n```\n","entries":[{"type":"method","name":"ACMD()","signature":"ACMD(name, [...args])","since":"","deprecated":false},{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"ADD()","signature":"ADD(value, [element], [config], [content])","since":"","deprecated":false},{"type":"method","name":"AEXEC()","signature":"AEXEC(path, [...args])","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], [callback], [delay])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHE()","signature":"AJAXCACHE(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHEREVIEW()","signature":"AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCONFIG()","signature":"AJAXCONFIG(name, fn)","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BIND()","signature":"BIND(path)","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(name, 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, [rebind])","since":"","deprecated":false},{"type":"method","name":"CAN()","signature":"CAN(path, [flags])","since":"","deprecated":false},{"type":"method","name":"CHANGE()","signature":"CHANGE(path, [value])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, callback)","since":"","deprecated":false},{"type":"method","name":"CL_INIT()","signature":"CL_INIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [nopath])","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], [e])","since":"","deprecated":false},{"type":"method","name":"COMPILE()","signature":"COMPILE([container])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], declaration, [dependencies])","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":"method","name":"DAPI()","signature":"DAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"method","name":"DEBUG()","signature":"DEBUG()","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DEFAULT()","signature":"DEFAULT(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"DISABLED()","signature":"DISABLED(path, [flags])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [...args])","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(value, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, [flags], [highlight])","since":"","deprecated":false},{"type":"method","name":"EVALUATE()","signature":"EVALUATE(path, expression, [nopath])","since":"","deprecated":false},{"type":"method","name":"EXE()","signature":"EXE([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXT()","signature":"EXT(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTEND()","signature":"EXTEND(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], declaration)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [many], [nocache], [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(expression)","since":"","deprecated":false},{"type":"method","name":"FORMATTER()","signature":"FORMATTER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE([delay])","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [scope])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([size])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value, [unsigned])","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"IMPORTCACHE()","signature":"IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value], [delay], [reset])","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":"method","name":"MACRO()","signature":"MACRO(name, declaration)","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"method","name":"MAKE()","signature":"MAKE([target], fn, [update])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, fn)","since":"","deprecated":false},{"type":"method","name":"MODIFIED()","signature":"MODIFIED(path, [flags])","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"property","name":"NAV","signature":"NAV","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, target, [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":"method","name":"NOTIFY()","signature":"NOTIFY(...paths)","since":"","deprecated":false},{"type":"method","name":"NOTMODIFIED()","signature":"NOTMODIFIED(path, [value], [fields])","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"NULL()","signature":"NULL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [path], [fn])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, [path], fn, [init])","since":"","deprecated":false},{"type":"method","name":"OPT()","signature":"OPT([obj], fn)","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value, [date])","since":"","deprecated":false},{"type":"method","name":"PARSER()","signature":"PARSER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [fn], [init], [done])","since":"","deprecated":false},{"type":"method","name":"PLUGINABLE()","signature":"PLUGINABLE(name, fn, [init])","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, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], obj)","since":"","deprecated":false},{"type":"method","name":"QUEUE()","signature":"QUEUE([name], fn)","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT(url)","since":"","deprecated":false},{"type":"method","name":"REMOVECACHE()","signature":"REMOVECACHE(key)","since":"","deprecated":false},{"type":"method","name":"REPEAT()","signature":"REPEAT([condition], process, delay, [init])","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path, [delay])","since":"","deprecated":false},{"type":"method","name":"RETURN()","signature":"RETURN(command, [multiple])","since":"","deprecated":false},{"type":"method","name":"REWRITE()","signature":"REWRITE(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"REWRITE2()","signature":"REWRITE2(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"ROUTE()","signature":"ROUTE(url, fn, [middleware], [init])","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(target, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, fn, delay, [limit], [arg])","since":"","deprecated":false},{"type":"method","name":"STOPDEBUG()","signature":"STOPDEBUG()","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":"property","name":"Ta","signature":"Ta","since":"","deprecated":false},{"type":"property","name":"Tangular","signature":"Tangular","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"property","name":"Thelpers","signature":"Thelpers","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...roles)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [fn])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPDATE()","signature":"UPDATE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPLOAD()","signature":"UPLOAD(url, data, [callback], [delay], [progress])","since":"","deprecated":false},{"type":"method","name":"VALID()","signature":"VALID(path, [flags])","since":"","deprecated":false},{"type":"method","name":"VBIND()","signature":"VBIND(html)","since":"","deprecated":false},{"type":"method","name":"VBINDARRAY()","signature":"VBINDARRAY(html, element)","since":"","deprecated":false},{"type":"method","name":"VERSION()","signature":"VERSION(...items)","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, [interval], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI()","signature":"WAPI([name], [data], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI_INIT()","signature":"WAPI_INIT(options)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...args)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, fn, [init])","since":"","deprecated":false},{"type":"method","name":"WATCHONCE()","signature":"WATCHONCE(path, fn)","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"method","name":"WORKFLOW()","signature":"WORKFLOW(declaration, [tasks], [callback])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammaB9IM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/globals/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Globale Funktionen","summary":"Die Funktionen und Objekte, die jComponent dem window-Objekt hinzufügt.","markdown":"---\ntitle: Globale Funktionen\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/globals/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Globale Funktionen\n\n> Die Funktionen und Objekte, die jComponent dem window-Objekt hinzufügt.\n\njComponent fügt `window` diese Funktionen und Objekte hinzu, sodass du sie überall ohne Import verwenden kannst. Wie Paths funktionieren, erfährst du zuerst unter [Paths](../../guides/paths/).\n\n## API\n\n### ACMD(name, [...args])\n\nType: `method`\n\nErstellt eine Funktion, die später [CMD()](#cmd) aufruft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Befehls. |\n| `...args` | `Object` | no |  | Die ersten Argumente. |\n\nReturns: `Function` Die aufzurufende Funktion.\n\nDas Argument der erstellten Funktion wird als letztes Argument des Befehls angehängt.\n\nExample: Als Callback verwenden\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nACMD('refresh')(1);\n```\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nBereitet importierten Text für einen Path und eine Kennung vor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Wert für `~PATH~` und `CLASS`. |\n| `id` | `String` | yes |  | Der Wert für `~ID~`. |\n| `text` | `String` | yes |  | Der Text. |\n\nReturns: `String` Der geänderte Text.\n\nDer Text wird übersetzt, `--name--`-Variablen werden ersetzt, `~CDN~` wird zu `DEF.cdn`, `~PATH~` und `CLASS` werden zum Path, und `~ID~` wird zur Kennung.\n\nExample: Die Markierungen ersetzen\n```js\nconsole.log(ADAPT('users', 'form1', '~PATH~ and ~ID~')); // users and form1\n```\n\n### ADD(value, [element], [config], [content])\n\nType: `method`\n\nFügt der Seite eine Komponente hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object|Array` | yes |  | Die Komponente. |\n| `element` | `Element|jQuery|Component` | no | `document.body` | Das übergeordnete Element. |\n| `config` | `Object|String` | no |  | Die Konfiguration. |\n| `content` | `String` | no |  | Das innere HTML. |\n\nEin String hat die Form `name__path__config`. Ein führendes `!` überspringt die Komponente, wenn sie bereits deklariert ist. Ein Objekt kann die Felder `name`, `path`, `config`, `element` und `prepend` haben. Ein Array fügt mehrere Komponenten hinzu.\n\nExample: Eine Komponente hinzufügen\n```js\nADD('box__data.title__size:10');\nsetTimeout(function() {\n\tconsole.log(FIND('box').config.size); // 10\n}, 1200);\n```\n\n### AEXEC(path, [...args])\n\nType: `method`\n\nErstellt eine Funktion, die später [EXEC()](#exec) aufruft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Das Ziel. |\n| `...args` | `Object` | no |  | Die ersten Argumente. |\n\nReturns: `Function` Die aufzurufende Funktion.\n\nDas Argument der erstellten Funktion wird als letztes Argument angehängt.\n\nExample: Als Callback verwenden\n```js\nwindow.save = value => console.log(value); // 5\nAEXEC('save')(5);\n```\n\n### AJAX(url, [data], [callback], [delay])\n\nType: `method`\n\nSendet eine HTTP-Anfrage.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Methode und die URL. |\n| `data` | `Object|String` | no |  | Die Daten. Eine `GET`-Anfrage sendet sie im Query-String. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` oder ein Path. |\n| `delay` | `Number` | no |  | Wartet vor dem Senden so viele Millisekunden. |\n\nReturns: `Promise` Nur wenn kein Callback angegeben ist.\n\nDie URL hat die Form `METHOD /path/`. Danach können weitere Einträge folgen, getrennt durch ein Leerzeichen:\n\n| Eintrag | Bedeutung |\n| --- | --- |\n| `!METHOD` | Sendet Cookies mit der Anfrage |\n| `{ \"Name\": \"value\" }` | Header der Anfrage |\n| `<5 minutes>` | Speichert die Antwort im Cache, wie bei [AJAXCACHE()](#ajaxcache) |\n| `(name)` | Wendet die Einstellungen aus [AJAXCONFIG()](#ajaxconfig) an |\n| `repeat` | Wiederholt die Anfrage, wenn der Server nicht verfügbar ist |\n| `cancel` | Bricht die vorherige, noch nicht abgeschlossene Anfrage an dieselbe URL ab |\n| `urlencoded` | Sendet die Daten als URL-kodiertes Formular |\n| `json` | Akzeptiert nur eine JSON-Antwort |\n| `error` | Leitet die Antwort durch [ERROR()](#error) |\n| `noencrypt`, `nodecrypt`, `nocsrf` | Überspringt die Verschlüsselung, die Entschlüsselung oder den CSRF-Header |\n| `#id` | Benennt die Anfrage für `cancel` oder wartet auf eine Codeliste |\n| `@flag` | Löst ein benutzerdefiniertes Flag aus |\n\nDer Callback erhält die Antwort, bei einem Fehler den Statuscode und ein Objekt mit den Details der Anfrage. Ein String als Callback ist ein Path, unter dem die Antwort gespeichert wird. Ohne Callback gibt die Funktion ein Promise zurück, das bei einem Status über 399 abgelehnt wird.\n\nExample: Daten senden\n```js\nAJAX('POST /api/users/', { name: 'Peter' }, function(response, err) {\n\tconsole.log(response.method, response.url); // POST /api/users/\n\tconsole.log(response.body); // {\"name\":\"Peter\"}\n});\n```\n\nExample: Ein Promise verwenden\n```js\n(async function() {\n\tvar response = await AJAX('GET /api/users/');\n\tconsole.log(response.url); // /api/users/\n})();\n```\n\nExample: Einen Fehler behandeln\n```js\nAJAX('GET /api/missing/', function(response, err) {\n\tconsole.log(err, response); // 404 Not found\n});\n```\n\n### AJAXCACHE(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nSendet eine Anfrage und speichert die Antwort im Cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Methode und die URL. |\n| `data` | `Object` | no |  | Die Daten. |\n| `callback` | `Function|String` | yes |  | `function(response, cached)` oder ein Path. |\n| `expire` | `String` | yes |  | Zum Beispiel `5 minutes` oder `session`. |\n| `delay` | `Number` | no |  | Wartet vor dem Lesen so viele Millisekunden. |\n| `clear` | `Boolean` | no |  | Mit `true` wird die gespeicherte Antwort ignoriert. |\n\nDer Callback erhält die Antwort und `true`, wenn sie aus dem Cache stammt. Der Wert `session` für `expire` behält die Antwort im Speicher, bis die Seite neu geladen wird.\n\nExample: Eine Antwort im Cache speichern\n```js\nAJAXCACHE('GET /api/users/', function(response, cached) {\n\tconsole.log('first', cached); // first false\n\tAJAXCACHE('GET /api/users/', function(response, cached) {\n\t\tconsole.log('second', cached); // second true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nGibt die Antwort aus dem Cache zurück und prüft dann, ob der Server eine neuere hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Methode und die URL. |\n| `data` | `Object` | no |  | Die Daten. |\n| `callback` | `Function|String` | yes |  | `function(response, cached, updated)` oder ein Path. |\n| `expire` | `String` | yes |  | Zum Beispiel `5 minutes`. |\n| `delay` | `Number` | no |  | Wartet vor dem Lesen so viele Millisekunden. |\n| `clear` | `Boolean` | no |  | Mit `true` wird die gespeicherte Antwort ignoriert. |\n\nGibt der Server andere Daten zurück, läuft der Callback erneut mit `false` und `true` als zweitem und drittem Argument.\n\nExample: Eine Antwort im Cache aktualisieren\n```js\nAJAXCACHE('GET /api/time/', function() {\n\tAJAXCACHEREVIEW('GET /api/time/', function(response, cached, updated) {\n\t\tconsole.log(response.value, cached, updated === true); // 2 false true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCONFIG(name, fn)\n\nType: `method`\n\nDeklariert Einstellungen, die eine Anfrage über ihren Namen anwenden kann.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Einstellungen. |\n| `fn` | `Function` | yes |  | `function(options)`. |\n\nEine Anfrage wendet sie mit `(name)` in ihrer URL an. Die Funktion erhält die Optionen der Anfrage.\n\nExample: Einen Header hinzufügen\n```js\nAJAXCONFIG('secure', function(options) {\n\toptions.headers['X-Token'] = 'abc';\n});\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-Token']); // abc\n\topt.respond({});\n});\nAJAX('GET /api/users/ (secure)', NOOP);\n```\n\n### API(url, [data], [callback])\n\nType: `method`\n\nRuft einen API-Endpunkt von Total.js auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Der Endpunkt und das Schema. |\n| `data` | `Object` | no |  | Die Daten. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` oder ein Path. |\n\nReturns: `Object|Promise` Das oben beschriebene Objekt oder ein Promise.\n\nDie URL hat die Form `/api/ schema`. Die Anfrage ist ein `POST` mit dem Namen des Schemas und den Daten im Body. Ohne Callback gibt die Funktion ein Promise zurück. Mit Callback gibt sie ein Objekt mit `params(value)` zurück, das die Parameter des Schemas füllt, und `data(value)`, das die Daten ersetzt.\n\nExample: Einen Endpunkt aufrufen\n```js\nAPI('/api/ users_save', { name: 'Peter' }, function(response) {\n\tconsole.log(response.url); // /api/\n\tconsole.log(response.body); // {\"schema\":\"users_save\",\"data\":{\"name\":\"Peter\"}}\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nLegt das Aussehen der Anwendung fest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Die CSS-Variablen und die Felder `dark` und `large`. |\n\nJedes Feld wird zu einer CSS-Variable auf `:root`. `dark` und `large` schalten die Klassen `ui-dark` und `ui-large` am Body um. `color` ist eine sechsstellige hexadezimale Farbe, die auch `DEF.color` und die Variable `--rgb` setzt.\n\nExample: Ein dunkles Theme verwenden\n```js\nAPPEARANCE({ dark: true, color: '#336699' });\nconsole.log($('#cssappearance').html()); // :root{--color:#336699;--rgb:51,102,153}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\n### ASETTER(selector, method, [...args])\n\nType: `method`\n\nErstellt eine Funktion, die später [SETTER()](#setter) aufruft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Ein Selektor wie bei [FIND()](#find). |\n| `method` | `String` | yes |  | Der Name der Methode. |\n| `...args` | `Object` | no |  | Die ersten Argumente der Methode. |\n\nReturns: `Function` Die aufzurufende Funktion.\n\nDas Argument der erstellten Funktion wird als letztes Argument der Methode angehängt, sodass sie als Callback einer Anfrage passt.\n\nExample: Als Callback verwenden\n```js\nON('ready', function() {\n\tvar fn = ASETTER('box', 'hello');\n\tfn('Peter');\n\tconsole.log(typeof(fn)); // function\n});\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLiest ein `data-`-Attribut von einem Element oder seinen übergeordneten Elementen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery|Event|Object` | yes |  | Die Quelle. |\n| `name` | `String` | no | `id` | Der Name des Attributs. |\n\nReturns: `String` Der Wert.\n\nBei einem einfachen Objekt wird dessen Feld mit diesem Namen zurückgegeben.\n\nExample: Eine Kennung lesen\n```html\n<div id=\"row\" data-id=\"15\" data-type=\"user\"></div>\n<script>\nconsole.log(ATTRD($('#row'))); // 15\nconsole.log(ATTRD($('#row'), 'type')); // user\n</script>\n```\n\n### BIND(path)\n\nType: `method`\n\nAktualisiert die Datenbindungen eines Paths, ohne Komponenten oder Watcher zu benachrichtigen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Array` | yes |  | Ein Path oder eine Liste von Paths. |\n\nExample: Eine Bindung aktualisieren\n```html\n<span id=\"name\" data-bind=\"user.name__text\"></span>\n<script>\nSET('user', { name: 'Peter' });\nsetTimeout(function() {\n\tGET('user').name = 'Anna';\n\tBIND('user.name');\n\tsetTimeout(function() {\n\t\tconsole.log($('#name').text()); // Anna\n\t}, 300);\n}, 300);\n</script>\n```\n\n### BLOCKED(name, timeout, [callback])\n\nType: `method`\n\nBegrenzt, wie oft eine Aktion ausgeführt werden kann.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Aktion. |\n| `timeout` | `Number|String` | yes |  | Millisekunden oder ein Wert wie `5 seconds`. |\n| `callback` | `Function` | no |  | Läuft, wenn die Aktion nicht gesperrt ist. |\n\nReturns: `Boolean` `true`, wenn die Aktion gesperrt ist.\n\nDer erste Aufruf gibt `false` zurück und sperrt den Namen für die angegebene Zeit. Eine Sperre von mehr als 10 Sekunden wird im Browser-Speicher aufbewahrt.\n\nExample: Einen Aufruf pro Sekunde erlauben\n```js\nconsole.log(BLOCKED('save', 1000)); // false\nconsole.log(BLOCKED('save', 1000)); // true\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLiest oder schreibt einen Wert im Browser-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|Number` | no |  | Zum Beispiel `1 day`, `session` oder Millisekunden. |\n\nReturns: `Object` Der gespeicherte Wert.\n\nEin Wert wird nur mit einer Ablaufzeit gespeichert. Der Wert `session` behält ihn im Speicher, bis die Seite neu geladen wird.\n\nExample: Einen Wert speichern\n```js\nCACHE('profile', { name: 'Peter' }, '1 day');\nconsole.log(CACHE('profile')); // {\"name\":\"Peter\"}\n```\n\n### CACHEPATH(path, expire, [rebind])\n\nType: `method`\n\nBewahrt den Wert eines Paths im Browser-Cache auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `expire` | `String` | yes |  | Zum Beispiel `1 month`. |\n| `rebind` | `Boolean` | no | `true` | Mit `false` wird der gespeicherte Wert nicht wiederhergestellt. |\n\nJede Änderung des Paths wird gespeichert, und der gespeicherte Wert wird beim nächsten Besuch wiederhergestellt. Mit der Form `path__value` ist der Ausdruck der Wert, der verwendet wird, wenn nichts gespeichert ist.\n\nExample: Einen Wert merken\n```js\nCACHEPATH('settings.theme', '1 month');\nSET('settings.theme', 'dark');\nconsole.log(CACHE('PATHS')); // {\"settings.theme\":\"dark\"}\n```\n\n### CAN(path, [flags])\n\nType: `method`\n\nGibt an, ob ein Formular abgesendet werden kann.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter. |\n| `flags` | `String|Array` | no |  | `visible` oder `hidden` beschränkt die Prüfung auf diese Komponenten. |\n\nReturns: `Boolean` Das Ergebnis.\n\nDas Ergebnis ist `true`, wenn mindestens eine Komponente auf dem Path berührt und keine ungültig ist. Ein Path ohne Komponenten gibt ebenfalls `true` zurück.\n\nExample: Eine Absenden-Schaltfläche aktivieren\n```js\nON('ready', function() {\n\tconsole.log(CAN('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tCHANGE('form.name');\n\tconsole.log(CAN('form.*')); // true\n});\n```\n\n### CHANGE(path, [value])\n\nType: `method`\n\nMarkiert die Komponenten auf einem Path als berührt und geändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Boolean` | no | `true` | Mit `false` werden die Markierungen entfernt. |\n\nExample: Ein Feld als geändert markieren\n```js\nON('ready', function() {\n\tCHANGE('form.age');\n\tconsole.log(MODIFIED('form.*')); // [\"form.age\"]\n});\n```\n\n### CL(name, callback)\n\nType: `method`\n\nWartet, bis Codelisten geladen sind.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `callback` | `Function` | yes |  | Läuft, wenn die Listen bereit sind. |\n\nMehrere Namen kannst du durch ein Komma trennen. Geladene Werte werden in `DEF.cl` gespeichert.\n\nExample: Auf eine Codeliste warten\n```js\nCL_INIT('countries', next => next(['SK', 'CZ']));\nCL('countries', function() {\n\tconsole.log(DEF.cl.countries); // [\"SK\",\"CZ\"]\n});\n```\n\n### CL_INIT(name, source, [expire], [init])\n\nType: `method`\n\nDeklariert, wie eine Codeliste geladen wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `source` | `Function|String` | yes |  | Der Loader. |\n| `expire` | `String` | no |  | Die Liste wird nach dieser Zeit erneut geladen. |\n| `init` | `Boolean` | no |  | Mit `true` wird die Liste sofort geladen. |\n\nDie Quelle ist eine Funktion, die `next(value)` erhält, oder ein String. Ein String, der mit einer HTTP-Methode beginnt, geht an [AJAX()](#ajax), jeder andere String an [TAPI()](#tapi). `CLINIT()` ist dieselbe Funktion.\n\nExample: Eine Liste von einer URL laden\n```js\nCL_INIT('roles', 'GET /api/roles/', true);\nsetTimeout(function() {\n\tconsole.log(DEF.cl.roles.url); // /api/roles/\n}, 300);\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nBricht einen benannten Timer ab.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Timers. |\n\nReturns: `Boolean` `true`, wenn ein Timer lief.\n\nExample: Einen Timer abbrechen\n```js\nsetTimeout2('save', NOOP, 1000);\nconsole.log(clearTimeout2('save')); // true\nconsole.log(clearTimeout2('save')); // false\n```\n\n### CLINIT(name, source, [expire], [init])\n\nType: `method`\n\nDieselbe Funktion wie [CL_INIT()](#cl-init).\n\nExample: Dieselbe Funktion\n```js\nconsole.log(CLINIT === CL_INIT); // true\n```\n\n### CLONE(value, [nopath])\n\nType: `method`\n\nErstellt eine tiefe Kopie eines Werts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | Der Wert oder ein Path. |\n| `nopath` | `Boolean` | no |  | Mit `true` wird ein String unverändert zurückgegeben. |\n\nReturns: `Object` Die Kopie.\n\nEin String wird als Path behandelt, und der Wert des Paths wird geklont.\n\nExample: Einen Wert klonen\n```js\nSET('user', { name: 'Peter' });\nvar copy = CLONE('user');\ncopy.name = 'Anna';\nconsole.log(GET('user.name')); // Peter\nconsole.log(copy.name); // Anna\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nLädt Codelisten erneut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `callback` | `Function` | no |  | Läuft, wenn die Listen geladen sind. |\n\nMehrere Namen kannst du durch ein Komma trennen.\n\nExample: Eine Liste neu laden\n```js\nvar count = 0;\nCL_INIT('numbers', next => next([++count]), true);\nsetTimeout(function() {\n\tCLRELOAD('numbers', function() {\n\t\tconsole.log(DEF.cl.numbers); // [2]\n\t});\n}, 100);\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nFührt einen Befehl in allen Komponenten aus, die ihn registriert haben.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Befehls. |\n| `a` | `Object` | no |  | Bis zu fünf Argumente, `a` bis `e`. |\n\nKomponenten registrieren Befehle mit `self.command()`.\n\nExample: Einen Befehl ausführen\n```js\nON('ready', function() {\n\tCMD('box.ping', 5);\n});\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // box.ping 5\n});\n```\n\n### COMPILE([container])\n\nType: `method`\n\nDurchsucht die Seite nach neuen Komponenten und Bindungen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Beschränkt die Suche auf dieses Element. |\n\nRufe die Funktion auf, nachdem du HTML von Hand hinzugefügt hast.\n\nExample: Neues HTML kompilieren\n```js\n$(document.body).append('<ui-component name=\"box\" path=\"data.new\"></ui-component>');\nCOMPILE();\nsetTimeout(function() {\n\tconsole.log(FIND('box').path); // data.new\n}, 500);\n```\n\n### COMPONENT(name, [config], declaration, [dependencies])\n\nType: `method`\n\nDeklariert eine Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Komponente. |\n| `config` | `String|Object` | no |  | Die Standardkonfiguration. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n| `dependencies` | `Array` | no |  | Dateien, die zuerst importiert werden, oder Komponentennamen, die mit `@` beginnen. |\n\nMehrere Namen kannst du durch ein Komma trennen. Auf den Namen kann eine Version folgen: `box@2`. Das gesamte Thema wird unter [Komponenten erstellen](../../guides/creating-components/) erklärt, und das Objekt, das die Deklaration erhält, ist unter [Component](../component/) beschrieben.\n\nExample: Eine Komponente deklarieren\n```html\n<ui-component name=\"hello\"></ui-component>\n<script>\nCOMPONENT('hello', 'name:World', function(self, config) {\n\tself.make = () => self.element.text('Hello ' + config.name);\n});\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // Hello World\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nListet die Komponenten auf einem Path auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path mit optionalen Flags. |\n\nReturns: `Array` Die Komponenten.\n\nDer Path wird ohne `.*` geschrieben. Flags nach dem Path filtern die Liste: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` und `@enabled`.\n\nExample: Die Komponenten filtern\n```js\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tSET('form.name', 'Peter');\n\tconsole.log(COMPONENTS('form @invalid').map(com => com.path)); // [\"form.age\"]\n});\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nLegt die Konfiguration von Komponenten fest, bevor diese starten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Welche Komponenten konfiguriert werden. |\n| `config` | `Object|String|Function` | yes |  | Die Konfiguration oder eine Funktion, die sie zurückgibt. |\n\nDer Selektor ist ein Komponentenname, `.path`, `#id` oder eine Funktion, die die Komponente erhält und einen booleschen Wert zurückgibt. Durch ein Leerzeichen getrennte Teile müssen alle zutreffen, und ein Komma trennt Alternativen. Rufe die Funktion auf, bevor die Komponenten kompiliert werden.\n\nExample: Nach Namen konfigurieren\n```js\nCONFIG('box', { size: 10 });\nON('ready', function() {\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### COOKIES\n\nType: `property`\n\nEin Objekt zum Lesen und Schreiben von Cookies.\n\nEs hat die Methoden `get(name)`, `set(name, value, expire, [samesite])` und `rem(name)`. `expire` ist ein `Date` oder ein Wert wie `1 day`.\n\nExample: Wert lesen\n```js\nCOOKIES.set('theme', 'dark', '1 day');\nconsole.log(COOKIES.get('theme') === 'dark' || location.protocol === 'file:'); // true\n```\n\n### COPY(source, target)\n\nType: `method`\n\nKopiert die Felder eines Objekts in ein anderes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | Das Objekt, das gelesen wird. |\n| `target` | `Object` | yes |  | Das Objekt, in das geschrieben wird. |\n\nReturns: `Object` Das Zielobjekt.\n\nObjekte innerhalb der Quelle werden geklont.\n\nExample: Felder kopieren\n```js\nvar target = COPY({ a: 1 }, { b: 2 });\nconsole.log(target); // {\"b\":2,\"a\":1}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nDieselbe Funktion wie [STYLE()](#style).\n\nExample: Dieselbe Funktion\n```js\nconsole.log(CSS === STYLE); // true\n```\n\n### DAPI(name, [data], [callback])\n\nType: `method`\n\nRuft den in `DEF.api` festgelegten API-Endpunkt auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Schemas. |\n| `data` | `Object` | no |  | Die Daten. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` oder ein Path. |\n\nReturns: `Object|Promise` Dasselbe wie bei [API()](#api).\n\n`DEF.api` ist eine URL oder eine Funktion, die den Namen und die Daten erhält und den Wert für [API()](#api) zurückgibt.\n\nExample: Den Standard-Endpunkt verwenden\n```js\nDEF.api = '/api/';\nDAPI('users_list', null, function(response) {\n\tconsole.log(response.url, response.body.schema); // /api/ users_list\n});\n```\n\n### DAYS\n\nType: `property`\n\nDie Namen der Tage, beginnend mit Sonntag.\n\nExample: Wert lesen\n```js\nconsole.log(DAYS[0]); // Sunday\n```\n\n### DEBUG()\n\nType: `method`\n\nSchaltet den Debug-Modus ein.\n\nAufrufe fehlender Methoden schreiben eine Warnung in die Konsole, und [API()](#api) fügt der URL das Schema hinzu. Der Modus lässt sich nicht mehr einschalten, nachdem `DEF.secret()` einen Schlüssel gesetzt hat.\n\nExample: Vor einer fehlenden Methode warnen\n```js\nDEBUG();\nEXEC('missing.method');\nconsole.log('done'); // done\n```\n\n### DECRYPT(value, [key], [type])\n\nType: `method`\n\nDekodiert einen Wert aus [ENCRYPT()](#encrypt).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Der kodierte Wert. |\n| `key` | `String` | no |  | Der Schlüssel. |\n| `type` | `String` | no |  | Das Präfix des Werts. |\n\nReturns: `Object` Der Wert oder `undefined`, wenn der Schlüssel oder das Präfix nicht passt.\n\nJSON wird zurück in ein Objekt geparst.\n\nExample: Einen falschen Schlüssel verwenden\n```js\nvar token = ENCRYPT('Peter', 'secret');\nconsole.log(DECRYPT(token, 'secret')); // Peter\nconsole.log(DECRYPT(token, 'other') === undefined); // true\n```\n\n### DEF\n\nType: `property`\n\nDie Konfiguration der Bibliothek. Siehe [DEF](../def/).\n\nExample: Wert lesen\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEFAULT(path, [delay], [reset])\n\nType: `method`\n\nStellt die Standardwerte der Komponenten auf einem Path wieder her.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter, oder `path__value`. |\n| `delay` | `Number` | no |  | Eine Verzögerung in Millisekunden. |\n| `reset` | `Boolean` | no | `true` | Mit `false` bleibt der Zustand der Komponenten erhalten. |\n\nEine Komponente übernimmt ihren Standardwert aus ihrem Attribut `default`. Mit der Form `path__value` wird stattdessen der Ausdruck nach den beiden Unterstrichen als Standardwert in den Path geschrieben.\n\nExample: Ein Standardobjekt schreiben\n```js\nDEFAULT('form.* __{ name: \"Peter\" }');\nsetTimeout(function() {\n\tconsole.log(GET('form')); // {\"name\":\"Peter\"}\n}, 100);\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 Kindelemente. |\n| `html` | `String` | yes |  | Das neue HTML. |\n| `attribute` | `String` | no |  | Das Attribut, das verglichen wird. |\n\nReturns: `Object` Die Zähler `add`, `upd` und `rem`.\n\nNur die geänderten Kindelemente werden hinzugefügt oder entfernt. Kindelemente werden anhand ihres HTML oder anhand des Attributwerts verglichen.\n\nExample: Eine Liste aktualisieren\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n<script>\nvar result = DIFFDOM($('#list'), 'li', '<li>B</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log($('#list').text()); // BC\n</script>\n```\n\n### DISABLED(path, [flags])\n\nType: `method`\n\nDas Gegenteil von [CAN()](#can).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter. |\n| `flags` | `String|Array` | no |  | `visible` oder `hidden` beschränkt die Prüfung auf diese Komponenten. |\n\nReturns: `Boolean` Das Ergebnis.\n\nExample: Eine Absenden-Schaltfläche deaktivieren\n```js\nON('ready', function() {\n\tconsole.log(DISABLED('form.*')); // true\n});\n```\n\n### EMIT(name, [...args])\n\nType: `method`\n\nRuft die Handler eines Events auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `...args` | `Object` | no |  | Die Argumente, die an die Handler übergeben werden. |\n\nReturns: `Boolean` `true`, wenn das Event mindestens einen Handler hat.\n\nAuf den Namen kann ein benutzerdefiniertes Flag folgen, zum Beispiel `EMIT('ping @saved')`.\n\nExample: Event auslösen\n```js\nON('hello', name => console.log(name)); // Peter\nconsole.log(EMIT('hello', 'Peter')); // true\nconsole.log(EMIT('unknown')); // false\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nEin eingefrorenes leeres Array.\n\nExample: Wert lesen\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nEin eingefrorenes leeres Objekt.\n\nExample: Wert lesen\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nKodiert einen Wert in einen hexadezimalen String, der mit einem Schlüssel signiert ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Der Wert. |\n| `key` | `String` | no |  | Der Schlüssel. |\n| `type` | `String` | no |  | Ein Präfix des Ergebnisses. |\n\nReturns: `String` Der kodierte Wert.\n\nDer Wert wird kodiert, nicht stark verschlüsselt. Objekte werden in JSON umgewandelt.\n\nExample: Kodieren und dekodieren\n```js\nvar token = ENCRYPT({ id: 5 }, 'secret');\nconsole.log(DECRYPT(token, 'secret')); // {\"id\":5}\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLiest oder schreibt eine Umgebungsvariable.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Der Name oder ein Objekt mit Werten. |\n| `value` | `Object` | no |  | Der Wert. |\n\nReturns: `Object` Der Wert der Variable.\n\nEin Objekt als erstes Argument schreibt mehrere Variablen. Paths und URLs lesen die Variablen mit `[name]`. Die Variablen werden in `DEF.environment` gespeichert.\n\nExample: Eine Variable 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 Namen, die Version und die Sprache der Anwendung fest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Anwendung. |\n| `version` | `String` | no |  | Die Version. |\n| `language` | `String` | no |  | Die Sprache des importierten HTML. |\n| `env` | `Object` | no |  | Umgebungsvariablen für [ENV()](#env). |\n\nDer Name trennt den Browser-Speicher der Anwendung ab. Die Funktion setzt `DEF.localstorage`, `DEF.version` und `DEF.languagehtml`.\n\nExample: Die Anwendung benennen\n```js\nENVIRONMENT('shop', '1.2', 'en', { api: '/api/' });\nconsole.log(DEF.localstorage, DEF.version, ENV('api')); // shop 1.2 /api/\n```\n\n### ERROR(value, [success], [error])\n\nType: `method`\n\nGibt an, ob eine Antwort einen Fehler enthält.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|Function` | yes |  | Die Antwort oder der Erfolgs-Handler. |\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|Function` `true`, wenn der Wert ein Fehler ist, oder der erstellte Callback.\n\nEin `Error`, ein Objekt mit dem Feld `error` oder ein Array, dessen erster Eintrag dieses Feld hat, gilt als Fehler, und das Event [ERROR](../events/#error-2) wird ausgelöst. `success` und `error` sind Funktionen oder Paths.\n\nMit einer Funktion als erstem Argument gibt `ERROR(success, [error])` einen Callback für eine Anfrage zurück.\n\nExample: Eine Antwort prüfen\n```js\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\nconsole.log(ERROR({ id: 5 })); // false\n```\n\nExample: Einen Callback erstellen\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 5\n});\ncallback({ id: 5 });\n```\n\n### ERRORS(path, [flags], [highlight])\n\nType: `method`\n\nListet die Komponenten auf, die berührt und ungültig sind.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter. |\n| `flags` | `String|Array` | no |  | `visible` oder `hidden` beschränkt die Prüfung auf diese Komponenten. |\n| `highlight` | `Boolean` | no |  | Aktualisiert den Zustand der gefundenen Komponenten. |\n\nReturns: `Array` Die Komponenten.\n\n`ERRORS(path, true)` aktualisiert außerdem den Zustand der gefundenen Komponenten.\n\nExample: Die ungültigen Felder finden\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(ERRORS('form.*').map(com => com.path)); // [\"form.name\"]\n});\n```\n\n### EVALUATE(path, expression, [nopath])\n\nType: `method`\n\nWertet einen JavaScript-Ausdruck mit dem Wert eines Paths aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Object` | yes |  | Der Path oder der Wert selbst, wenn `nopath` den Wert `true` hat. |\n| `expression` | `String` | yes |  | Der Ausdruck. |\n| `nopath` | `Boolean` | no |  | Behandelt das erste Argument als Wert. |\n\nReturns: `Object` Das Ergebnis des Ausdrucks.\n\nDer Ausdruck kann die Variablen `value` und `path` verwenden.\n\nExample: Einen Ausdruck auswerten\n```js\nSET('price', 10);\nconsole.log(EVALUATE('price', 'value * 2')); // 20\nconsole.log(EVALUATE(4, 'value + 1', true)); // 5\n```\n\n### EXE([wait], path, [...args])\n\nType: `method`\n\nDieselbe Funktion wie [EXEC()](#exec).\n\nExample: Dieselbe Funktion\n```js\nconsole.log(EXE === EXEC); // true\n```\n\n### EXEC([wait], path, [...args])\n\nType: `method`\n\nRuft eine Funktion, eine Plugin-Methode, eine Komponentenmethode, einen Befehl oder ein Event auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Mit `true` wird auf das Ziel gewartet. |\n| `path` | `String` | yes |  | Das Ziel. |\n| `...args` | `Object` | no |  | Die Argumente. |\n\nDie Form des Paths bestimmt das Ziel:\n\n| Path | Ziel |\n| --- | --- |\n| `plugin/method` | Eine Methode eines Plugins |\n| `@plugin.method` | Eine Methode eines Plugins |\n| `path.to.fn` | Eine Funktion auf einem Path |\n| `#name` | Das Event `name` |\n| `-selector/method` | Eine Methode einer Komponente, wie bei [SETTER()](#setter) |\n| `&name` | Ein Befehl, wie bei [CMD()](#cmd) |\n\nMit `true` als erstem Argument wartet der Aufruf, bis das Ziel existiert. `EXE()` ist dieselbe Funktion.\n\nExample: Eine Plugin-Methode aufrufen\n```js\nPLUGIN('users', function(exports) {\n\texports.hello = function(name) {\n\t\tconsole.log(name); // Peter\n\t};\n});\nEXEC(true, 'users/hello', 'Peter');\n```\n\nExample: Eine Funktion auf einem Path aufrufen\n```js\nwindow.app = { sum: (a, b) => console.log(a + b) };\nEXEC('app.sum', 1, 2);\nconsole.log(typeof(app.sum)); // function\n```\n\n### EXT(path, value, [delay], [reset])\n\nType: `method`\n\nFührt die Felder eines Objekts mit dem Objekt auf einem Path zusammen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Die Felder, die zusammengeführt werden. |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n| `reset` | `Boolean` | no |  | Mit `true` werden die Komponenten auf dem Path außerdem als nicht berührt und nicht geändert markiert. |\n\nJedes Feld wird einzeln geschrieben, die übrigen Felder bleiben also erhalten. `EXTEND()` ist dieselbe Funktion. Wie bei [SET()](#set) kann das erste Argument eine Anfrage und `value` der Ziel-Path sein.\n\nExample: Felder zusammenführen\n```js\nSET('user', { name: 'Peter' });\nEXT('user', { age: 30 });\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"age\":30}\n```\n\n### EXTEND(path, value, [delay], [reset])\n\nType: `method`\n\nDieselbe Funktion wie [EXT()](#ext).\n\nExample: Dieselbe Funktion\n```js\nconsole.log(EXTEND === EXT); // true\n```\n\n### EXTENSION(name, [config], declaration)\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 `@plugin`. |\n| `config` | `Object|String` | no |  | Zusätzliche Konfiguration. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n\nDie Deklaration läuft für jede Instanz der Komponente, auch für bereits vorhandene. Mit einem Namen, der mit `@` beginnt, erweitert sie das Plugin dieses Namens.\n\nExample: Einer Komponente eine Methode hinzufügen\n```js\nEXTENSION('box', function(self) {\n\tself.bye = () => 'Bye';\n});\nON('ready', function() {\n\tconsole.log(FIND('box').bye()); // Bye\n});\n```\n\n### FIND(selector, [many], [nocache], [callback])\n\nType: `method`\n\nSucht eine Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Element` | yes |  | Was gesucht wird. |\n| `many` | `Boolean` | no |  | Mit `true` werden alle Treffer als Array zurückgegeben. |\n| `nocache` | `Boolean` | no |  | Überspringt den Cache der gefundenen Komponenten. |\n| `callback` | `Function` | no |  | Wartet auf die Komponente und erhält sie. |\n\nReturns: `Component|Array` Die gefundene Komponente oder mit `many` ein Array. Wird ein Callback verwendet, gibt die Funktion nichts zurück.\n\nDer Selektor ist ein Komponentenname, `.path`, `#id`, `name[path]` oder `name@version`, und Teile lassen sich mit einem Leerzeichen kombinieren. Ein DOM-Element oder ein jQuery-Objekt findet die Komponenten darin.\n\nMit einem Callback wartet die Suche, bis die Komponente existiert. Der Callback kann das zweite oder das dritte Argument sein.\n\nExample: Nach Name und Path suchen\n```js\nON('ready', function() {\n\tconsole.log(FIND('box').path); // data.box\n\tconsole.log(FIND('.data.box').name); // box\n\tconsole.log(FIND('box', true).length); // 1\n});\n```\n\nExample: Auf eine Komponente warten\n```js\nFIND('box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### FN(expression)\n\nType: `method`\n\nErstellt eine Funktion aus einem String.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expression` | `String` | yes |  | Der Ausdruck. |\n\nReturns: `Function` Die Funktion.\n\nDer String ist eine Pfeilfunktion. Ein String, der nur das Wort `value` verwendet, wird zu einer Funktion mit dem Argument `value`.\n\nExample: Funktionen erstellen\n```js\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value > 5')(10)); // true\n```\n\n### FORMATTER(fn, [prepend])\n\nType: `method`\n\nRegistriert einen globalen Formatter für Komponentenwerte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Mit `true` läuft der Formatter zuerst. |\n\nReturns: `Object` Der formatierte Wert, wenn die Funktion die Formatter ausführt.\n\nDie Funktion gibt den neuen Wert zurück, und `undefined` behält den aktuellen bei. `FORMATTER(value, path, type, [format])` führt alle registrierten Formatter aus.\n\nExample: Einen Wert formatieren\n```js\nFORMATTER(function(path, value, type) {\n\tif (type === 'upper')\n\t\treturn value.toUpperCase();\n});\nconsole.log(FORMATTER('peter', 'user.name', 'upper')); // PETER\n```\n\n### FREE([delay])\n\nType: `method`\n\nEntfernt nicht verwendete Komponenten, Bindungen und Watcher.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `10` | Die Verzögerung in Millisekunden. |\n\nDie Bibliothek macht das außerdem alle drei Minuten.\n\nExample: Aufräumen\n```js\nFREE();\nconsole.log(typeof(FREE)); // function\n```\n\n### FUNC\n\nType: `property`\n\nEin leeres Objekt für deine eigenen gemeinsamen Funktionen.\n\nExample: Wert lesen\n```js\nFUNC.sum = (a, b) => a + b;\nconsole.log(FUNC.sum(1, 2)); // 3\n```\n\n### GET(path, [scope])\n\nType: `method`\n\nLiest den Wert eines Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `scope` | `Object|Function|Boolean` | no |  | Bei einem Objekt wird der Path relativ zu diesem Objekt gelesen. Eine Funktion wartet, bis der Wert nicht `null` ist, und erhält ihn dann. `true` setzt den Zustand der Komponenten auf dem Path zurück. |\n\nReturns: `Object` Der Wert oder `undefined`, wenn der Path keinen Wert hat. Mit einer Funktion als zweitem Argument wird nichts zurückgegeben.\n\nAuf den Path können Flags folgen. `@clone` gibt eine Kopie zurück, `@reset` setzt nach dem Lesen den Zustand der Komponenten zurück, und `@modified` gibt nur die Werte der geänderten Komponenten zurück.\n\nExample: Wert lesen\n```js\nSET('user', { name: 'Peter', age: 30 });\nconsole.log(GET('user.age')); // 30\nconsole.log(GET('name', { name: 'Anna' })); // Anna\n```\n\nExample: Auf einen Wert warten\n```js\nGET('settings.theme', function(value) {\n\tconsole.log(value); // dark\n});\nsetTimeout(() => SET('settings.theme', 'dark'), 100);\n```\n\n### GUID([size])\n\nType: `method`\n\nErstellt eine zufällige Kennung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `size` | `Number` | no |  | Die Länge. Ohne Angabe hat die Kennung 36 Zeichen in der Form einer UUID. |\n\nReturns: `String` Die Kennung.\n\nExample: Kennungen erstellen\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value, [unsigned])\n\nType: `method`\n\nErstellt eine Zahl aus einem Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Wert. |\n| `unsigned` | `Boolean` | no | `true` | Mit `false` kann das Ergebnis negativ sein. |\n\nReturns: `Number` Der Hash.\n\nObjekte werden anhand ihrer JSON-Form gehasht. Eine Zahl wird unverändert zurückgegeben, ein boolescher Wert wird zu `0` oder `1`, und ein Datum wird zu seinem Zeitwert.\n\nExample: Einen String hashen\n```js\nconsole.log(HASH('abc')); // 96354\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nGibt an, ob ein Element nicht angezeigt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Das Element. |\n\nReturns: `Boolean` Das Ergebnis. Ein fehlendes Element gibt `true` zurück.\n\nExample: Ein Element prüfen\n```html\n<div id=\"a\" style=\"display:none\"><span></span></div>\n<script>\nconsole.log(HIDDEN($('#a')[0].firstChild)); // true\nconsole.log(HIDDEN(null)); // true\n</script>\n```\n\n### IMPORT(url, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nLädt ein Skript, einen Style oder HTML in die Seite.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String|Array` | yes |  | Die URL. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Wohin das HTML kommt. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Mit `false` wird der Inhalt des Ziels ersetzt. |\n| `preparator` | `Function` | no |  | `function(response, output)` ändert das HTML vor dem Einfügen. |\n\nDas Thema wird unter [Inhalte importieren](../../guides/importing/) erklärt. Ein Array von URLs wird nacheinander geladen. Eine URL, die mit `once ` oder `!` beginnt, wird nur einmal geladen, und `<path>` vor der URL überspringt den Import, wenn der Path einen Wert hat. Der Callback erhält `1` nach dem Laden und `0`, wenn nichts geladen wurde.\n\nExample: HTML importieren\n```html\n<div id=\"target\"></div>\n<script>\nIMPORT('/parts/hello.html', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nFunktioniert wie [IMPORT()](#import) und speichert importiertes HTML im Cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL. |\n| `expire` | `String` | yes |  | Zum Beispiel `5 minutes` oder `session`. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Wohin das HTML kommt. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Mit `false` wird der Inhalt des Ziels ersetzt. |\n| `preparator` | `Function` | no |  | `function(response, output)` ändert das HTML vor dem Einfügen. |\n\nExample: Importieren und im Cache speichern\n```html\n<div id=\"target\"></div>\n<script>\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### INC(path, [value], [delay], [reset])\n\nType: `method`\n\nAddiert eine Zahl zum Wert auf einem Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Number` | no | `1` | Die Zahl, die addiert wird. |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n| `reset` | `Boolean` | no |  | Mit `true` werden die Komponenten auf dem Path außerdem als nicht berührt und nicht geändert markiert. |\n\nEin fehlender Wert oder ein Wert, der keine Zahl ist, zählt als `0`.\n\nExample: Einen Zähler erhöhen\n```js\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 6\n```\n\n### inDOM(element)\n\nType: `method`\n\nGibt an, ob sich ein Element im Body der Seite befindet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | Das Element. |\n\nReturns: `Boolean` `true` oder `undefined`, wenn sich das Element außerhalb des Bodys befindet.\n\nExample: Ein Element prüfen\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(inDOM(document.createElement('div')) === undefined); // true\n```\n\n### isIE\n\nType: `property`\n\n`true` im Internet Explorer.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(isIE)); // boolean\n```\n\n### isMOBILE\n\nType: `property`\n\n`true` auf einem Mobilgerät.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(isMOBILE)); // boolean\n```\n\n### isPRIVATEMODE\n\nType: `property`\n\n`true`, wenn der Browser-Speicher nicht verfügbar ist.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(isPRIVATEMODE)); // boolean\n```\n\n### isROBOT\n\nType: `property`\n\n`true`, wenn der User-Agent nach einem Robot aussieht.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(isROBOT)); // boolean\n```\n\n### isSTANDALONE\n\nType: `property`\n\n`true`, wenn die Seite als installierte Anwendung läuft.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(isSTANDALONE)); // boolean\n```\n\n### isTOUCH\n\nType: `property`\n\n`true` auf einem Gerät mit Touchscreen.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(isTOUCH)); // boolean\n```\n\n### jComponent\n\nType: `property`\n\nEin anderer Name für `MAIN`. Siehe [MAIN](../main/).\n\nExample: Wert lesen\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### LOCALIZE(text)\n\nType: `method`\n\nFügt dem Wörterbuch Übersetzungen hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Die Übersetzungen. |\n\nJede Zeile hat die Form `key : value`, und eine Zeile, die mit `//` beginnt, wird übersprungen. Die Werte werden in `DEF.dictionary` gespeichert. Das Thema wird unter [Lokalisierung](../../guides/localization/) erklärt.\n\nExample: Übersetzungen hinzufügen\n```js\nLOCALIZE('// Greetings\\nhello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### M\n\nType: `property`\n\nEin Kurzname für `MAIN`. Siehe [M](../m/).\n\nExample: Wert lesen\n```js\nconsole.log(M === MAIN); // true\n```\n\n### MACRO(name, declaration)\n\nType: `method`\n\nDeklariert ein Macro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Macros. |\n| `declaration` | `Function` | yes |  | `function(self, element, cls)`. |\n\nDas Thema wird unter [Macros](../../guides/macros/) erklärt, und das Objekt ist unter [Macro](../macro/) beschrieben.\n\nExample: Ein Macro deklarieren\n```js\nMACRO('upper', function(self, element) {\n\tself.setter = value => element.text((value || '').toUpperCase());\n});\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### MAIN\n\nType: `property`\n\nDas Hauptobjekt der Bibliothek. Siehe [MAIN](../main/).\n\nExample: Wert lesen\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### MAKE([target], fn, [update])\n\nType: `method`\n\nBaut ein Objekt in einer Funktion auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Object|String` | no |  | Ein Objekt oder ein Path. Ohne Angabe wird ein neues Objekt erstellt. |\n| `fn` | `Function` | yes |  | `function(obj, path, set)`. |\n| `update` | `Boolean` | no | `true` | Mit `false` wird ein vorhandenes Objekt auf dem Path zurückgeschrieben, ohne seine Komponenten zurückzusetzen. |\n\nReturns: `Object` Das Objekt.\n\nEin String als Ziel ist ein Path: Das Objekt auf dem Path wird geändert, oder ein neues wird erstellt und dorthin geschrieben. Die Funktion erhält das Objekt, den Path und eine Funktion `set(path, value)`.\n\nExample: Ein Objekt aufbauen\n```js\nvar obj = MAKE(function(o) {\n\to.name = 'Peter';\n});\nconsole.log(obj); // {\"name\":\"Peter\"}\n```\n\nExample: Ein Objekt auf einem Path aufbauen\n```js\nMAKE('user', function(o, path, set) {\n\to.name = 'Peter';\n\tset('address.city', 'Bratislava');\n});\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"address\":{\"city\":\"Bratislava\"}}\n```\n\n### MIDDLEWARE(name, fn)\n\nType: `method`\n\nDeklariert eine Middleware für Routen. Siehe [Routing](../../guides/routing/).\n\n### MODIFIED(path, [flags])\n\nType: `method`\n\nListet die Paths der Komponenten auf, die berührt und geändert sind.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter. |\n| `flags` | `String|Array` | no |  | `visible` oder `hidden` beschränkt die Suche auf diese Komponenten. |\n\nReturns: `Array` Die Paths der geänderten Komponenten.\n\nExample: Die geänderten Felder auflisten\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n});\n```\n\n### MONTHS\n\nType: `property`\n\nDie Namen der Monate.\n\nExample: Wert lesen\n```js\nconsole.log(MONTHS[11]); // December\n```\n\n### NAV\n\nType: `property`\n\nDas Router-Objekt. Siehe [Routing](../../guides/routing/).\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` | `Element|jQuery` | yes |  | Das Element. |\n\nReturns: `Number` Der Index.\n\nExample: Die Position lesen\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, target, [before])\n\nType: `method`\n\nSetzt ein Element hinter oder vor ein anderes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Das Element, das verschoben wird. |\n| `target` | `Element|jQuery` | yes |  | Das Referenzelement. |\n| `before` | `Boolean` | no |  | Mit `true` wird es vor das Ziel gesetzt. |\n\nExample: Ein Element verschieben\n```html\n<ul><li id=\"a\">A</li><li>B</li><li id=\"c\">C</li></ul>\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 Geschwisterelementen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Das Element. |\n| `up` | `Boolean` | no |  | Mit `true` wird es nach oben verschoben, andernfalls nach unten. |\n\nExample: Ein Element nach oben verschieben\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BA\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nEine Funktion, die nichts macht.\n\nExample: Als leeren Callback verwenden\n```js\nconsole.log(NOOP() === undefined); // true\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nGibt an, ob sich die Seite im Hintergrund befindet.\n\nReturns: `Boolean` Das Ergebnis.\n\nExample: Die Seite prüfen\n```js\nconsole.log(typeof(NOTFOCUSED())); // boolean\n```\n\n### NOTIFY(...paths)\n\nType: `method`\n\nAktualisiert die Komponenten und Watcher exakter Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...paths` | `String` | yes |  | Ein oder mehrere Paths. |\n\nNur Komponenten mit genau demselben Path werden aktualisiert.\n\nExample: Einen Watcher benachrichtigen\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nwindow.user = { name: 'Peter' };\nNOTIFY('user.name');\n```\n\n### NOTMODIFIED(path, [value], [fields])\n\nType: `method`\n\nGibt an, ob ein Wert derselbe ist wie bei der letzten Prüfung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path oder ein beliebiger Schlüssel, wenn `value` angegeben ist. |\n| `value` | `Object` | no |  | Der Wert, der verglichen wird. Ohne Angabe wird der Wert des Paths verwendet. |\n| `fields` | `Array` | no |  | Vergleicht nur diese Felder. |\n\nReturns: `Boolean` `true`, wenn sich der Wert nicht geändert hat.\n\nDie erste Prüfung eines Paths gibt `false` zurück. Der Wert wird über einen Hash seiner JSON-Form verglichen.\n\nExample: Arbeit überspringen, wenn sich nichts geändert hat\n```js\nconsole.log(NOTMODIFIED('list', [1, 2])); // false\nconsole.log(NOTMODIFIED('list', [1, 2])); // true\nconsole.log(NOTMODIFIED('list', [1, 2, 3])); // false\n```\n\n### NOW\n\nType: `property`\n\nDas aktuelle Datum, das jede Minute aktualisiert wird.\n\nExample: Wert lesen\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path, [delay])\n\nType: `method`\n\nSchreibt `null` in einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n\n`NULL()` ist dieselbe Funktion.\n\nExample: Einen Wert leeren\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### NULL(path, [delay])\n\nType: `method`\n\nDieselbe Funktion wie [NUL()](#nul).\n\nExample: Dieselbe Funktion\n```js\nconsole.log(NULL === NUL); // true\n```\n\n### OFF(name, [path], [fn])\n\nType: `method`\n\nEntfernt Handler eines Events.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `path` | `String|Function` | no |  | Der Path oder der Handler, wenn kein Path nötig ist. |\n| `fn` | `Function` | no |  | Der Handler. |\n\nMehrere Events kannst du durch `+` trennen. Die Form `owner#name` entfernt die Handler dieses Besitzers, und `owner#` entfernt alle seine Handler.\n\nExample: Einen Handler entfernen\n```js\nvar fn = () => console.log('never');\nON('ping', fn);\nOFF('ping', fn);\nconsole.log(EMIT('ping')); // false\n```\n\nExample: Die Handler eines Besitzers entfernen\n```js\nON('shop#ping', () => console.log('never'));\nOFF('shop#');\nconsole.log(EMIT('ping')); // false\n```\n\n### ON(name, [path], fn, [init])\n\nType: `method`\n\nRegistriert einen Handler für ein Event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `path` | `String` | no |  | Der Path für das Event `watch`. |\n| `fn` | `Function` | yes |  | Der Handler. |\n| `init` | `Boolean` | no |  | Beim Event `watch` wird der Handler außerdem sofort aufgerufen. |\n\nDer Name kann mehrere Events enthalten, getrennt durch ein Leerzeichen oder ` + `. Ein Name, der mit `^` beginnt, setzt den Handler an den Anfang. Die Form `owner#name` weist den Handler einem Besitzer zu, sodass [OFF()](#off) ihn später entfernen kann. Der Name `@flag myflag` reagiert auf ein benutzerdefiniertes Flag auf einem Path.\n\nDas Event `watch` funktioniert wie [WATCH()](#watch) und verwendet `path` und `init`. Die Events der Bibliothek sind unter [Events](../events/) aufgeführt.\n\nExample: Auf ein benutzerdefiniertes Event lauschen\n```js\nON('cart.add', function(id, count) {\n\tconsole.log(id, count); // 15 2\n});\nEMIT('cart.add', 15, 2);\n```\n\nExample: Auf ein benutzerdefiniertes Flag reagieren\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.name Peter\n});\nSET('user.name @saved', 'Peter');\n```\n\n### OPT([obj], fn)\n\nType: `method`\n\nBaut ein Optionsobjekt mit verschachtelten Paths auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | no |  | Das Objekt, das gefüllt wird. Ohne Angabe wird ein neues Objekt erstellt. |\n| `fn` | `Function` | yes |  | `function(set, scope)`. |\n\nReturns: `Object` Das Objekt.\n\nDie Funktion erhält `set(path, value)` und `scope(prefix)`, das den nächsten Paths ein Präfix hinzufügt.\n\nExample: Optionen aufbauen\n```js\nvar options = OPT(function(set, scope) {\n\tset('title', 'Users');\n\tscope('grid');\n\tset('limit', 20);\n});\nconsole.log(options); // {\"title\":\"Users\",\"grid\":{\"limit\":20}}\n```\n\n### PARSE(value, [date])\n\nType: `method`\n\nParst JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Das JSON oder ein Selektor. |\n| `date` | `Boolean` | no | `DEF.jsondate` | Wandelt ISO-Datumsangaben in `Date`-Objekte um. |\n\nReturns: `Object` Der Wert.\n\nEin String, der mit `#` oder `.` beginnt, ist ein Selektor eines Elements mit JSON. Ungültiges JSON gibt `null` zurück, und ein Objekt wird unverändert zurückgegeben.\n\nExample: JSON parsen\n```js\nconsole.log(PARSE('{\"id\":5}').id); // 5\nconsole.log(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d instanceof Date); // true\nconsole.log(PARSE('wrong')); // null\n```\n\n### PARSER(fn, [prepend])\n\nType: `method`\n\nRegistriert einen globalen Parser für Komponentenwerte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Mit `true` läuft der Parser zuerst. |\n\nReturns: `Object` Der geparste Wert, wenn die Funktion die Parser ausführt.\n\nDie Funktion muss immer den Wert zurückgeben. Der eingebaute Parser wandelt die Typen `number`, `currency`, `float`, `boolean`, `bool`, `date` und `datetime` um. `PARSER(value, path, type, [format])` führt alle registrierten Parser aus.\n\nExample: Einen Wert parsen\n```js\nconsole.log(PARSER('1 200.5', 'price', 'number')); // 1200.5\nconsole.log(PARSER('on', 'active', 'boolean')); // true\n```\n\n### PLUGIN(name, [fn], [init], [done])\n\nType: `method`\n\nDeklariert ein Plugin oder gibt ein vorhandenes zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Plugins. |\n| `fn` | `Function` | no |  | `function(exports)`. |\n| `init` | `Function|String` | no |  | Läuft vor der Deklaration. Ein String listet Middleware-Namen auf. |\n| `done` | `Function` | no |  | Wird aufgerufen, wenn das Plugin bereit ist. |\n\nReturns: `Plugin` Das Plugin.\n\nDas Thema wird unter [Plugins](../../guides/plugins/) erklärt, und das Objekt ist unter [Plugin](../plugin/) beschrieben.\n\nExample: Ein Plugin deklarieren\n```js\nPLUGIN('users', function(exports) {\n\texports.count = 5;\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.users.count); // 5\n}, 500);\n```\n\n### PLUGINABLE(name, fn, [init])\n\nType: `method`\n\nRegistriert ein Plugin, das bei seinem ersten Aufruf erstellt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Plugins. |\n| `fn` | `Function|String` | yes |  | Die Deklaration oder eine URL. |\n| `init` | `Function|String` | no |  | Läuft vor der Deklaration. |\n\nDie Deklaration kann auch die URL einer Datei sein, die das Plugin deklariert.\n\nExample: Ein Plugin bei Bedarf erstellen\n```js\nPLUGINABLE('reports', function(exports) {\n\texports.open = function() {\n\t\tconsole.log('opened'); // opened\n\t};\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.reports == null); // true\n\tEXEC('reports/open');\n}, 500);\n```\n\n### PLUGINS\n\nType: `property`\n\nEin Objekt mit allen erstellten Plugins nach Namen.\n\nExample: Ein Plugin lesen\n```js\nPLUGIN('users', function(exports) {\n\texports.limit = 10;\n});\nsetTimeout(function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n}, 500);\n```\n\n### PREF\n\nType: `property`\n\nGespeicherte Benutzereinstellungen. Siehe [PREF](../pref/).\n\nExample: Wert lesen\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.theme); // dark\n```\n\n### PUSH(path, value, [delay], [reset])\n\nType: `method`\n\nFügt dem Array auf einem Path einen Wert hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Object|Array` | yes |  | Der Eintrag oder die Einträge, die hinzugefügt werden. |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n| `reset` | `Boolean` | no |  | Mit `true` werden die Komponenten auf dem Path außerdem als nicht berührt und nicht geändert markiert. |\n\nIst der Wert ein Array, wird jeder seiner Einträge hinzugefügt. Enthält der Path kein Array, wird ein neues erstellt. Ein Path, der mit `^` beginnt, fügt am Anfang hinzu. Wie bei [SET()](#set) kann das erste Argument eine Anfrage und `value` der Ziel-Path sein.\n\nExample: Elemente hinzufügen\n```js\nPUSH('tags', 'a');\nPUSH('tags', ['b', 'c']);\nPUSH('^tags', 'first');\nconsole.log(GET('tags')); // [\"first\",\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], obj)\n\nType: `method`\n\nFügt einer URL ein Objekt als Query-String hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Die URL, optional mit einer Methode. |\n| `obj` | `Object` | yes |  | Die Werte. |\n\nReturns: `String` Die URL.\n\nLeere Werte werden übersprungen, Arrays mit einem Komma verbunden, und Datumsangaben verwenden das ISO-Format.\n\nExample: Eine URL aufbauen\n```js\nconsole.log(QUERIFY('GET /users/', { page: 2, tags: ['a', 'b'] })); // GET /users/?page=2&tags=a%2Cb\nconsole.log(QUERIFY({ q: 'x y' })); // ?q=x%20y\n```\n\n### QUEUE([name], fn)\n\nType: `method`\n\nFührt Funktionen nacheinander aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Der Name der Warteschlange. |\n| `fn` | `Function` | yes |  | `function(next, pending)`. |\n\nReturns: `Number` Die Anzahl der wartenden Einträge.\n\nDie Funktion erhält `next` und die Anzahl der wartenden Einträge. Der nächste Eintrag startet, nachdem `next()` aufgerufen wurde.\n\nExample: Der Reihe nach ausführen\n```js\nQUEUE('tasks', function(next) {\n\tsetTimeout(next, 50);\n});\nQUEUE('tasks', function(next, pending) {\n\tconsole.log('second', pending); // second 0\n\tnext();\n});\n```\n\n### RECONFIGURE(selector, value)\n\nType: `method`\n\nÄndert die Konfiguration aller passenden Komponenten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Ein Selektor wie bei [FIND()](#find). |\n| `value` | `Object|String` | yes |  | Die neue Konfiguration. |\n\nExample: Konfiguration ändern\n```js\nON('ready', function() {\n\tRECONFIGURE('box', { size: 10 });\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### REDIRECT(url)\n\nType: `method`\n\nNavigiert zu einer URL. Siehe [Routing](../../guides/routing/).\n\n### REMOVECACHE(key)\n\nType: `method`\n\nEntfernt einen Wert aus dem Browser-Cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Schlüssel. |\n\nExample: Einen Wert entfernen\n```js\nCACHE('profile', 'Peter', '1 day');\nREMOVECACHE('profile');\nconsole.log(CACHE('profile') === undefined); // true\n```\n\n### REPEAT([condition], process, delay, [init])\n\nType: `method`\n\nFührt eine Funktion wiederholt aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | no |  | Die Bedingung. |\n| `process` | `Function` | yes |  | `function(counter, scope)`. |\n| `delay` | `Number` | yes |  | Die Verzögerung in Millisekunden. |\n| `init` | `Boolean` | no |  | Mit `true` startet der erste Durchlauf sofort. |\n\nDie Bedingung ist eine Funktion oder ein Path, und der Durchlauf wird übersprungen, solange sie nicht erfüllt ist. Mit der Form `path__expression` erhält der Ausdruck die Variable `value`. Solange die Seite im Hintergrund ist, läuft nichts, außer `DEF.repeatfocus` hat den Wert `false`.\n\nExample: Alle 100 ms ausführen\n```js\nREPEAT(function(counter) {\n\tif (counter === 3)\n\t\tconsole.log('third run'); // third run\n}, 100);\n```\n\n### REPO\n\nType: `property`\n\nEin leeres Objekt für deine eigenen gemeinsamen Daten.\n\nExample: Wert lesen\n```js\nREPO.items = [1, 2];\nconsole.log(REPO.items.length); // 2\n```\n\n### RESET(path, [delay])\n\nType: `method`\n\nMarkiert die Komponenten auf einem Path als nicht berührt und nicht geändert und validiert sie erneut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter. |\n| `delay` | `Number` | no |  | Eine Verzögerung in Millisekunden. |\n\nExample: Ein Formular zurücksetzen\n```js\nON('ready', function() {\n\tSET('form.name', 'Peter');\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n\tRESET('form.*');\n\tconsole.log(MODIFIED('form.*').length); // 0\n});\n```\n\n### RETURN(command, [multiple])\n\nType: `method`\n\nLiest eine Eigenschaft einer Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `command` | `String` | yes |  | Der Selektor und die Eigenschaft. |\n| `multiple` | `Boolean` | no |  | Mit `true` wird von allen passenden Komponenten gelesen. |\n\nReturns: `Object|Array` Der Wert oder mit `multiple` ein Array.\n\nDer Befehl hat die Form `selector/property`.\n\nExample: Eine Eigenschaft lesen\n```js\nON('ready', function() {\n\tconsole.log(RETURN('box/title')); // Box\n\tconsole.log(RETURN('box/title', true)); // [\"Box\"]\n});\n```\n\n### REWRITE(path, value, [type])\n\nType: `method`\n\nSchreibt einen Wert, ohne Komponenten zu aktualisieren.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `type` | `Number` | no |  | Der Änderungstyp, der an die Watcher übergeben wird. |\n\nDatenbindungen und Watcher laufen trotzdem. Verwende das Flag `@nowatch`, um die Watcher zu überspringen.\n\nExample: Ohne Aktualisierung der Komponenten schreiben\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nREWRITE('user.name', 'Peter');\n```\n\n### REWRITE2(path, value, [type])\n\nType: `method`\n\nSchreibt einen Wert, ohne Komponenten oder Datenbindungen zu aktualisieren.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `type` | `Number` | no |  | Der Änderungstyp, der an die Watcher übergeben wird. |\n\nWatcher laufen trotzdem.\n\nExample: Ohne Bindungen schreiben\n```js\nREWRITE2('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\n```\n\n### ROUTE(url, fn, [middleware], [init])\n\nType: `method`\n\nDeklariert eine Route. Siehe [Routing](../../guides/routing/).\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\nDie Optionen:\n\n| Option | Typ | Beschreibung |\n| --- | --- | --- |\n| `orientation` | String | `x` oder `y`. Ohne Angabe beide Richtungen |\n| `visibleX`, `visibleY` | Boolean | Hält die Scrollbar sichtbar |\n| `native` | Boolean | Verwendet die Scrollbar des Browsers |\n| `wrap` | Boolean | Mit `false` wird der Inhalt nicht umschlossen |\n| `controls` | jQuery | Das Element für die Scrollbar-Steuerelemente |\n| `shadow` | Boolean | Fügt an den Rändern Schatten hinzu |\n| `padding` | Number | Der Innenabstand der Balken. Standardwert: `5` |\n| `minsize` | Number | Die kleinste Größe eines Balkens. Standardwert: `50` |\n| `thickness` | Number | Die Dicke eines Balkens. Standardwert: `10` |\n| `margin`, `marginX`, `marginY` | Number | Die Außenabstände |\n| `offsetX`, `offsetY` | Number | Wird zur Größe der Ansicht addiert |\n| `parent` | String oder Element | Übernimmt die Größe von diesem übergeordneten Element |\n| `autoresize` | Boolean | Mit `false` wird die Größe beim Ändern der Fenstergröße nicht geprüft |\n| `interval` | Number | Das Intervall der Größenprüfung |\n| `onscroll`, `onidle`, `onresize` | Function | Handler, die die Scrollbar erhalten |\n\nDas zurückgegebene Objekt hat die Methoden `scrollTop([value])`, `scrollLeft([value])`, `scrollBottom([value])`, `scrollRight([value])`, `scroll(x, y)`, `resize()`, `check()`, `sync(element, [offset])`, `unsync()` und `destroy()`.\n\nExample: Eine Scrollbar erstellen\n```html\n<div id=\"box\" style=\"height:100px\"><div style=\"height:500px\"></div></div>\n<script>\nvar scrollbar = SCROLLBAR($('#box'), { orientation: 'y' });\nconsole.log(typeof(scrollbar.scrollTop)); // function\nconsole.log(M.scrollbars.length); // 1\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nGibt die Breite der Browser-Scrollbar in Pixeln zurück.\n\nReturns: `Number` Die Breite.\n\nExample: Die Breite lesen\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(target, [a], [b], [c], [d])\n\nType: `method`\n\nRuft je nach Ziel eine Funktion auf oder schreibt einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Function|String` | yes |  | Eine Funktion, eine Methode oder ein 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\nEine Funktion wird aufgerufen. Ein String mit `/` oder ein Path, der eine Funktion enthält, geht an [EXEC()](#exec). Jeder andere String ist ein Path, in den das erste Argument geschrieben wird.\n\nExample: Funktion oder Path\n```js\nSEEX(value => console.log(value), 1); // 1\nSEEX('result.value', 2);\nconsole.log(GET('result.value')); // 2\n```\n\n### SET(path, value, [delay], [reset])\n\nType: `method`\n\nSchreibt einen Wert in einen Path und aktualisiert alles, was daran gebunden ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n| `reset` | `Boolean` | no |  | Mit `true` werden die Komponenten auf dem Path außerdem als nicht berührt und nicht geändert markiert. |\n\nKomponenten, Bindungen und Watcher auf dem Path werden aktualisiert. Das dritte Argument kann auch `true` sein, was den Zustand der Komponenten sofort zurücksetzt.\n\nEin Path, der mit `+` beginnt, fügt den Wert wie [PUSH()](#push) einem Array hinzu. Ein Path, der mit `~` beginnt, führt ihn wie [EXT()](#ext) zusammen. Auf den Path können Flags folgen: siehe [Flags und Path-Modifikatoren](../../guides/flags/).\n\nIst das erste Argument eine Anfrage wie `GET /api/users/`, wird die Antwort in den als `value` angegebenen Path geschrieben.\n\nExample: Wert schreiben\n```js\nSET('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\nExample: Das Schreiben verzögern\n```js\nSET('search', 'first', 100);\nSET('search', 'second', 100);\nsetTimeout(function() {\n\tconsole.log(GET('search')); // second\n}, 300);\n```\n\nExample: Eine Antwort speichern\n```js\nSET('GET /api/users/', 'users.response');\nsetTimeout(function() {\n\tconsole.log(GET('users.response.url')); // /api/users/\n}, 200);\n```\n\n### SETTER(selector, method, [...args])\n\nType: `method`\n\nRuft eine Methode aller passenden Komponenten auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Ein Selektor wie bei [FIND()](#find). |\n| `method` | `String` | yes |  | Der Name der Methode. |\n| `...args` | `Object` | no |  | Die Argumente der Methode. |\n\nSelektor und Methode lassen sich als `selector/method` verbinden. Mit `true` als erstem Argument wartet der Aufruf auf die Komponente. Ein Selektor, der mit `!` beginnt, startet keine Lazy-Komponente.\n\nExample: Methode aufrufen\n```js\n// The component logs 'Hello ' + name\nON('ready', function() {\n\tSETTER('box', 'hello', 'Peter');\n\tSETTER('box/hello', 'Anna');\n});\n```\n\n### setTimeout2(name, fn, delay, [limit], [arg])\n\nType: `method`\n\nStartet einen benannten Timer und bricht den vorherigen Timer mit demselben Namen ab.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Timers. |\n| `fn` | `Function` | yes |  | Die Funktion. |\n| `delay` | `Number` | yes |  | Die Verzögerung in Millisekunden. |\n| `limit` | `Number` | no |  | Wie oft der Timer verschoben werden kann. |\n| `arg` | `Object` | no |  | Das Argument der Funktion. |\n\nReturns: `String` Der Name des Timers.\n\nMit einem Limit wird der Timer höchstens so oft verschoben, sodass die Funktion auch bei ständigen Aufrufen noch läuft.\n\nExample: Nur den letzten Aufruf behalten\n```js\nfunction search(value) {\n\tconsole.log(value); // last\n}\nsetTimeout2('search', search, 50, null, 'first');\nsetTimeout2('search', search, 50, null, 'last');\n```\n\n### STOPDEBUG()\n\nType: `method`\n\nHält den Browser-Debugger immer wieder an, solange die Entwicklertools geöffnet sind.\n\nDie Funktion wiederholt sich alle 5 Sekunden und lässt sich nicht stoppen.\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 | `DEF.jsoncompress` | Komprimiert die Ausgabe. |\n| `fields` | `Array|Object|Function` | no |  | Ein Array erlaubter Felder, ein Objekt mit `field: false` oder `function(key, value)`. |\n| `encrypt` | `Boolean` | no |  | Verschlüsselt die Ausgabe mit dem Schlüssel aus `DEF.secret()`. |\n\nReturns: `String` Das JSON.\n\nDie Komprimierung kürzt Strings und entfernt leere Strings, `false` und `null`.\n\nExample: Einen Wert serialisieren\n```js\nconsole.log(STRINGIFY({ a: 1, b: '', c: false }, true)); // {\"a\":1}\nconsole.log(STRINGIFY({ a: 1, b: 2 }, false, ['b'])); // {\"b\":2}\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 Styles. Das Element erhält die id `css` plus diesen Wert. |\n| `selector` | `String` | no |  | Ein Selektor, der die Regeln umschließt. |\n\nEin vorhandener Style mit derselben Kennung wird ersetzt. Vor jede Regel wird ein Selektor gesetzt. `CSS()` ist dieselbe Funktion.\n\nExample: CSS mit Selektor hinzufügen\n```js\nSTYLE('b { color: red }', 'mystyle', '#panel');\nconsole.log($('#cssmystyle').html()); // #panel b{ color: red }\n```\n\n### Ta\n\nType: `property`\n\nEin Kurzname für `Tangular`.\n\nExample: Wert lesen\n```js\nconsole.log(Ta === Tangular); // true\n```\n\n### Tangular\n\nType: `property`\n\nDie Template-Engine. Siehe [Templates mit Tangular](../../guides/tangular/).\n\nExample: Wert lesen\n```js\nconsole.log(Tangular.render('Hello {{ name }}', { name: 'Peter' })); // Hello Peter\n```\n\n### TAPI(name, [data], [callback])\n\nType: `method`\n\nRuft eine API mit [DAPI()](#dapi) auf, wenn `DEF.api` gesetzt ist, andernfalls mit [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Schemas. |\n| `data` | `Object` | no |  | Die Daten. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` oder ein Path. |\n\nReturns: `Object|Promise` Das Ergebnis der ausgewählten Funktion.\n\nExample: Den Transport auswählen\n```js\nDEF.api = '/api/';\nTAPI('users_list', null, function(response) {\n\tconsole.log(response.url); // /api/\n});\n```\n\n### TEMP\n\nType: `property`\n\nEin Objekt für temporäre Daten.\n\nDie Bibliothek ersetzt es alle fünf Minuten durch ein leeres Objekt.\n\nExample: Wert lesen\n```js\nTEMP.value = 5;\nconsole.log(TEMP.value); // 5\n```\n\n### Thelpers\n\nType: `property`\n\nDie Helper der Template-Engine. Siehe [Tangular-Helper](../tangular-helpers/).\n\nExample: Wert lesen\n```js\nconsole.log(typeof(Thelpers)); // object\n```\n\n### TOGGLE(path, [delay], [reset])\n\nType: `method`\n\nSchreibt den entgegengesetzten booleschen Wert in einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n| `reset` | `Boolean` | no |  | Mit `true` werden die Komponenten auf dem Path außerdem als nicht berührt und nicht geändert markiert. |\n\nExample: Wert umschalten\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### TRANSLATE(text)\n\nType: `method`\n\nErsetzt jedes `@(text)` durch seine Übersetzung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Der Text. |\n\nReturns: `String` Der übersetzte Text.\n\nDer Schlüssel in `DEF.dictionary` ist `HASH(text).toString(36)`, optional mit dem Präfix `T`. Text ohne Übersetzung bleibt in der Originalsprache.\n\nExample: Text übersetzen\n```js\nDEF.dictionary[HASH('Hello').toString(36)] = 'Ahoj';\nconsole.log(TRANSLATE('@(Hello), @(Peter)')); // Ahoj, Peter\n```\n\n### UNAUTHORIZED(...roles)\n\nType: `method`\n\nGibt an, ob dem aktuellen Benutzer alle angegebenen Rollen fehlen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...roles` | `String` | yes |  | Die Rollen. |\n\nReturns: `Boolean` `true`, wenn der Benutzer keine der Rollen hat.\n\nDer Benutzer wird aus `window.user` gelesen. Die Felder `sa` und `su` erlauben alles, und die Rollen stammen aus `permissions` oder `roles`, als Array oder Objekt.\n\nExample: Eine Rolle prüfen\n```js\nwindow.user = { roles: ['editor'] };\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [fn])\n\nType: `method`\n\nEntfernt einen Watcher.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der überwachte Path. |\n| `fn` | `Function` | no |  | Die an [WATCH()](#watch) übergebene Funktion. |\n\nOhne Funktion werden alle Watcher des Paths entfernt.\n\nExample: Die Beobachtung beenden\n```js\nvar count = 0;\nvar fn = () => count++;\nWATCH('value', fn);\nSET('value', 1);\nUNWATCH('value', fn);\nSET('value', 2);\nconsole.log(count); // 1\n```\n\n### UPD(path, [delay], [reset])\n\nType: `method`\n\nTeilt der Bibliothek mit, dass sich der Wert auf einem Path geändert hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path des Werts. Siehe [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Eine Zahl ab 10 verzögert die Änderung um so viele Millisekunden. Eine kleinere Zahl ist der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n| `reset` | `Boolean` | no |  | Mit `true` werden die Komponenten auf dem Path außerdem als nicht berührt und nicht geändert markiert. |\n\nVerwende die Funktion, nachdem du ein Objekt direkt geändert hast. Komponenten werden aktualisiert und Watcher aufgerufen. `UPDATE()` ist dieselbe Funktion. Das zweite Argument kann auch `true` sein, was den Zustand der Komponenten zurücksetzt.\n\nExample: Nach einer direkten Änderung aktualisieren\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nUPD('user.name');\n```\n\n### UPDATE(path, [delay], [reset])\n\nType: `method`\n\nDieselbe Funktion wie [UPD()](#upd).\n\nExample: Dieselbe Funktion\n```js\nconsole.log(UPDATE === UPD); // true\n```\n\n### UPLOAD(url, data, [callback], [delay], [progress])\n\nType: `method`\n\nLädt Daten auf einen Server hoch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL, optional mit einer Methode. |\n| `data` | `FormData|Object` | yes |  | Die Daten. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` oder ein Path. |\n| `delay` | `Number` | no |  | Wartet vor dem Senden so viele Millisekunden. |\n| `progress` | `Function|String` | no |  | `function(percentage)` oder ein Path. |\n\nReturns: `Promise` Nur wenn kein Callback angegeben ist.\n\nDie Standardmethode ist `POST`. `FormData` wird unverändert gesendet, alles andere als JSON. Ohne Callback gibt die Funktion ein Promise zurück. `progress` kann das vierte Argument sein, wenn keine Verzögerung nötig ist.\n\nExample: Eine Datei hochladen\n```js\nvar data = new FormData();\ndata.append('name', 'photo.jpg');\nUPLOAD('/api/upload/', data, function(response) {\n\tconsole.log(response.url); // /api/upload/\n});\n```\n\n### VALID(path, [flags])\n\nType: `method`\n\nGibt an, ob keine Komponente auf einem Path ungültig ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit `.*` für alles darunter. |\n| `flags` | `String|Array` | no |  | `visible` oder `hidden` beschränkt die Prüfung auf diese Komponenten. |\n\nReturns: `Boolean` Das Ergebnis.\n\nAnders als [CAN()](#can) berücksichtigt die Funktion nicht, ob die Komponenten berührt wurden.\n\nExample: Ein Formular prüfen\n```js\nON('ready', function() {\n\tconsole.log(VALID('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tconsole.log(VALID('form.*')); // true\n});\n```\n\n### VBIND(html)\n\nType: `method`\n\nErstellt aus HTML einen virtuellen Binder.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | Das HTML mit Bindungen. |\n\nReturns: `VBinder` Der virtuelle Binder.\n\nDas Objekt ist unter [Virtueller Binder](../vbinder/) beschrieben, das Thema unter [Virtuelle Bindungen](../../guides/virtual-bindings/).\n\nExample: Ein losgelöstes Element binden\n```js\nvar binder = VBIND('<div><span data-bind=\"name__text\"></span></div>');\nbinder.set({ name: 'Peter' });\nconsole.log(binder.element.find('span').text()); // Peter\n```\n\n### VBINDARRAY(html, element)\n\nType: `method`\n\nRendert ein Array mit einem virtuellen Binder für jeden Eintrag.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | Das HTML eines Eintrags. |\n| `element` | `Element|jQuery|Component` | yes |  | Das übergeordnete Element. |\n\nReturns: `Object` Ein Objekt mit den Methoden `set()`, `get()`, `upd()` und `remove()`.\n\nDas Thema wird unter [Virtuelle Bindungen](../../guides/virtual-bindings/) erklärt.\n\nExample: Liste rendern\n```html\n<ul id=\"list\"></ul>\n<script>\nvar list = VBINDARRAY('<li data-bind=\"name__text\"></li>', $('#list'));\nlist.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log($('#list').text()); // PeterAnna\n</script>\n```\n\n### VERSION(...items)\n\nType: `method`\n\nWählt die Version von Komponenten aus, die ohne Version verwendet werden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...items` | `String` | yes |  | Die Komponenten und ihre Versionen. |\n\nJeder Eintrag hat die Form `name@version`, und ein String kann mehrere Einträge enthalten, getrennt durch ein Komma.\n\nExample: Eine Version auswählen\n```html\n<ui-component name=\"tag\"></ui-component>\n<script>\nCOMPONENT('tag@2', function(self) {\n\tself.make = () => self.element.text('two');\n});\nVERSION('tag@2');\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // two\n});\n</script>\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nGibt an, ob sich ein Element im sichtbaren Höhenbereich des Fensters befindet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Das Element. |\n| `threshold` | `Number` | no | `0` | Ein Rand in Pixeln. |\n| `mode` | `String` | no | `visible` | `visible`, `above` oder `below`. |\n\nReturns: `Boolean` Das Ergebnis.\n\nExample: Ein Element prüfen\n```html\n<div id=\"box\">Box</div>\n<script>\nconsole.log(VISIBLE($('#box'))); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nEin Kurzname für `window`.\n\nExample: Wert lesen\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback, [interval], [timeout])\n\nType: `method`\n\nWartet, bis eine Bedingung erfüllt ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Die Funktion oder der Path, die geprüft werden. |\n| `callback` | `Function` | yes |  | `function(err, again)`. |\n| `interval` | `Number` | no | `500` | Das Prüfintervall in Millisekunden. |\n| `timeout` | `Number` | no |  | Die längste Wartezeit in Millisekunden. |\n\nDie Bedingung ist eine Funktion oder ein Path. Der Callback erhält nach einem Timeout einen Fehler und eine Funktion, die das Warten erneut startet. Ohne Timeout endet das Warten nie von selbst.\n\nExample: Auf einen Wert warten\n```js\nWAIT('app.ready', function() {\n\tconsole.log(GET('app.ready')); // true\n}, 50);\nsetTimeout(() => SET('app.ready', true), 100);\n```\n\nExample: Nach einem Timeout stoppen\n```js\nWAIT(() => false, function(err) {\n\tconsole.log(err.message); // Timeout.\n}, 50, 200);\n```\n\n### WAPI([name], [data], [callback], [timeout])\n\nType: `method`\n\nRuft eine API über die WebSocket-Verbindung auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | no |  | Der Name des Schemas oder die Verbindungsoptionen. |\n| `data` | `Object` | no |  | Die Daten. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` oder ein Path. |\n| `timeout` | `Number` | no | `10000` | Der Timeout in Millisekunden. |\n\nReturns: `Object|Promise` Die Verbindung oder ein Promise.\n\nEin Objekt als erstes Argument öffnet die Verbindung wie [WAPI_INIT()](#wapi-init). Ohne Argumente gibt die Funktion die offene Verbindung zurück. Ohne Callback gibt sie ein Promise zurück. Der Standard-Timeout eines Aufrufs beträgt 10 Sekunden.\n\nExample: Über einen Socket aufrufen\n```js\nWAPI({ url: '/api/' });\nWAPI('users_list', null, function(response) {\n\tconsole.log(response.schema); // users_list\n});\n```\n\n### WAPI_INIT(options)\n\nType: `method`\n\nÖffnet die von [WAPI()](#wapi) verwendete WebSocket-Verbindung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Die Verbindungsoptionen. |\n\nReturns: `Object` Das Optionsobjekt mit den hinzugefügten Methoden.\n\nDie Optionen sind `url`, `reconnect` (eine Verzögerung in Millisekunden oder `false`), `expire` (verbindet sich nach dieser Zeit neu), `callback` (wird einmal nach dem ersten Verbindungsversuch aufgerufen) und die Handler `open`, `close(e)` und `message(data)`.\n\nDas zurückgegebene Objekt hat die Methoden `send(name, data, callback, [timeout])`, `on(name, fn)` für die Events `open`, `close`, `message` und `reconnect`, `emit(name, ...)` und `pause(is)`.\n\nExample: Eine Verbindung öffnen\n```js\nWAPI_INIT({\n\turl: '/api/',\n\topen: function() {\n\t\tconsole.log('connected'); // connected\n\t}\n});\nconsole.log(typeof(WAPI().send)); // function\n```\n\n### WARN(...args)\n\nType: `method`\n\nSchreibt eine Warnung in die Konsole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...args` | `Object` | yes |  | Die Werte, die geschrieben werden. |\n\nExample: Eine Warnung schreiben\n```js\nWARN('Disk is full');\nconsole.log(typeof(WARN)); // function\n```\n\n### WATCH(path, fn, [init])\n\nType: `method`\n\nRuft eine Funktion auf, wenn sich der Wert auf einem Path ändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, der überwacht wird. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n| `init` | `Boolean` | no |  | Mit `true` wird die Funktion außerdem sofort aufgerufen. |\n\nDie Funktion erhält den geänderten Path, den Wert und den Änderungstyp: `0` erster Aufruf, `1` manuell, `2` Eingabe, `3` Standardwert. Ein Path `users.*` reagiert auch auf alles unterhalb von `users`. Mehrere Paths kannst du durch ein Leerzeichen trennen, und ein Path, der mit `^` beginnt, läuft vor den anderen Watchern.\n\nExample: Auf eine Änderung reagieren\n```js\nWATCH('user.name', function(path, value, type) {\n\tconsole.log(path, value, type); // user.name Peter 1\n});\nSET('user.name', 'Peter');\n```\n\nExample: Sofort aufrufen\n```js\nSET('count', 5);\nWATCH('count', function(path, value, type) {\n\tconsole.log(value, type); // 5 0\n}, true);\n```\n\n### WATCHONCE(path, fn)\n\nType: `method`\n\nRuft eine Funktion nur bei der nächsten Änderung eines Paths auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, der überwacht wird. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n\nExample: Einmal reagieren\n```js\nWATCHONCE('count', function(path, value) {\n\tconsole.log(value); // 1\n});\nSET('count', 1);\nSET('count', 2);\n```\n\n### WH\n\nType: `property`\n\nDie Höhe des Fensters in Pixeln.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(WH)); // number\n```\n\n### WIDTH([element])\n\nType: `method`\n\nGibt die Anzeigegröße des Fensters oder eines Elements zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | Das Element. |\n\nReturns: `String` `xs`, `sm`, `md` oder `lg`.\n\nDie Grenzwerte stehen in `DEF.devices`.\n\nExample: Die Größe eines Elements lesen\n```html\n<div id=\"box\" style=\"width:1000px\"></div>\n<script>\nconsole.log(WIDTH($('#box'))); // md\n</script>\n```\n\n### WORKFLOW(declaration, [tasks], [callback])\n\nType: `method`\n\nFührt benannte Schritte aus, die einen Wert weitergeben.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `declaration` | `Function` | yes |  | `function($)`. |\n| `tasks` | `Object` | no |  | Die Schritte nach Namen. |\n| `callback` | `Function` | no |  | `function(value, err, $)`. |\n\nReturns: `Object` Der Workflow.\n\nDas Objekt, das an die Deklaration und an jeden Schritt übergeben wird, hat diese Member:\n\n| Member | Beschreibung |\n| --- | --- |\n| `push(name, fn)` | Fügt einen Schritt hinzu: `function($, value)` |\n| `next(name, [value])` | Führt einen Schritt aus. Ein unbekannter Name beendet den Workflow |\n| `next2(name)` | Gibt einen Callback zurück, der den Schritt ausführt |\n| `done([value])` | Ruft den abschließenden Callback mit dem Wert auf |\n| `invalid(err)` | Meldet einen Fehler an `error` oder an den abschließenden Callback |\n| `callback(fn)` | Ersetzt den abschließenden Callback |\n| `clone()` | Erstellt einen Workflow mit denselben Schritten |\n| `destroy()` | Beendet den Workflow |\n| `value`, `current`, `prev` | Der Wert, der aktuelle Schritt und der vorherige Schritt |\n\nExample: Zwei Schritte ausführen\n```js\nWORKFLOW(function($) {\n\t$.push('load', ($, value) => $.next('save', value + 1));\n\t$.push('save', ($, value) => $.done(value * 2));\n\t$.next('load', 1);\n}, function(value) {\n\tconsole.log(value); // 4\n});\n```\n\n### WW\n\nType: `property`\n\nDie Breite des Fensters in Pixeln.\n\nExample: Wert lesen\n```js\nconsole.log(typeof(WW)); // number\n```\n","entries":[{"type":"method","name":"ACMD()","signature":"ACMD(name, [...args])","since":"","deprecated":false},{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"ADD()","signature":"ADD(value, [element], [config], [content])","since":"","deprecated":false},{"type":"method","name":"AEXEC()","signature":"AEXEC(path, [...args])","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], [callback], [delay])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHE()","signature":"AJAXCACHE(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHEREVIEW()","signature":"AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCONFIG()","signature":"AJAXCONFIG(name, fn)","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BIND()","signature":"BIND(path)","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(name, 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, [rebind])","since":"","deprecated":false},{"type":"method","name":"CAN()","signature":"CAN(path, [flags])","since":"","deprecated":false},{"type":"method","name":"CHANGE()","signature":"CHANGE(path, [value])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, callback)","since":"","deprecated":false},{"type":"method","name":"CL_INIT()","signature":"CL_INIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [nopath])","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], [e])","since":"","deprecated":false},{"type":"method","name":"COMPILE()","signature":"COMPILE([container])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], declaration, [dependencies])","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":"method","name":"DAPI()","signature":"DAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"method","name":"DEBUG()","signature":"DEBUG()","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DEFAULT()","signature":"DEFAULT(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"DISABLED()","signature":"DISABLED(path, [flags])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [...args])","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(value, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, [flags], [highlight])","since":"","deprecated":false},{"type":"method","name":"EVALUATE()","signature":"EVALUATE(path, expression, [nopath])","since":"","deprecated":false},{"type":"method","name":"EXE()","signature":"EXE([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXT()","signature":"EXT(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTEND()","signature":"EXTEND(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], declaration)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [many], [nocache], [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(expression)","since":"","deprecated":false},{"type":"method","name":"FORMATTER()","signature":"FORMATTER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE([delay])","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [scope])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([size])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value, [unsigned])","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"IMPORTCACHE()","signature":"IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value], [delay], [reset])","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":"method","name":"MACRO()","signature":"MACRO(name, declaration)","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"method","name":"MAKE()","signature":"MAKE([target], fn, [update])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, fn)","since":"","deprecated":false},{"type":"method","name":"MODIFIED()","signature":"MODIFIED(path, [flags])","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"property","name":"NAV","signature":"NAV","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, target, [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":"method","name":"NOTIFY()","signature":"NOTIFY(...paths)","since":"","deprecated":false},{"type":"method","name":"NOTMODIFIED()","signature":"NOTMODIFIED(path, [value], [fields])","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"NULL()","signature":"NULL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [path], [fn])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, [path], fn, [init])","since":"","deprecated":false},{"type":"method","name":"OPT()","signature":"OPT([obj], fn)","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value, [date])","since":"","deprecated":false},{"type":"method","name":"PARSER()","signature":"PARSER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [fn], [init], [done])","since":"","deprecated":false},{"type":"method","name":"PLUGINABLE()","signature":"PLUGINABLE(name, fn, [init])","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, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], obj)","since":"","deprecated":false},{"type":"method","name":"QUEUE()","signature":"QUEUE([name], fn)","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT(url)","since":"","deprecated":false},{"type":"method","name":"REMOVECACHE()","signature":"REMOVECACHE(key)","since":"","deprecated":false},{"type":"method","name":"REPEAT()","signature":"REPEAT([condition], process, delay, [init])","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path, [delay])","since":"","deprecated":false},{"type":"method","name":"RETURN()","signature":"RETURN(command, [multiple])","since":"","deprecated":false},{"type":"method","name":"REWRITE()","signature":"REWRITE(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"REWRITE2()","signature":"REWRITE2(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"ROUTE()","signature":"ROUTE(url, fn, [middleware], [init])","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(target, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, fn, delay, [limit], [arg])","since":"","deprecated":false},{"type":"method","name":"STOPDEBUG()","signature":"STOPDEBUG()","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":"property","name":"Ta","signature":"Ta","since":"","deprecated":false},{"type":"property","name":"Tangular","signature":"Tangular","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"property","name":"Thelpers","signature":"Thelpers","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...roles)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [fn])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPDATE()","signature":"UPDATE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPLOAD()","signature":"UPLOAD(url, data, [callback], [delay], [progress])","since":"","deprecated":false},{"type":"method","name":"VALID()","signature":"VALID(path, [flags])","since":"","deprecated":false},{"type":"method","name":"VBIND()","signature":"VBIND(html)","since":"","deprecated":false},{"type":"method","name":"VBINDARRAY()","signature":"VBINDARRAY(html, element)","since":"","deprecated":false},{"type":"method","name":"VERSION()","signature":"VERSION(...items)","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, [interval], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI()","signature":"WAPI([name], [data], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI_INIT()","signature":"WAPI_INIT(options)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...args)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, fn, [init])","since":"","deprecated":false},{"type":"method","name":"WATCHONCE()","signature":"WATCHONCE(path, fn)","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"method","name":"WORKFLOW()","signature":"WORKFLOW(declaration, [tasks], [callback])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammaB9IM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/globals/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Funciones globales","summary":"Las funciones y los objetos que jComponent añade al objeto window.","markdown":"---\ntitle: Funciones globales\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/globals/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Funciones globales\n\n> Las funciones y los objetos que jComponent añade al objeto window.\n\njComponent añade estas funciones y objetos a `window`, así que puedes usarlos en cualquier lugar sin importar nada. Para saber primero cómo funcionan los paths, lee [Paths](../../guides/paths/).\n\n## API\n\n### ACMD(name, [...args])\n\nType: `method`\n\nCrea una función que llama a [CMD()](#cmd) más adelante.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n| `...args` | `Object` | no |  | Los primeros argumentos. |\n\nReturns: `Function` La función a la que se llama.\n\nEl argumento de la función creada se añade como último argumento del comando.\n\nExample: Usarla como callback\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nACMD('refresh')(1);\n```\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrepara el texto importado para un path y un identificador.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El valor de `~PATH~` y `CLASS`. |\n| `id` | `String` | yes |  | El valor de `~ID~`. |\n| `text` | `String` | yes |  | El texto. |\n\nReturns: `String` El texto modificado.\n\nEl texto se traduce, las variables `--name--` se sustituyen, `~CDN~` se convierte en `DEF.cdn`, `~PATH~` y `CLASS` se convierten en el path, y `~ID~` se convierte en el identificador.\n\nExample: Sustituir los marcadores\n```js\nconsole.log(ADAPT('users', 'form1', '~PATH~ and ~ID~')); // users and form1\n```\n\n### ADD(value, [element], [config], [content])\n\nType: `method`\n\nAñade un componente a la página.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object|Array` | yes |  | El componente. |\n| `element` | `Element|jQuery|Component` | no | `document.body` | El elemento padre. |\n| `config` | `Object|String` | no |  | La configuración. |\n| `content` | `String` | no |  | El HTML interior. |\n\nUna cadena tiene la forma `name__path__config`. Un `!` inicial omite el componente si ya está declarado. Un objeto puede tener los campos `name`, `path`, `config`, `element` y `prepend`. Un array añade varios componentes.\n\nExample: Añadir un componente\n```js\nADD('box__data.title__size:10');\nsetTimeout(function() {\n\tconsole.log(FIND('box').config.size); // 10\n}, 1200);\n```\n\n### AEXEC(path, [...args])\n\nType: `method`\n\nCrea una función que llama a [EXEC()](#exec) más adelante.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El destino. |\n| `...args` | `Object` | no |  | Los primeros argumentos. |\n\nReturns: `Function` La función a la que se llama.\n\nEl argumento de la función creada se añade como último argumento.\n\nExample: Usarla como callback\n```js\nwindow.save = value => console.log(value); // 5\nAEXEC('save')(5);\n```\n\n### AJAX(url, [data], [callback], [delay])\n\nType: `method`\n\nEnvía una petición HTTP.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El método y la URL. |\n| `data` | `Object|String` | no |  | Los datos. Una petición `GET` los envía en la cadena de consulta. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` o un path. |\n| `delay` | `Number` | no |  | Espera estos milisegundos antes de enviar. |\n\nReturns: `Promise` Solo cuando no se indica ningún callback.\n\nLa URL tiene la forma `METHOD /path/`. Pueden seguirla más elementos, separados por un espacio:\n\n| Elemento | Significado |\n| --- | --- |\n| `!METHOD` | Envía las cookies con la petición |\n| `{ \"Name\": \"value\" }` | Cabeceras de la petición |\n| `<5 minutes>` | Guarda la respuesta en caché, como en [AJAXCACHE()](#ajaxcache) |\n| `(name)` | Aplica los ajustes de [AJAXCONFIG()](#ajaxconfig) |\n| `repeat` | Repite la petición cuando el servidor no está disponible |\n| `cancel` | Cancela la petición anterior sin terminar a la misma URL |\n| `urlencoded` | Envía los datos como un formulario codificado en URL |\n| `json` | Acepta solo una respuesta JSON |\n| `error` | Pasa la respuesta por [ERROR()](#error) |\n| `noencrypt`, `nodecrypt`, `nocsrf` | Omite el cifrado, el descifrado o la cabecera CSRF |\n| `#id` | Da nombre a la petición para `cancel`, o espera a una lista de códigos |\n| `@flag` | Emite un flag personalizado |\n\nEl callback recibe la respuesta, el código de estado si hay un error y un objeto con los detalles de la petición. Un callback de tipo cadena es un path donde se guarda la respuesta. Sin callback, la función devuelve una Promise, que se rechaza con un estado superior a 399.\n\nExample: Enviar datos\n```js\nAJAX('POST /api/users/', { name: 'Peter' }, function(response, err) {\n\tconsole.log(response.method, response.url); // POST /api/users/\n\tconsole.log(response.body); // {\"name\":\"Peter\"}\n});\n```\n\nExample: Usar una Promise\n```js\n(async function() {\n\tvar response = await AJAX('GET /api/users/');\n\tconsole.log(response.url); // /api/users/\n})();\n```\n\nExample: Gestionar un error\n```js\nAJAX('GET /api/missing/', function(response, err) {\n\tconsole.log(err, response); // 404 Not found\n});\n```\n\n### AJAXCACHE(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nEnvía una petición y guarda la respuesta en caché.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El método y la URL. |\n| `data` | `Object` | no |  | Los datos. |\n| `callback` | `Function|String` | yes |  | `function(response, cached)` o un path. |\n| `expire` | `String` | yes |  | Por ejemplo, `5 minutes` o `session`. |\n| `delay` | `Number` | no |  | Espera estos milisegundos antes de leer. |\n| `clear` | `Boolean` | no |  | Con `true`, ignora la respuesta guardada. |\n\nEl callback recibe la respuesta y `true` cuando procede de la caché. El valor `session` en `expire` conserva la respuesta en memoria hasta que se recarga la página.\n\nExample: Guardar una respuesta en caché\n```js\nAJAXCACHE('GET /api/users/', function(response, cached) {\n\tconsole.log('first', cached); // first false\n\tAJAXCACHE('GET /api/users/', function(response, cached) {\n\t\tconsole.log('second', cached); // second true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nDevuelve la respuesta en caché y luego comprueba si el servidor tiene una más reciente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El método y la URL. |\n| `data` | `Object` | no |  | Los datos. |\n| `callback` | `Function|String` | yes |  | `function(response, cached, updated)` o un path. |\n| `expire` | `String` | yes |  | Por ejemplo, `5 minutes`. |\n| `delay` | `Number` | no |  | Espera estos milisegundos antes de leer. |\n| `clear` | `Boolean` | no |  | Con `true`, ignora la respuesta guardada. |\n\nCuando el servidor devuelve datos distintos, el callback se ejecuta de nuevo con `false` y `true` como segundo y tercer argumento.\n\nExample: Actualizar una respuesta en caché\n```js\nAJAXCACHE('GET /api/time/', function() {\n\tAJAXCACHEREVIEW('GET /api/time/', function(response, cached, updated) {\n\t\tconsole.log(response.value, cached, updated === true); // 2 false true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCONFIG(name, fn)\n\nType: `method`\n\nDeclara ajustes que una petición puede aplicar por nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de los ajustes. |\n| `fn` | `Function` | yes |  | `function(options)`. |\n\nUna petición los aplica con `(name)` en su URL. La función recibe las opciones de la petición.\n\nExample: Añadir una cabecera\n```js\nAJAXCONFIG('secure', function(options) {\n\toptions.headers['X-Token'] = 'abc';\n});\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-Token']); // abc\n\topt.respond({});\n});\nAJAX('GET /api/users/ (secure)', NOOP);\n```\n\n### API(url, [data], [callback])\n\nType: `method`\n\nLlama a un endpoint de la API de Total.js.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El endpoint y el esquema. |\n| `data` | `Object` | no |  | Los datos. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` o un path. |\n\nReturns: `Object|Promise` El objeto descrito arriba o una Promise.\n\nLa URL tiene la forma `/api/ schema`. La petición es un `POST` con el nombre del esquema y los datos en el cuerpo. Sin callback, la función devuelve una Promise. Con callback, devuelve un objeto con `params(value)`, que rellena los parámetros del esquema, y `data(value)`, que sustituye los datos.\n\nExample: Llamar a un endpoint\n```js\nAPI('/api/ users_save', { name: 'Peter' }, function(response) {\n\tconsole.log(response.url); // /api/\n\tconsole.log(response.body); // {\"schema\":\"users_save\",\"data\":{\"name\":\"Peter\"}}\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nDefine el aspecto de la aplicación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Las variables CSS y los campos `dark` y `large`. |\n\nCada campo se convierte en una variable CSS en `:root`. `dark` y `large` activan las clases `ui-dark` y `ui-large` en el body. `color` es un color hexadecimal de seis dígitos, que también define `DEF.color` y la variable `--rgb`.\n\nExample: Usar un tema oscuro\n```js\nAPPEARANCE({ dark: true, color: '#336699' });\nconsole.log($('#cssappearance').html()); // :root{--color:#336699;--rgb:51,102,153}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\n### ASETTER(selector, method, [...args])\n\nType: `method`\n\nCrea una función que llama a [SETTER()](#setter) más adelante.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selector como en [FIND()](#find). |\n| `method` | `String` | yes |  | El nombre del método. |\n| `...args` | `Object` | no |  | Los primeros argumentos del método. |\n\nReturns: `Function` La función a la que se llama.\n\nEl argumento de la función creada se añade como último argumento del método, así que encaja como callback de una petición.\n\nExample: Usarla como callback\n```js\nON('ready', function() {\n\tvar fn = ASETTER('box', 'hello');\n\tfn('Peter');\n\tconsole.log(typeof(fn)); // function\n});\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLee un atributo `data-` de un elemento o de sus padres.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery|Event|Object` | yes |  | El origen. |\n| `name` | `String` | no | `id` | El nombre del atributo. |\n\nReturns: `String` El valor.\n\nUn objeto simple devuelve su campo con ese nombre.\n\nExample: Leer un identificador\n```html\n<div id=\"row\" data-id=\"15\" data-type=\"user\"></div>\n<script>\nconsole.log(ATTRD($('#row'))); // 15\nconsole.log(ATTRD($('#row'), 'type')); // user\n</script>\n```\n\n### BIND(path)\n\nType: `method`\n\nActualiza los enlaces de datos de un path sin notificar a los componentes ni a los observadores.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Array` | yes |  | Un path o una lista de paths. |\n\nExample: Actualizar un enlace\n```html\n<span id=\"name\" data-bind=\"user.name__text\"></span>\n<script>\nSET('user', { name: 'Peter' });\nsetTimeout(function() {\n\tGET('user').name = 'Anna';\n\tBIND('user.name');\n\tsetTimeout(function() {\n\t\tconsole.log($('#name').text()); // Anna\n\t}, 300);\n}, 300);\n</script>\n```\n\n### BLOCKED(name, timeout, [callback])\n\nType: `method`\n\nLimita la frecuencia con la que puede ejecutarse una acción.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la acción. |\n| `timeout` | `Number|String` | yes |  | Milisegundos o un valor como `5 seconds`. |\n| `callback` | `Function` | no |  | Se ejecuta cuando la acción no está bloqueada. |\n\nReturns: `Boolean` `true` cuando la acción está bloqueada.\n\nLa primera llamada devuelve `false` y bloquea el nombre durante el tiempo indicado. Un bloqueo de más de 10 segundos se conserva en el almacenamiento del navegador.\n\nExample: Permitir una llamada por segundo\n```js\nconsole.log(BLOCKED('save', 1000)); // false\nconsole.log(BLOCKED('save', 1000)); // true\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLee o escribe un valor en la caché del navegador.\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|Number` | no |  | Por ejemplo, `1 day`, `session` o milisegundos. |\n\nReturns: `Object` El valor guardado.\n\nUn valor solo se guarda con una caducidad. El valor `session` lo conserva en memoria hasta que se recarga la página.\n\nExample: Guardar un valor\n```js\nCACHE('profile', { name: 'Peter' }, '1 day');\nconsole.log(CACHE('profile')); // {\"name\":\"Peter\"}\n```\n\n### CACHEPATH(path, expire, [rebind])\n\nType: `method`\n\nConserva el valor de un path en la caché del navegador.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `expire` | `String` | yes |  | Por ejemplo, `1 month`. |\n| `rebind` | `Boolean` | no | `true` | Con `false`, el valor guardado no se restaura. |\n\nCada cambio del path se guarda, y el valor guardado se restaura en la siguiente visita. Con la forma `path__value`, la expresión es el valor que se usa cuando no hay nada guardado.\n\nExample: Recordar un valor\n```js\nCACHEPATH('settings.theme', '1 month');\nSET('settings.theme', 'dark');\nconsole.log(CACHE('PATHS')); // {\"settings.theme\":\"dark\"}\n```\n\n### CAN(path, [flags])\n\nType: `method`\n\nIndica si se puede enviar un formulario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita la comprobación a esos componentes. |\n\nReturns: `Boolean` El resultado.\n\nEl resultado es `true` cuando al menos un componente del path está tocado y ninguno es inválido. Un path sin componentes también devuelve `true`.\n\nExample: Activar un botón de envío\n```js\nON('ready', function() {\n\tconsole.log(CAN('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tCHANGE('form.name');\n\tconsole.log(CAN('form.*')); // true\n});\n```\n\n### CHANGE(path, [value])\n\nType: `method`\n\nMarca los componentes de un path como tocados y modificados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Boolean` | no | `true` | Con `false`, se quitan las marcas. |\n\nExample: Marcar un campo como cambiado\n```js\nON('ready', function() {\n\tCHANGE('form.age');\n\tconsole.log(MODIFIED('form.*')); // [\"form.age\"]\n});\n```\n\n### CL(name, callback)\n\nType: `method`\n\nEspera hasta que se cargan las listas de códigos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la lista de códigos. |\n| `callback` | `Function` | yes |  | Se ejecuta cuando las listas están listas. |\n\nPuedes separar varios nombres con una coma. Los valores cargados se guardan en `DEF.cl`.\n\nExample: Esperar a una lista de códigos\n```js\nCL_INIT('countries', next => next(['SK', 'CZ']));\nCL('countries', function() {\n\tconsole.log(DEF.cl.countries); // [\"SK\",\"CZ\"]\n});\n```\n\n### CL_INIT(name, source, [expire], [init])\n\nType: `method`\n\nDeclara cómo se carga 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 |  | El cargador. |\n| `expire` | `String` | no |  | La lista se vuelve a cargar después de este tiempo. |\n| `init` | `Boolean` | no |  | Con `true`, carga la lista de inmediato. |\n\nEl origen es una función que recibe `next(value)`, o una cadena. Una cadena que empieza por un método HTTP va a [AJAX()](#ajax), y cualquier otra cadena a [TAPI()](#tapi). `CLINIT()` es la misma función.\n\nExample: Cargar una lista desde una URL\n```js\nCL_INIT('roles', 'GET /api/roles/', true);\nsetTimeout(function() {\n\tconsole.log(DEF.cl.roles.url); // /api/roles/\n}, 300);\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nCancela un temporizador con nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del temporizador. |\n\nReturns: `Boolean` `true` cuando había un temporizador en marcha.\n\nExample: Cancelar un temporizador\n```js\nsetTimeout2('save', NOOP, 1000);\nconsole.log(clearTimeout2('save')); // true\nconsole.log(clearTimeout2('save')); // false\n```\n\n### CLINIT(name, source, [expire], [init])\n\nType: `method`\n\nLa misma función que [CL_INIT()](#cl-init).\n\nExample: La misma función\n```js\nconsole.log(CLINIT === CL_INIT); // true\n```\n\n### CLONE(value, [nopath])\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 o un path. |\n| `nopath` | `Boolean` | no |  | Con `true`, una cadena se devuelve tal cual. |\n\nReturns: `Object` La copia.\n\nUna cadena se trata como un path, y se clona el valor del path.\n\nExample: Clonar un valor\n```js\nSET('user', { name: 'Peter' });\nvar copy = CLONE('user');\ncopy.name = 'Anna';\nconsole.log(GET('user.name')); // Peter\nconsole.log(copy.name); // Anna\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nVuelve a cargar listas de códigos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la lista de códigos. |\n| `callback` | `Function` | no |  | Se ejecuta cuando las listas se han cargado. |\n\nPuedes separar varios nombres con una coma.\n\nExample: Recargar una lista\n```js\nvar count = 0;\nCL_INIT('numbers', next => next([++count]), true);\nsetTimeout(function() {\n\tCLRELOAD('numbers', function() {\n\t\tconsole.log(DEF.cl.numbers); // [2]\n\t});\n}, 100);\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nEjecuta un comando en todos los componentes que lo han registrado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n| `a` | `Object` | no |  | Hasta cinco argumentos, de `a` a `e`. |\n\nLos componentes registran comandos con `self.command()`.\n\nExample: Ejecutar un comando\n```js\nON('ready', function() {\n\tCMD('box.ping', 5);\n});\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // box.ping 5\n});\n```\n\n### COMPILE([container])\n\nType: `method`\n\nBusca en la página componentes y enlaces nuevos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limita la búsqueda a este elemento. |\n\nLlámala después de añadir HTML a mano.\n\nExample: Compilar HTML nuevo\n```js\n$(document.body).append('<ui-component name=\"box\" path=\"data.new\"></ui-component>');\nCOMPILE();\nsetTimeout(function() {\n\tconsole.log(FIND('box').path); // data.new\n}, 500);\n```\n\n### COMPONENT(name, [config], declaration, [dependencies])\n\nType: `method`\n\nDeclara un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del componente. |\n| `config` | `String|Object` | no |  | La configuración predeterminada. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n| `dependencies` | `Array` | no |  | Archivos que se importan primero, o nombres de componentes que empiezan por `@`. |\n\nPuedes separar varios nombres con una coma. Una versión puede seguir al nombre: `box@2`. El tema completo se explica en [Crear componentes](../../guides/creating-components/), y el objeto que recibe la declaración se describe en [Component](../component/).\n\nExample: Declarar un componente\n```html\n<ui-component name=\"hello\"></ui-component>\n<script>\nCOMPONENT('hello', 'name:World', function(self, config) {\n\tself.make = () => self.element.text('Hello ' + config.name);\n});\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // Hello World\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nEnumera los componentes de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path con flags opcionales. |\n\nReturns: `Array` Los componentes.\n\nEl path se escribe sin `.*`. Los flags que siguen al path filtran la lista: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` y `@enabled`.\n\nExample: Filtrar los componentes\n```js\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tSET('form.name', 'Peter');\n\tconsole.log(COMPONENTS('form @invalid').map(com => com.path)); // [\"form.age\"]\n});\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nDefine la configuración de los componentes antes de que se inicien.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Qué componentes se configuran. |\n| `config` | `Object|String|Function` | yes |  | La configuración o una función que la devuelve. |\n\nEl selector es un nombre de componente, `.path`, `#id` o una función que recibe el componente y devuelve un booleano. Las partes separadas por un espacio deben coincidir todas, y una coma separa alternativas. Llámala antes de que se compilen los componentes.\n\nExample: Configurar por nombre\n```js\nCONFIG('box', { size: 10 });\nON('ready', function() {\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### COOKIES\n\nType: `property`\n\nUn objeto para leer y escribir cookies.\n\nTiene los métodos `get(name)`, `set(name, value, expire, [samesite])` y `rem(name)`. `expire` es un `Date` o un valor como `1 day`.\n\nExample: Leer el valor\n```js\nCOOKIES.set('theme', 'dark', '1 day');\nconsole.log(COOKIES.get('theme') === 'dark' || location.protocol === 'file:'); // true\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopia los campos de un objeto a otro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | El objeto que se lee. |\n| `target` | `Object` | yes |  | El objeto en el que se escribe. |\n\nReturns: `Object` El objeto de destino.\n\nLos objetos que hay dentro del origen se clonan.\n\nExample: Copiar campos\n```js\nvar target = COPY({ a: 1 }, { b: 2 });\nconsole.log(target); // {\"b\":2,\"a\":1}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nLa misma función que [STYLE()](#style).\n\nExample: La misma función\n```js\nconsole.log(CSS === STYLE); // true\n```\n\n### DAPI(name, [data], [callback])\n\nType: `method`\n\nLlama al endpoint de la API definido en `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del esquema. |\n| `data` | `Object` | no |  | Los datos. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` o un path. |\n\nReturns: `Object|Promise` Igual que [API()](#api).\n\n`DEF.api` es una URL, o una función que recibe el nombre y los datos y devuelve el valor para [API()](#api).\n\nExample: Usar el endpoint predeterminado\n```js\nDEF.api = '/api/';\nDAPI('users_list', null, function(response) {\n\tconsole.log(response.url, response.body.schema); // /api/ users_list\n});\n```\n\n### DAYS\n\nType: `property`\n\nLos nombres de los días, empezando por el domingo.\n\nExample: Leer el valor\n```js\nconsole.log(DAYS[0]); // Sunday\n```\n\n### DEBUG()\n\nType: `method`\n\nActiva el modo de depuración.\n\nLas llamadas a métodos inexistentes escriben un aviso en la consola, y [API()](#api) añade el esquema a la URL. El modo no se puede activar después de que `DEF.secret()` haya definido una clave.\n\nExample: Avisar de un método inexistente\n```js\nDEBUG();\nEXEC('missing.method');\nconsole.log('done'); // done\n```\n\n### DECRYPT(value, [key], [type])\n\nType: `method`\n\nDecodifica un valor de [ENCRYPT()](#encrypt).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El valor codificado. |\n| `key` | `String` | no |  | La clave. |\n| `type` | `String` | no |  | El prefijo del valor. |\n\nReturns: `Object` El valor, o `undefined` cuando la clave o el prefijo no coinciden.\n\nEl JSON se vuelve a convertir en un objeto.\n\nExample: Usar una clave incorrecta\n```js\nvar token = ENCRYPT('Peter', 'secret');\nconsole.log(DECRYPT(token, 'secret')); // Peter\nconsole.log(DECRYPT(token, 'other') === undefined); // true\n```\n\n### DEF\n\nType: `property`\n\nLa configuración de la biblioteca. Consulta [DEF](../def/).\n\nExample: Leer el valor\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEFAULT(path, [delay], [reset])\n\nType: `method`\n\nRestaura los valores predeterminados de los componentes de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo, o `path__value`. |\n| `delay` | `Number` | no |  | Un retardo en milisegundos. |\n| `reset` | `Boolean` | no | `true` | Con `false`, se conserva el estado de los componentes. |\n\nUn componente toma su valor predeterminado de su atributo `default`. Con la forma `path__value`, lo que se escribe en el path como valor predeterminado es la expresión que sigue a los dos guiones bajos.\n\nExample: Escribir un objeto predeterminado\n```js\nDEFAULT('form.* __{ name: \"Peter\" }');\nsetTimeout(function() {\n\tconsole.log(GET('form')); // {\"name\":\"Peter\"}\n}, 100);\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 padre. |\n| `selector` | `String` | yes |  | Un selector de los hijos. |\n| `html` | `String` | yes |  | El HTML nuevo. |\n| `attribute` | `String` | no |  | El atributo que se compara. |\n\nReturns: `Object` Los recuentos `add`, `upd` y `rem`.\n\nSolo se añaden o eliminan los hijos que han cambiado. Los hijos se comparan por su HTML o por el valor del atributo.\n\nExample: Actualizar una lista\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n<script>\nvar result = DIFFDOM($('#list'), 'li', '<li>B</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log($('#list').text()); // BC\n</script>\n```\n\n### DISABLED(path, [flags])\n\nType: `method`\n\nLo contrario de [CAN()](#can).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita la comprobación a esos componentes. |\n\nReturns: `Boolean` El resultado.\n\nExample: Desactivar un botón de envío\n```js\nON('ready', function() {\n\tconsole.log(DISABLED('form.*')); // true\n});\n```\n\n### EMIT(name, [...args])\n\nType: `method`\n\nLlama a los manejadores de un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `...args` | `Object` | no |  | Los argumentos que se pasan a los manejadores. |\n\nReturns: `Boolean` `true` cuando el evento tiene al menos un manejador.\n\nUn flag personalizado puede seguir al nombre, por ejemplo `EMIT('ping @saved')`.\n\nExample: Emitir un evento\n```js\nON('hello', name => console.log(name)); // Peter\nconsole.log(EMIT('hello', 'Peter')); // true\nconsole.log(EMIT('unknown')); // false\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nUn array vacío congelado.\n\nExample: Leer el valor\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nUn objeto vacío congelado.\n\nExample: Leer el valor\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nCodifica un valor en una cadena hexadecimal firmada con una clave.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | El valor. |\n| `key` | `String` | no |  | La clave. |\n| `type` | `String` | no |  | Un prefijo del resultado. |\n\nReturns: `String` El valor codificado.\n\nEl valor se codifica, pero no se cifra de forma robusta. Los objetos se convierten a JSON.\n\nExample: Codificar y decodificar\n```js\nvar token = ENCRYPT({ id: 5 }, 'secret');\nconsole.log(DECRYPT(token, 'secret')); // {\"id\":5}\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLee o escribe una variable de entorno.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | El nombre o un objeto con valores. |\n| `value` | `Object` | no |  | El valor. |\n\nReturns: `Object` El valor de la variable.\n\nUn objeto como primer argumento escribe varias variables. Los paths y las URL leen las variables con `[name]`. Las variables se guardan en `DEF.environment`.\n\nExample: Usar una variable\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\nDefine el nombre, la versión y el idioma de la aplicación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la aplicación. |\n| `version` | `String` | no |  | La versión. |\n| `language` | `String` | no |  | El idioma del HTML importado. |\n| `env` | `Object` | no |  | Variables de entorno para [ENV()](#env). |\n\nEl nombre separa el almacenamiento del navegador de la aplicación. Define `DEF.localstorage`, `DEF.version` y `DEF.languagehtml`.\n\nExample: Dar nombre a la aplicación\n```js\nENVIRONMENT('shop', '1.2', 'en', { api: '/api/' });\nconsole.log(DEF.localstorage, DEF.version, ENV('api')); // shop 1.2 /api/\n```\n\n### ERROR(value, [success], [error])\n\nType: `method`\n\nIndica si una respuesta contiene un error.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|Function` | yes |  | La respuesta o el manejador de éxito. |\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|Function` `true` cuando el valor es un error, o el callback creado.\n\nCuentan como error un `Error`, un objeto con el campo `error` o un array cuyo primer elemento lo tiene, y se emite el evento [ERROR](../events/#error-2). `success` y `error` son funciones o paths.\n\nCon una función como primer argumento, `ERROR(success, [error])` devuelve un callback para una petición.\n\nExample: Comprobar una respuesta\n```js\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\nconsole.log(ERROR({ id: 5 })); // false\n```\n\nExample: Crear un callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 5\n});\ncallback({ id: 5 });\n```\n\n### ERRORS(path, [flags], [highlight])\n\nType: `method`\n\nEnumera los componentes que están tocados y son inválidos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita la comprobación a esos componentes. |\n| `highlight` | `Boolean` | no |  | Actualiza el estado de los componentes encontrados. |\n\nReturns: `Array` Los componentes.\n\n`ERRORS(path, true)` también actualiza el estado de los componentes que encuentra.\n\nExample: Buscar los campos inválidos\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(ERRORS('form.*').map(com => com.path)); // [\"form.name\"]\n});\n```\n\n### EVALUATE(path, expression, [nopath])\n\nType: `method`\n\nEvalúa una expresión JavaScript con el valor de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Object` | yes |  | El path, o el propio valor cuando `nopath` es `true`. |\n| `expression` | `String` | yes |  | La expresión. |\n| `nopath` | `Boolean` | no |  | Trata el primer argumento como el valor. |\n\nReturns: `Object` El resultado de la expresión.\n\nLa expresión puede usar las variables `value` y `path`.\n\nExample: Evaluar una expresión\n```js\nSET('price', 10);\nconsole.log(EVALUATE('price', 'value * 2')); // 20\nconsole.log(EVALUATE(4, 'value + 1', true)); // 5\n```\n\n### EXE([wait], path, [...args])\n\nType: `method`\n\nLa misma función que [EXEC()](#exec).\n\nExample: La misma función\n```js\nconsole.log(EXE === EXEC); // true\n```\n\n### EXEC([wait], path, [...args])\n\nType: `method`\n\nLlama a una función, un método de plugin, un método de componente, un comando o un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Con `true`, espera al destino. |\n| `path` | `String` | yes |  | El destino. |\n| `...args` | `Object` | no |  | Los argumentos. |\n\nLa forma del path selecciona el destino:\n\n| Path | Destino |\n| --- | --- |\n| `plugin/method` | Un método de un plugin |\n| `@plugin.method` | Un método de un plugin |\n| `path.to.fn` | Una función en un path |\n| `#name` | El evento `name` |\n| `-selector/method` | Un método de un componente, como en [SETTER()](#setter) |\n| `&name` | Un comando, como en [CMD()](#cmd) |\n\nCon `true` como primer argumento, la llamada espera hasta que exista el destino. `EXE()` es la misma función.\n\nExample: Llamar a un método de un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.hello = function(name) {\n\t\tconsole.log(name); // Peter\n\t};\n});\nEXEC(true, 'users/hello', 'Peter');\n```\n\nExample: Llamar a una función en un path\n```js\nwindow.app = { sum: (a, b) => console.log(a + b) };\nEXEC('app.sum', 1, 2);\nconsole.log(typeof(app.sum)); // function\n```\n\n### EXT(path, value, [delay], [reset])\n\nType: `method`\n\nFusiona los campos de un objeto con el objeto de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Los campos que se fusionan. |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n| `reset` | `Boolean` | no |  | Con `true`, los componentes del path también se marcan como no tocados y no modificados. |\n\nCada campo se escribe por separado, así que los demás campos se mantienen. `EXTEND()` es la misma función. Como en [SET()](#set), el primer argumento puede ser una petición y `value` el path de destino.\n\nExample: Fusionar campos\n```js\nSET('user', { name: 'Peter' });\nEXT('user', { age: 30 });\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"age\":30}\n```\n\n### EXTEND(path, value, [delay], [reset])\n\nType: `method`\n\nLa misma función que [EXT()](#ext).\n\nExample: La misma función\n```js\nconsole.log(EXTEND === EXT); // true\n```\n\n### EXTENSION(name, [config], declaration)\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 `@plugin`. |\n| `config` | `Object|String` | no |  | Configuración adicional. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n\nLa declaración se ejecuta para cada instancia del componente, incluidas las existentes. Con un nombre que empieza por `@`, amplía el plugin con ese nombre.\n\nExample: Añadir un método a un componente\n```js\nEXTENSION('box', function(self) {\n\tself.bye = () => 'Bye';\n});\nON('ready', function() {\n\tconsole.log(FIND('box').bye()); // Bye\n});\n```\n\n### FIND(selector, [many], [nocache], [callback])\n\nType: `method`\n\nBusca un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Element` | yes |  | Qué se busca. |\n| `many` | `Boolean` | no |  | Con `true`, devuelve todas las coincidencias como un array. |\n| `nocache` | `Boolean` | no |  | Omite la caché de componentes encontrados. |\n| `callback` | `Function` | no |  | Espera al componente y lo recibe. |\n\nReturns: `Component|Array` El componente encontrado, o un array con `many`. No se devuelve nada cuando se usa un callback.\n\nEl selector es un nombre de componente, `.path`, `#id`, `name[path]` o `name@version`, y las partes se pueden combinar con un espacio. Un elemento DOM o un objeto jQuery busca los componentes que hay dentro de él.\n\nCon un callback, la búsqueda espera hasta que exista el componente. El callback puede ser el segundo o el tercer argumento.\n\nExample: Buscar por nombre y path\n```js\nON('ready', function() {\n\tconsole.log(FIND('box').path); // data.box\n\tconsole.log(FIND('.data.box').name); // box\n\tconsole.log(FIND('box', true).length); // 1\n});\n```\n\nExample: Esperar a un componente\n```js\nFIND('box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### FN(expression)\n\nType: `method`\n\nCrea una función a partir de una cadena.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expression` | `String` | yes |  | La expresión. |\n\nReturns: `Function` La función.\n\nLa cadena es una función flecha. Una cadena que solo usa la palabra `value` se convierte en una función con el argumento `value`.\n\nExample: Crear funciones\n```js\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value > 5')(10)); // true\n```\n\n### FORMATTER(fn, [prepend])\n\nType: `method`\n\nRegistra un formateador global de valores de componentes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Con `true`, el formateador se ejecuta primero. |\n\nReturns: `Object` El valor con formato, cuando la función ejecuta los formateadores.\n\nLa función devuelve el valor nuevo, y `undefined` mantiene el actual. `FORMATTER(value, path, type, [format])` ejecuta todos los formateadores registrados.\n\nExample: Dar formato a un valor\n```js\nFORMATTER(function(path, value, type) {\n\tif (type === 'upper')\n\t\treturn value.toUpperCase();\n});\nconsole.log(FORMATTER('peter', 'user.name', 'upper')); // PETER\n```\n\n### FREE([delay])\n\nType: `method`\n\nElimina los componentes, enlaces y observadores que no se usan.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `10` | El retardo en milisegundos. |\n\nLa biblioteca también lo hace cada tres minutos.\n\nExample: Limpiar\n```js\nFREE();\nconsole.log(typeof(FREE)); // function\n```\n\n### FUNC\n\nType: `property`\n\nUn objeto vacío para tus propias funciones compartidas.\n\nExample: Leer el valor\n```js\nFUNC.sum = (a, b) => a + b;\nconsole.log(FUNC.sum(1, 2)); // 3\n```\n\n### GET(path, [scope])\n\nType: `method`\n\nLee el valor de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `scope` | `Object|Function|Boolean` | no |  | Un objeto lee el path de forma relativa a ese objeto. Una función espera hasta que el valor no sea `null` y entonces lo recibe. `true` restablece el estado de los componentes del path. |\n\nReturns: `Object` El valor, o `undefined` cuando el path no tiene valor. Con una función como segundo argumento, no se devuelve nada.\n\nLos flags pueden seguir al path. `@clone` devuelve una copia, `@reset` restablece el estado de los componentes después de leer y `@modified` devuelve solo los valores de los componentes modificados.\n\nExample: Leer un valor\n```js\nSET('user', { name: 'Peter', age: 30 });\nconsole.log(GET('user.age')); // 30\nconsole.log(GET('name', { name: 'Anna' })); // Anna\n```\n\nExample: Esperar a un valor\n```js\nGET('settings.theme', function(value) {\n\tconsole.log(value); // dark\n});\nsetTimeout(() => SET('settings.theme', 'dark'), 100);\n```\n\n### GUID([size])\n\nType: `method`\n\nCrea un identificador aleatorio.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `size` | `Number` | no |  | La longitud. Sin ella, el identificador tiene 36 caracteres con la forma de un UUID. |\n\nReturns: `String` El identificador.\n\nExample: Crear identificadores\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value, [unsigned])\n\nType: `method`\n\nCrea un número a partir de un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor. |\n| `unsigned` | `Boolean` | no | `true` | Con `false`, el resultado puede ser negativo. |\n\nReturns: `Number` El hash.\n\nLos objetos se convierten en hash a partir de su forma JSON. Un número se devuelve tal cual, un booleano se convierte en `0` o `1`, y una fecha se convierte en su marca de tiempo.\n\nExample: Calcular el hash de una cadena\n```js\nconsole.log(HASH('abc')); // 96354\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nIndica si un elemento no se muestra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | El elemento. |\n\nReturns: `Boolean` El resultado. Un elemento inexistente devuelve `true`.\n\nExample: Comprobar un elemento\n```html\n<div id=\"a\" style=\"display:none\"><span></span></div>\n<script>\nconsole.log(HIDDEN($('#a')[0].firstChild)); // true\nconsole.log(HIDDEN(null)); // true\n</script>\n```\n\n### IMPORT(url, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nCarga un script, un estilo o HTML en la página.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String|Array` | yes |  | La URL. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Dónde se coloca el HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Con `false`, sustituye el contenido del destino. |\n| `preparator` | `Function` | no |  | `function(response, output)` modifica el HTML antes de insertarlo. |\n\nEl tema se explica en [Importar contenido](../../guides/importing/). Un array de URL se carga una a una. Una URL que empieza por `once ` o `!` se carga una sola vez, y `<path>` delante de la URL omite la importación cuando el path tiene valor. El callback recibe `1` después de la carga y `0` cuando no se ha cargado nada.\n\nExample: Importar HTML\n```html\n<div id=\"target\"></div>\n<script>\nIMPORT('/parts/hello.html', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nFunciona como [IMPORT()](#import) y guarda en caché el HTML importado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL. |\n| `expire` | `String` | yes |  | Por ejemplo, `5 minutes` o `session`. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Dónde se coloca el HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Con `false`, sustituye el contenido del destino. |\n| `preparator` | `Function` | no |  | `function(response, output)` modifica el HTML antes de insertarlo. |\n\nExample: Importar y guardar en caché\n```html\n<div id=\"target\"></div>\n<script>\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### INC(path, [value], [delay], [reset])\n\nType: `method`\n\nSuma un número al valor de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Number` | no | `1` | El número que se suma. |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n| `reset` | `Boolean` | no |  | Con `true`, los componentes del path también se marcan como no tocados y no modificados. |\n\nUn valor inexistente o que no es un número cuenta como `0`.\n\nExample: Aumentar un contador\n```js\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 6\n```\n\n### inDOM(element)\n\nType: `method`\n\nIndica si un elemento está dentro del body de la página.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | El elemento. |\n\nReturns: `Boolean` `true`, o `undefined` cuando el elemento está fuera del body.\n\nExample: Comprobar un elemento\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(inDOM(document.createElement('div')) === undefined); // true\n```\n\n### isIE\n\nType: `property`\n\n`true` en Internet Explorer.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(isIE)); // boolean\n```\n\n### isMOBILE\n\nType: `property`\n\n`true` en un dispositivo móvil.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(isMOBILE)); // boolean\n```\n\n### isPRIVATEMODE\n\nType: `property`\n\n`true` cuando el almacenamiento del navegador no está disponible.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(isPRIVATEMODE)); // boolean\n```\n\n### isROBOT\n\nType: `property`\n\n`true` cuando el agente de usuario parece un robot.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(isROBOT)); // boolean\n```\n\n### isSTANDALONE\n\nType: `property`\n\n`true` cuando la página se ejecuta como aplicación instalada.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(isSTANDALONE)); // boolean\n```\n\n### isTOUCH\n\nType: `property`\n\n`true` en un dispositivo con pantalla táctil.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(isTOUCH)); // boolean\n```\n\n### jComponent\n\nType: `property`\n\nOtro nombre de `MAIN`. Consulta [MAIN](../main/).\n\nExample: Leer el valor\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### LOCALIZE(text)\n\nType: `method`\n\nAñade traducciones al diccionario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Las traducciones. |\n\nCada línea tiene la forma `key : value`, y se omite la línea que empieza por `//`. Los valores se guardan en `DEF.dictionary`. El tema se explica en [Localización](../../guides/localization/).\n\nExample: Añadir traducciones\n```js\nLOCALIZE('// Greetings\\nhello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### M\n\nType: `property`\n\nUn nombre corto de `MAIN`. Consulta [M](../m/).\n\nExample: Leer el valor\n```js\nconsole.log(M === MAIN); // true\n```\n\n### MACRO(name, declaration)\n\nType: `method`\n\nDeclara una macro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la macro. |\n| `declaration` | `Function` | yes |  | `function(self, element, cls)`. |\n\nEl tema se explica en [Macros](../../guides/macros/), y el objeto se describe en [Macro](../macro/).\n\nExample: Declarar una macro\n```js\nMACRO('upper', function(self, element) {\n\tself.setter = value => element.text((value || '').toUpperCase());\n});\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### MAIN\n\nType: `property`\n\nEl objeto principal de la biblioteca. Consulta [MAIN](../main/).\n\nExample: Leer el valor\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### MAKE([target], fn, [update])\n\nType: `method`\n\nConstruye un objeto dentro de una función.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Object|String` | no |  | Un objeto o un path. Sin él, se crea un objeto nuevo. |\n| `fn` | `Function` | yes |  | `function(obj, path, set)`. |\n| `update` | `Boolean` | no | `true` | Con `false`, un objeto existente en el path se vuelve a escribir sin restablecer sus componentes. |\n\nReturns: `Object` El objeto.\n\nUn destino de tipo cadena es un path: se modifica el objeto del path, o se crea uno nuevo y se escribe ahí. La función recibe el objeto, el path y una función `set(path, value)`.\n\nExample: Construir un objeto\n```js\nvar obj = MAKE(function(o) {\n\to.name = 'Peter';\n});\nconsole.log(obj); // {\"name\":\"Peter\"}\n```\n\nExample: Construir un objeto en un path\n```js\nMAKE('user', function(o, path, set) {\n\to.name = 'Peter';\n\tset('address.city', 'Bratislava');\n});\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"address\":{\"city\":\"Bratislava\"}}\n```\n\n### MIDDLEWARE(name, fn)\n\nType: `method`\n\nDeclara un middleware de rutas. Consulta [Enrutamiento](../../guides/routing/).\n\n### MODIFIED(path, [flags])\n\nType: `method`\n\nEnumera los paths de los componentes que están tocados y modificados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita la búsqueda a esos componentes. |\n\nReturns: `Array` Los paths de los componentes modificados.\n\nExample: Enumerar los campos cambiados\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n});\n```\n\n### MONTHS\n\nType: `property`\n\nLos nombres de los meses.\n\nExample: Leer el valor\n```js\nconsole.log(MONTHS[11]); // December\n```\n\n### NAV\n\nType: `property`\n\nEl objeto del enrutador. Consulta [Enrutamiento](../../guides/routing/).\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` | `Element|jQuery` | yes |  | El elemento. |\n\nReturns: `Number` El índice.\n\nExample: Leer la posición\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, target, [before])\n\nType: `method`\n\nColoca un elemento después o antes de otro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | El elemento que se mueve. |\n| `target` | `Element|jQuery` | yes |  | El elemento de referencia. |\n| `before` | `Boolean` | no |  | Con `true`, lo coloca antes del destino. |\n\nExample: Mover un elemento\n```html\n<ul><li id=\"a\">A</li><li>B</li><li id=\"c\">C</li></ul>\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` | `Element|jQuery` | yes |  | El elemento. |\n| `up` | `Boolean` | no |  | Con `true`, lo mueve hacia arriba. Si no, lo mueve hacia abajo. |\n\nExample: Mover un elemento hacia arriba\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BA\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nUna función que no hace nada.\n\nExample: Usarla como callback vacío\n```js\nconsole.log(NOOP() === undefined); // true\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nIndica si la página está en segundo plano.\n\nReturns: `Boolean` El resultado.\n\nExample: Comprobar la página\n```js\nconsole.log(typeof(NOTFOCUSED())); // boolean\n```\n\n### NOTIFY(...paths)\n\nType: `method`\n\nActualiza los componentes y observadores de paths exactos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...paths` | `String` | yes |  | Uno o varios paths. |\n\nSolo se actualizan los componentes cuyo path es exactamente el mismo.\n\nExample: Notificar a un observador\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nwindow.user = { name: 'Peter' };\nNOTIFY('user.name');\n```\n\n### NOTMODIFIED(path, [value], [fields])\n\nType: `method`\n\nIndica si un valor es igual que la última vez que se comprobó.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, o cualquier clave cuando se indica `value`. |\n| `value` | `Object` | no |  | El valor que se compara. Sin él, se usa el valor del path. |\n| `fields` | `Array` | no |  | Compara solo estos campos. |\n\nReturns: `Boolean` `true` cuando el valor no ha cambiado.\n\nLa primera comprobación de un path devuelve `false`. El valor se compara mediante un hash de su forma JSON.\n\nExample: Evitar trabajo cuando nada ha cambiado\n```js\nconsole.log(NOTMODIFIED('list', [1, 2])); // false\nconsole.log(NOTMODIFIED('list', [1, 2])); // true\nconsole.log(NOTMODIFIED('list', [1, 2, 3])); // false\n```\n\n### NOW\n\nType: `property`\n\nLa fecha actual, actualizada cada minuto.\n\nExample: Leer el valor\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path, [delay])\n\nType: `method`\n\nEscribe `null` en un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n\n`NULL()` es la misma función.\n\nExample: Borrar un valor\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### NULL(path, [delay])\n\nType: `method`\n\nLa misma función que [NUL()](#nul).\n\nExample: La misma función\n```js\nconsole.log(NULL === NUL); // true\n```\n\n### OFF(name, [path], [fn])\n\nType: `method`\n\nElimina manejadores de un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `path` | `String|Function` | no |  | El path, o el manejador cuando no se necesita path. |\n| `fn` | `Function` | no |  | El manejador. |\n\nPuedes separar varios eventos con `+`. La forma `owner#name` elimina los manejadores de ese propietario, y `owner#` los elimina todos.\n\nExample: Eliminar un manejador\n```js\nvar fn = () => console.log('never');\nON('ping', fn);\nOFF('ping', fn);\nconsole.log(EMIT('ping')); // false\n```\n\nExample: Eliminar los manejadores de un propietario\n```js\nON('shop#ping', () => console.log('never'));\nOFF('shop#');\nconsole.log(EMIT('ping')); // false\n```\n\n### ON(name, [path], fn, [init])\n\nType: `method`\n\nRegistra un manejador de un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `path` | `String` | no |  | El path, para el evento `watch`. |\n| `fn` | `Function` | yes |  | El manejador. |\n| `init` | `Boolean` | no |  | Con el evento `watch`, el manejador también se llama de inmediato. |\n\nEl nombre puede enumerar varios eventos separados por un espacio o ` + `. Un nombre que empieza por `^` coloca el manejador en primer lugar. La forma `owner#name` asigna el manejador a un propietario, para que [OFF()](#off) pueda eliminarlo más adelante. El nombre `@flag myflag` reacciona a un flag personalizado en un path.\n\nEl evento `watch` funciona como [WATCH()](#watch) y usa `path` e `init`. Los eventos de la biblioteca se enumeran en [Eventos](../events/).\n\nExample: Escuchar un evento personalizado\n```js\nON('cart.add', function(id, count) {\n\tconsole.log(id, count); // 15 2\n});\nEMIT('cart.add', 15, 2);\n```\n\nExample: Reaccionar a un flag personalizado\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.name Peter\n});\nSET('user.name @saved', 'Peter');\n```\n\n### OPT([obj], fn)\n\nType: `method`\n\nConstruye un objeto de opciones con paths anidados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | no |  | El objeto que se rellena. Sin él, se crea un objeto nuevo. |\n| `fn` | `Function` | yes |  | `function(set, scope)`. |\n\nReturns: `Object` El objeto.\n\nLa función recibe `set(path, value)` y `scope(prefix)`, que añade un prefijo a los paths siguientes.\n\nExample: Construir opciones\n```js\nvar options = OPT(function(set, scope) {\n\tset('title', 'Users');\n\tscope('grid');\n\tset('limit', 20);\n});\nconsole.log(options); // {\"title\":\"Users\",\"grid\":{\"limit\":20}}\n```\n\n### PARSE(value, [date])\n\nType: `method`\n\nAnaliza JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El JSON o un selector. |\n| `date` | `Boolean` | no | `DEF.jsondate` | Convierte las fechas ISO en objetos `Date`. |\n\nReturns: `Object` El valor.\n\nUna cadena que empieza por `#` o `.` es un selector de un elemento con JSON. Un JSON no válido devuelve `null`, y un objeto se devuelve tal cual.\n\nExample: Analizar JSON\n```js\nconsole.log(PARSE('{\"id\":5}').id); // 5\nconsole.log(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d instanceof Date); // true\nconsole.log(PARSE('wrong')); // null\n```\n\n### PARSER(fn, [prepend])\n\nType: `method`\n\nRegistra un parser global de valores de componentes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Con `true`, el parser se ejecuta primero. |\n\nReturns: `Object` El valor analizado, cuando la función ejecuta los parsers.\n\nLa función siempre debe devolver el valor. El parser integrado convierte los tipos `number`, `currency`, `float`, `boolean`, `bool`, `date` y `datetime`. `PARSER(value, path, type, [format])` ejecuta todos los parsers registrados.\n\nExample: Analizar un valor\n```js\nconsole.log(PARSER('1 200.5', 'price', 'number')); // 1200.5\nconsole.log(PARSER('on', 'active', 'boolean')); // true\n```\n\n### PLUGIN(name, [fn], [init], [done])\n\nType: `method`\n\nDeclara un plugin o devuelve uno existente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del plugin. |\n| `fn` | `Function` | no |  | `function(exports)`. |\n| `init` | `Function|String` | no |  | Se ejecuta antes de la declaración. Una cadena enumera nombres de middleware. |\n| `done` | `Function` | no |  | Se llama cuando el plugin está listo. |\n\nReturns: `Plugin` El plugin.\n\nEl tema se explica en [Plugins](../../guides/plugins/), y el objeto se describe en [Plugin](../plugin/).\n\nExample: Declarar un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.count = 5;\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.users.count); // 5\n}, 500);\n```\n\n### PLUGINABLE(name, fn, [init])\n\nType: `method`\n\nRegistra un plugin que se crea con su primera llamada.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del plugin. |\n| `fn` | `Function|String` | yes |  | La declaración o una URL. |\n| `init` | `Function|String` | no |  | Se ejecuta antes de la declaración. |\n\nLa declaración también puede ser la URL de un archivo que declara el plugin.\n\nExample: Crear un plugin bajo demanda\n```js\nPLUGINABLE('reports', function(exports) {\n\texports.open = function() {\n\t\tconsole.log('opened'); // opened\n\t};\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.reports == null); // true\n\tEXEC('reports/open');\n}, 500);\n```\n\n### PLUGINS\n\nType: `property`\n\nUn objeto con todos los plugins creados, por nombre.\n\nExample: Leer un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.limit = 10;\n});\nsetTimeout(function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n}, 500);\n```\n\n### PREF\n\nType: `property`\n\nPreferencias de usuario guardadas. Consulta [PREF](../pref/).\n\nExample: Leer el valor\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.theme); // dark\n```\n\n### PUSH(path, value, [delay], [reset])\n\nType: `method`\n\nAñade un valor al array de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Object|Array` | yes |  | El elemento o los elementos que se añaden. |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n| `reset` | `Boolean` | no |  | Con `true`, los componentes del path también se marcan como no tocados y no modificados. |\n\nUn array como valor añade cada uno de sus elementos. Si el path no contiene ningún array, se crea uno nuevo. Un path que empieza por `^` añade al principio. Como en [SET()](#set), el primer argumento puede ser una petición y `value` el path de destino.\n\nExample: Añadir elementos\n```js\nPUSH('tags', 'a');\nPUSH('tags', ['b', 'c']);\nPUSH('^tags', 'first');\nconsole.log(GET('tags')); // [\"first\",\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], obj)\n\nType: `method`\n\nAñade un objeto a una URL como cadena de consulta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | La URL, opcionalmente con un método. |\n| `obj` | `Object` | yes |  | Los valores. |\n\nReturns: `String` La URL.\n\nLos valores vacíos se omiten, los arrays se unen con una coma y las fechas usan el formato ISO.\n\nExample: Construir una URL\n```js\nconsole.log(QUERIFY('GET /users/', { page: 2, tags: ['a', 'b'] })); // GET /users/?page=2&tags=a%2Cb\nconsole.log(QUERIFY({ q: 'x y' })); // ?q=x%20y\n```\n\n### QUEUE([name], fn)\n\nType: `method`\n\nEjecuta funciones una tras otra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | El nombre de la cola. |\n| `fn` | `Function` | yes |  | `function(next, pending)`. |\n\nReturns: `Number` El número de elementos en espera.\n\nLa función recibe `next` y el número de elementos en espera. El siguiente elemento empieza después de llamar a `next()`.\n\nExample: Ejecutar en orden\n```js\nQUEUE('tasks', function(next) {\n\tsetTimeout(next, 50);\n});\nQUEUE('tasks', function(next, pending) {\n\tconsole.log('second', pending); // second 0\n\tnext();\n});\n```\n\n### RECONFIGURE(selector, value)\n\nType: `method`\n\nCambia la configuración de todos los componentes que coinciden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selector como en [FIND()](#find). |\n| `value` | `Object|String` | yes |  | La configuración nueva. |\n\nExample: Cambiar la configuración\n```js\nON('ready', function() {\n\tRECONFIGURE('box', { size: 10 });\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### REDIRECT(url)\n\nType: `method`\n\nNavega a una URL. Consulta [Enrutamiento](../../guides/routing/).\n\n### REMOVECACHE(key)\n\nType: `method`\n\nElimina un valor de la caché del navegador.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clave. |\n\nExample: Eliminar un valor\n```js\nCACHE('profile', 'Peter', '1 day');\nREMOVECACHE('profile');\nconsole.log(CACHE('profile') === undefined); // true\n```\n\n### REPEAT([condition], process, delay, [init])\n\nType: `method`\n\nEjecuta una función repetidamente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | no |  | La condición. |\n| `process` | `Function` | yes |  | `function(counter, scope)`. |\n| `delay` | `Number` | yes |  | El retardo en milisegundos. |\n| `init` | `Boolean` | no |  | Con `true`, la primera ejecución empieza de inmediato. |\n\nLa condición es una función o un path, y la ejecución se omite mientras no se cumple. Con la forma `path__expression`, la expresión recibe la variable `value`. Mientras la página está en segundo plano, no se ejecuta nada salvo que `DEF.repeatfocus` sea `false`.\n\nExample: Ejecutar cada 100 ms\n```js\nREPEAT(function(counter) {\n\tif (counter === 3)\n\t\tconsole.log('third run'); // third run\n}, 100);\n```\n\n### REPO\n\nType: `property`\n\nUn objeto vacío para tus propios datos compartidos.\n\nExample: Leer el valor\n```js\nREPO.items = [1, 2];\nconsole.log(REPO.items.length); // 2\n```\n\n### RESET(path, [delay])\n\nType: `method`\n\nMarca los componentes de un path como no tocados y no modificados, y los vuelve a validar.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo. |\n| `delay` | `Number` | no |  | Un retardo en milisegundos. |\n\nExample: Restablecer un formulario\n```js\nON('ready', function() {\n\tSET('form.name', 'Peter');\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n\tRESET('form.*');\n\tconsole.log(MODIFIED('form.*').length); // 0\n});\n```\n\n### RETURN(command, [multiple])\n\nType: `method`\n\nLee una propiedad de un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `command` | `String` | yes |  | El selector y la propiedad. |\n| `multiple` | `Boolean` | no |  | Con `true`, lee de todos los componentes que coinciden. |\n\nReturns: `Object|Array` El valor, o un array con `multiple`.\n\nEl comando tiene la forma `selector/property`.\n\nExample: Leer una propiedad\n```js\nON('ready', function() {\n\tconsole.log(RETURN('box/title')); // Box\n\tconsole.log(RETURN('box/title', true)); // [\"Box\"]\n});\n```\n\n### REWRITE(path, value, [type])\n\nType: `method`\n\nEscribe un valor sin actualizar los componentes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `type` | `Number` | no |  | El tipo de cambio que se pasa a los observadores. |\n\nLos enlaces de datos y los observadores se siguen ejecutando. Usa el flag `@nowatch` para omitir los observadores.\n\nExample: Escribir sin actualizar los componentes\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nREWRITE('user.name', 'Peter');\n```\n\n### REWRITE2(path, value, [type])\n\nType: `method`\n\nEscribe un valor sin actualizar los componentes ni los enlaces de datos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `type` | `Number` | no |  | El tipo de cambio que se pasa a los observadores. |\n\nLos observadores se siguen ejecutando.\n\nExample: Escribir sin enlaces\n```js\nREWRITE2('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\n```\n\n### ROUTE(url, fn, [middleware], [init])\n\nType: `method`\n\nDeclara una ruta. Consulta [Enrutamiento](../../guides/routing/).\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\nLas opciones:\n\n| Opción | Tipo | Descripción |\n| --- | --- | --- |\n| `orientation` | String | `x` o `y`. Sin ella, ambas direcciones |\n| `visibleX`, `visibleY` | Boolean | Mantiene visible la barra de desplazamiento |\n| `native` | Boolean | Usa la barra de desplazamiento del navegador |\n| `wrap` | Boolean | Con `false`, el contenido no se envuelve |\n| `controls` | jQuery | El elemento para los controles de la barra de desplazamiento |\n| `shadow` | Boolean | Añade sombras en los bordes |\n| `padding` | Number | El relleno de las barras. Valor predeterminado: `5` |\n| `minsize` | Number | El tamaño mínimo de una barra. Valor predeterminado: `50` |\n| `thickness` | Number | El grosor de una barra. Valor predeterminado: `10` |\n| `margin`, `marginX`, `marginY` | Number | Los márgenes |\n| `offsetX`, `offsetY` | Number | Se suman al tamaño de la vista |\n| `parent` | String o Element | Toma el tamaño de este padre |\n| `autoresize` | Boolean | Con `false`, el tamaño no se comprueba al redimensionar |\n| `interval` | Number | El intervalo de la comprobación del tamaño |\n| `onscroll`, `onidle`, `onresize` | Function | Manejadores que reciben la barra de desplazamiento |\n\nEl objeto devuelto tiene los métodos `scrollTop([value])`, `scrollLeft([value])`, `scrollBottom([value])`, `scrollRight([value])`, `scroll(x, y)`, `resize()`, `check()`, `sync(element, [offset])`, `unsync()` y `destroy()`.\n\nExample: Crear una barra de desplazamiento\n```html\n<div id=\"box\" style=\"height:100px\"><div style=\"height:500px\"></div></div>\n<script>\nvar scrollbar = SCROLLBAR($('#box'), { orientation: 'y' });\nconsole.log(typeof(scrollbar.scrollTop)); // function\nconsole.log(M.scrollbars.length); // 1\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nDevuelve el ancho en píxeles de la barra de desplazamiento del navegador.\n\nReturns: `Number` El ancho.\n\nExample: Leer el ancho\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(target, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función o escribe un valor, según el destino.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Function|String` | yes |  | Una función, un método o un 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\nUna función se llama. Una cadena con `/`, o un path que contiene una función, va a [EXEC()](#exec). Cualquier otra cadena es un path, y en él se escribe el primer argumento.\n\nExample: Función o path\n```js\nSEEX(value => console.log(value), 1); // 1\nSEEX('result.value', 2);\nconsole.log(GET('result.value')); // 2\n```\n\n### SET(path, value, [delay], [reset])\n\nType: `method`\n\nEscribe un valor en un path y actualiza todo lo que está enlazado a él.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n| `reset` | `Boolean` | no |  | Con `true`, los componentes del path también se marcan como no tocados y no modificados. |\n\nSe actualizan los componentes, enlaces y observadores del path. El tercer argumento también puede ser `true`, que restablece de inmediato el estado de los componentes.\n\nUn path que empieza por `+` añade el valor a un array como [PUSH()](#push). Un path que empieza por `~` lo fusiona como [EXT()](#ext). Los flags pueden seguir al path: consulta [Flags y modificadores de path](../../guides/flags/).\n\nCuando el primer argumento es una petición como `GET /api/users/`, la respuesta se escribe en el path indicado en `value`.\n\nExample: Escribir un valor\n```js\nSET('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\nExample: Retrasar la escritura\n```js\nSET('search', 'first', 100);\nSET('search', 'second', 100);\nsetTimeout(function() {\n\tconsole.log(GET('search')); // second\n}, 300);\n```\n\nExample: Guardar una respuesta\n```js\nSET('GET /api/users/', 'users.response');\nsetTimeout(function() {\n\tconsole.log(GET('users.response.url')); // /api/users/\n}, 200);\n```\n\n### SETTER(selector, method, [...args])\n\nType: `method`\n\nLlama a un método de todos los componentes que coinciden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selector como en [FIND()](#find). |\n| `method` | `String` | yes |  | El nombre del método. |\n| `...args` | `Object` | no |  | Los argumentos del método. |\n\nEl selector y el método se pueden unir como `selector/method`. Con `true` como primer argumento, la llamada espera al componente. Un selector que empieza por `!` no inicia un componente lazy.\n\nExample: Llamar a un método\n```js\n// The component logs 'Hello ' + name\nON('ready', function() {\n\tSETTER('box', 'hello', 'Peter');\n\tSETTER('box/hello', 'Anna');\n});\n```\n\n### setTimeout2(name, fn, delay, [limit], [arg])\n\nType: `method`\n\nInicia un temporizador con nombre y cancela el temporizador anterior con el mismo nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del temporizador. |\n| `fn` | `Function` | yes |  | La función. |\n| `delay` | `Number` | yes |  | El retardo en milisegundos. |\n| `limit` | `Number` | no |  | Cuántas veces se puede posponer el temporizador. |\n| `arg` | `Object` | no |  | El argumento de la función. |\n\nReturns: `String` El nombre del temporizador.\n\nCon un límite, el temporizador se pospone como máximo ese número de veces, de modo que la función se ejecuta aunque las llamadas sean constantes.\n\nExample: Conservar solo la última llamada\n```js\nfunction search(value) {\n\tconsole.log(value); // last\n}\nsetTimeout2('search', search, 50, null, 'first');\nsetTimeout2('search', search, 50, null, 'last');\n```\n\n### STOPDEBUG()\n\nType: `method`\n\nPausa una y otra vez el depurador del navegador mientras las herramientas de desarrollo están abiertas.\n\nLa función se repite cada 5 segundos y no se puede detener.\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 | `DEF.jsoncompress` | Comprime la salida. |\n| `fields` | `Array|Object|Function` | no |  | Un array de campos permitidos, un objeto con `field: false` o `function(key, value)`. |\n| `encrypt` | `Boolean` | no |  | Cifra la salida con la clave de `DEF.secret()`. |\n\nReturns: `String` El JSON.\n\nLa compresión recorta las cadenas y elimina las cadenas vacías, `false` y `null`.\n\nExample: Serializar un valor\n```js\nconsole.log(STRINGIFY({ a: 1, b: '', c: false }, true)); // {\"a\":1}\nconsole.log(STRINGIFY({ a: 1, b: 2 }, false, ['b'])); // {\"b\":2}\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 estilo. El elemento recibe el id `css` seguido de este valor. |\n| `selector` | `String` | no |  | Un selector que envuelve las reglas. |\n\nUn estilo existente con el mismo identificador se sustituye. Se añade un selector delante de cada regla. `CSS()` es la misma función.\n\nExample: Añadir CSS con scope\n```js\nSTYLE('b { color: red }', 'mystyle', '#panel');\nconsole.log($('#cssmystyle').html()); // #panel b{ color: red }\n```\n\n### Ta\n\nType: `property`\n\nUn nombre corto de `Tangular`.\n\nExample: Leer el valor\n```js\nconsole.log(Ta === Tangular); // true\n```\n\n### Tangular\n\nType: `property`\n\nEl motor de plantillas. Consulta [Plantillas con Tangular](../../guides/tangular/).\n\nExample: Leer el valor\n```js\nconsole.log(Tangular.render('Hello {{ name }}', { name: 'Peter' })); // Hello Peter\n```\n\n### TAPI(name, [data], [callback])\n\nType: `method`\n\nLlama a una API con [DAPI()](#dapi) cuando `DEF.api` está definido, y con [WAPI()](#wapi) en caso contrario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del esquema. |\n| `data` | `Object` | no |  | Los datos. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` o un path. |\n\nReturns: `Object|Promise` El resultado de la función seleccionada.\n\nExample: Seleccionar el transporte\n```js\nDEF.api = '/api/';\nTAPI('users_list', null, function(response) {\n\tconsole.log(response.url); // /api/\n});\n```\n\n### TEMP\n\nType: `property`\n\nUn objeto para datos temporales.\n\nLa biblioteca lo sustituye por un objeto vacío cada cinco minutos.\n\nExample: Leer el valor\n```js\nTEMP.value = 5;\nconsole.log(TEMP.value); // 5\n```\n\n### Thelpers\n\nType: `property`\n\nLos helpers del motor de plantillas. Consulta [Helpers de Tangular](../tangular-helpers/).\n\nExample: Leer el valor\n```js\nconsole.log(typeof(Thelpers)); // object\n```\n\n### TOGGLE(path, [delay], [reset])\n\nType: `method`\n\nEscribe en un path el valor booleano contrario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n| `reset` | `Boolean` | no |  | Con `true`, los componentes del path también se marcan como no tocados y no modificados. |\n\nExample: Alternar un valor\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### TRANSLATE(text)\n\nType: `method`\n\nSustituye cada `@(text)` por su traducción.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | El texto. |\n\nReturns: `String` El texto traducido.\n\nLa clave en `DEF.dictionary` es `HASH(text).toString(36)`, opcionalmente con el prefijo `T`. El texto sin traducción se queda en el idioma original.\n\nExample: Traducir texto\n```js\nDEF.dictionary[HASH('Hello').toString(36)] = 'Ahoj';\nconsole.log(TRANSLATE('@(Hello), @(Peter)')); // Ahoj, Peter\n```\n\n### UNAUTHORIZED(...roles)\n\nType: `method`\n\nIndica si el usuario actual no tiene ninguno de los roles indicados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...roles` | `String` | yes |  | Los roles. |\n\nReturns: `Boolean` `true` cuando el usuario no tiene ninguno de los roles.\n\nEl usuario se lee de `window.user`. Los campos `sa` y `su` lo permiten todo, y los roles proceden de `permissions` o `roles`, como array o como objeto.\n\nExample: Comprobar un rol\n```js\nwindow.user = { roles: ['editor'] };\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [fn])\n\nType: `method`\n\nElimina un observador.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path observado. |\n| `fn` | `Function` | no |  | La función que se pasó a [WATCH()](#watch). |\n\nSin una función, se eliminan todos los observadores del path.\n\nExample: Dejar de observar\n```js\nvar count = 0;\nvar fn = () => count++;\nWATCH('value', fn);\nSET('value', 1);\nUNWATCH('value', fn);\nSET('value', 2);\nconsole.log(count); // 1\n```\n\n### UPD(path, [delay], [reset])\n\nType: `method`\n\nIndica a la biblioteca que el valor de un path ha cambiado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path del valor. Consulta [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un número igual o superior a 10 retrasa el cambio esos milisegundos. Un número menor es el tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n| `reset` | `Boolean` | no |  | Con `true`, los componentes del path también se marcan como no tocados y no modificados. |\n\nÚsala después de cambiar un objeto directamente. Los componentes se actualizan y se llama a los observadores. `UPDATE()` es la misma función. El segundo argumento también puede ser `true`, que restablece el estado de los componentes.\n\nExample: Actualizar tras un cambio directo\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nUPD('user.name');\n```\n\n### UPDATE(path, [delay], [reset])\n\nType: `method`\n\nLa misma función que [UPD()](#upd).\n\nExample: La misma función\n```js\nconsole.log(UPDATE === UPD); // true\n```\n\n### UPLOAD(url, data, [callback], [delay], [progress])\n\nType: `method`\n\nSube datos a un servidor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL, opcionalmente con un método. |\n| `data` | `FormData|Object` | yes |  | Los datos. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` o un path. |\n| `delay` | `Number` | no |  | Espera estos milisegundos antes de enviar. |\n| `progress` | `Function|String` | no |  | `function(percentage)` o un path. |\n\nReturns: `Promise` Solo cuando no se indica ningún callback.\n\nEl método predeterminado es `POST`. `FormData` se envía tal cual, y todo lo demás como JSON. Sin callback, la función devuelve una Promise. `progress` puede ser el cuarto argumento cuando no se necesita ningún retraso.\n\nExample: Subir un archivo\n```js\nvar data = new FormData();\ndata.append('name', 'photo.jpg');\nUPLOAD('/api/upload/', data, function(response) {\n\tconsole.log(response.url); // /api/upload/\n});\n```\n\n### VALID(path, [flags])\n\nType: `method`\n\nIndica si ningún componente de un path es inválido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con `.*` para todo lo que hay debajo. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita la comprobación a esos componentes. |\n\nReturns: `Boolean` El resultado.\n\nA diferencia de [CAN()](#can), no tiene en cuenta si los componentes están tocados.\n\nExample: Comprobar un formulario\n```js\nON('ready', function() {\n\tconsole.log(VALID('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tconsole.log(VALID('form.*')); // true\n});\n```\n\n### VBIND(html)\n\nType: `method`\n\nCrea un binder virtual a partir de HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | El HTML con enlaces. |\n\nReturns: `VBinder` El binder virtual.\n\nEl objeto se describe en [Binder virtual](../vbinder/), y el tema en [Enlaces virtuales](../../guides/virtual-bindings/).\n\nExample: Enlazar un elemento independiente\n```js\nvar binder = VBIND('<div><span data-bind=\"name__text\"></span></div>');\nbinder.set({ name: 'Peter' });\nconsole.log(binder.element.find('span').text()); // Peter\n```\n\n### VBINDARRAY(html, element)\n\nType: `method`\n\nRenderiza un array con un binder virtual para cada elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | El HTML de un elemento. |\n| `element` | `Element|jQuery|Component` | yes |  | El elemento padre. |\n\nReturns: `Object` Un objeto con los métodos `set()`, `get()`, `upd()` y `remove()`.\n\nEl tema se explica en [Enlaces virtuales](../../guides/virtual-bindings/).\n\nExample: Renderizar una lista\n```html\n<ul id=\"list\"></ul>\n<script>\nvar list = VBINDARRAY('<li data-bind=\"name__text\"></li>', $('#list'));\nlist.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log($('#list').text()); // PeterAnna\n</script>\n```\n\n### VERSION(...items)\n\nType: `method`\n\nSelecciona la versión de los componentes que se usan sin versión.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...items` | `String` | yes |  | Los componentes y sus versiones. |\n\nCada elemento tiene la forma `name@version`, y una cadena puede enumerar varios elementos separados por una coma.\n\nExample: Seleccionar una versión\n```html\n<ui-component name=\"tag\"></ui-component>\n<script>\nCOMPONENT('tag@2', function(self) {\n\tself.make = () => self.element.text('two');\n});\nVERSION('tag@2');\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // two\n});\n</script>\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nIndica si un elemento está en la altura visible de la ventana.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | El elemento. |\n| `threshold` | `Number` | no | `0` | Un margen en píxeles. |\n| `mode` | `String` | no | `visible` | `visible`, `above` o `below`. |\n\nReturns: `Boolean` El resultado.\n\nExample: Comprobar un elemento\n```html\n<div id=\"box\">Box</div>\n<script>\nconsole.log(VISIBLE($('#box'))); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nUn nombre corto de `window`.\n\nExample: Leer el valor\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback, [interval], [timeout])\n\nType: `method`\n\nEspera hasta que se cumple una condición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | La función o el path que se comprueba. |\n| `callback` | `Function` | yes |  | `function(err, again)`. |\n| `interval` | `Number` | no | `500` | El intervalo de las comprobaciones en milisegundos. |\n| `timeout` | `Number` | no |  | La espera máxima en milisegundos. |\n\nLa condición es una función o un path. El callback recibe un error cuando se agota el tiempo de espera, y una función que vuelve a iniciar la espera. Sin tiempo de espera, la espera nunca termina por sí sola.\n\nExample: Esperar a un valor\n```js\nWAIT('app.ready', function() {\n\tconsole.log(GET('app.ready')); // true\n}, 50);\nsetTimeout(() => SET('app.ready', true), 100);\n```\n\nExample: Detenerse al agotarse el tiempo de espera\n```js\nWAIT(() => false, function(err) {\n\tconsole.log(err.message); // Timeout.\n}, 50, 200);\n```\n\n### WAPI([name], [data], [callback], [timeout])\n\nType: `method`\n\nLlama a una API a través de la conexión WebSocket.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | no |  | El nombre del esquema o las opciones de conexión. |\n| `data` | `Object` | no |  | Los datos. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` o un path. |\n| `timeout` | `Number` | no | `10000` | El tiempo de espera en milisegundos. |\n\nReturns: `Object|Promise` La conexión o una Promise.\n\nUn objeto como primer argumento abre la conexión como [WAPI_INIT()](#wapi-init). Sin argumentos, la función devuelve la conexión abierta. Sin callback, devuelve una Promise. El tiempo de espera predeterminado de una llamada es de 10 segundos.\n\nExample: Llamar a través de un socket\n```js\nWAPI({ url: '/api/' });\nWAPI('users_list', null, function(response) {\n\tconsole.log(response.schema); // users_list\n});\n```\n\n### WAPI_INIT(options)\n\nType: `method`\n\nAbre la conexión WebSocket que usa [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Las opciones de conexión. |\n\nReturns: `Object` El objeto de opciones con los métodos añadidos.\n\nLas opciones son `url`, `reconnect` (un retraso en milisegundos, o `false`), `expire` (se reconecta después de este tiempo), `callback` (se llama una vez después del primer intento de conexión) y los manejadores `open`, `close(e)` y `message(data)`.\n\nEl objeto devuelto tiene los métodos `send(name, data, callback, [timeout])`, `on(name, fn)` para los eventos `open`, `close`, `message` y `reconnect`, `emit(name, ...)` y `pause(is)`.\n\nExample: Abrir una conexión\n```js\nWAPI_INIT({\n\turl: '/api/',\n\topen: function() {\n\t\tconsole.log('connected'); // connected\n\t}\n});\nconsole.log(typeof(WAPI().send)); // function\n```\n\n### WARN(...args)\n\nType: `method`\n\nEscribe un aviso en la consola.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...args` | `Object` | yes |  | Los valores que se escriben. |\n\nExample: Escribir un aviso\n```js\nWARN('Disk is full');\nconsole.log(typeof(WARN)); // function\n```\n\n### WATCH(path, fn, [init])\n\nType: `method`\n\nLlama a una función cuando cambia el valor de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path que se observa. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n| `init` | `Boolean` | no |  | Con `true`, la función también se llama de inmediato. |\n\nLa función recibe el path que ha cambiado, el valor y el tipo de cambio: `0` llamada inicial, `1` manual, `2` entrada, `3` predeterminado. Un path `users.*` también reacciona a todo lo que hay debajo de `users`. Puedes separar varios paths con un espacio, y un path que empieza por `^` se ejecuta antes que los demás observadores.\n\nExample: Reaccionar a un cambio\n```js\nWATCH('user.name', function(path, value, type) {\n\tconsole.log(path, value, type); // user.name Peter 1\n});\nSET('user.name', 'Peter');\n```\n\nExample: Llamarla de inmediato\n```js\nSET('count', 5);\nWATCH('count', function(path, value, type) {\n\tconsole.log(value, type); // 5 0\n}, true);\n```\n\n### WATCHONCE(path, fn)\n\nType: `method`\n\nLlama a una función solo en el siguiente cambio de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path que se observa. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n\nExample: Reaccionar una vez\n```js\nWATCHONCE('count', function(path, value) {\n\tconsole.log(value); // 1\n});\nSET('count', 1);\nSET('count', 2);\n```\n\n### WH\n\nType: `property`\n\nLa altura de la ventana en píxeles.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(WH)); // number\n```\n\n### WIDTH([element])\n\nType: `method`\n\nDevuelve el tamaño de pantalla de la ventana o de un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | El elemento. |\n\nReturns: `String` `xs`, `sm`, `md` o `lg`.\n\nLos límites están en `DEF.devices`.\n\nExample: Leer el tamaño de un elemento\n```html\n<div id=\"box\" style=\"width:1000px\"></div>\n<script>\nconsole.log(WIDTH($('#box'))); // md\n</script>\n```\n\n### WORKFLOW(declaration, [tasks], [callback])\n\nType: `method`\n\nEjecuta pasos con nombre que se transmiten un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `declaration` | `Function` | yes |  | `function($)`. |\n| `tasks` | `Object` | no |  | Los pasos por nombre. |\n| `callback` | `Function` | no |  | `function(value, err, $)`. |\n\nReturns: `Object` El flujo de trabajo.\n\nEl objeto que se pasa a la declaración y a cada paso tiene estos miembros:\n\n| Miembro | Descripción |\n| --- | --- |\n| `push(name, fn)` | Añade un paso: `function($, value)` |\n| `next(name, [value])` | Ejecuta un paso. Un nombre desconocido termina el flujo de trabajo |\n| `next2(name)` | Devuelve un callback que ejecuta el paso |\n| `done([value])` | Llama al callback final con el valor |\n| `invalid(err)` | Comunica un error a `error` o al callback final |\n| `callback(fn)` | Sustituye el callback final |\n| `clone()` | Crea un flujo de trabajo con los mismos pasos |\n| `destroy()` | Termina el flujo de trabajo |\n| `value`, `current`, `prev` | El valor, el paso actual y el paso anterior |\n\nExample: Ejecutar dos pasos\n```js\nWORKFLOW(function($) {\n\t$.push('load', ($, value) => $.next('save', value + 1));\n\t$.push('save', ($, value) => $.done(value * 2));\n\t$.next('load', 1);\n}, function(value) {\n\tconsole.log(value); // 4\n});\n```\n\n### WW\n\nType: `property`\n\nEl ancho de la ventana en píxeles.\n\nExample: Leer el valor\n```js\nconsole.log(typeof(WW)); // number\n```\n","entries":[{"type":"method","name":"ACMD()","signature":"ACMD(name, [...args])","since":"","deprecated":false},{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"ADD()","signature":"ADD(value, [element], [config], [content])","since":"","deprecated":false},{"type":"method","name":"AEXEC()","signature":"AEXEC(path, [...args])","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], [callback], [delay])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHE()","signature":"AJAXCACHE(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHEREVIEW()","signature":"AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCONFIG()","signature":"AJAXCONFIG(name, fn)","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BIND()","signature":"BIND(path)","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(name, 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, [rebind])","since":"","deprecated":false},{"type":"method","name":"CAN()","signature":"CAN(path, [flags])","since":"","deprecated":false},{"type":"method","name":"CHANGE()","signature":"CHANGE(path, [value])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, callback)","since":"","deprecated":false},{"type":"method","name":"CL_INIT()","signature":"CL_INIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [nopath])","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], [e])","since":"","deprecated":false},{"type":"method","name":"COMPILE()","signature":"COMPILE([container])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], declaration, [dependencies])","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":"method","name":"DAPI()","signature":"DAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"method","name":"DEBUG()","signature":"DEBUG()","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DEFAULT()","signature":"DEFAULT(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"DISABLED()","signature":"DISABLED(path, [flags])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [...args])","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(value, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, [flags], [highlight])","since":"","deprecated":false},{"type":"method","name":"EVALUATE()","signature":"EVALUATE(path, expression, [nopath])","since":"","deprecated":false},{"type":"method","name":"EXE()","signature":"EXE([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXT()","signature":"EXT(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTEND()","signature":"EXTEND(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], declaration)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [many], [nocache], [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(expression)","since":"","deprecated":false},{"type":"method","name":"FORMATTER()","signature":"FORMATTER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE([delay])","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [scope])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([size])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value, [unsigned])","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"IMPORTCACHE()","signature":"IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value], [delay], [reset])","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":"method","name":"MACRO()","signature":"MACRO(name, declaration)","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"method","name":"MAKE()","signature":"MAKE([target], fn, [update])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, fn)","since":"","deprecated":false},{"type":"method","name":"MODIFIED()","signature":"MODIFIED(path, [flags])","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"property","name":"NAV","signature":"NAV","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, target, [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":"method","name":"NOTIFY()","signature":"NOTIFY(...paths)","since":"","deprecated":false},{"type":"method","name":"NOTMODIFIED()","signature":"NOTMODIFIED(path, [value], [fields])","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"NULL()","signature":"NULL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [path], [fn])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, [path], fn, [init])","since":"","deprecated":false},{"type":"method","name":"OPT()","signature":"OPT([obj], fn)","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value, [date])","since":"","deprecated":false},{"type":"method","name":"PARSER()","signature":"PARSER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [fn], [init], [done])","since":"","deprecated":false},{"type":"method","name":"PLUGINABLE()","signature":"PLUGINABLE(name, fn, [init])","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, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], obj)","since":"","deprecated":false},{"type":"method","name":"QUEUE()","signature":"QUEUE([name], fn)","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT(url)","since":"","deprecated":false},{"type":"method","name":"REMOVECACHE()","signature":"REMOVECACHE(key)","since":"","deprecated":false},{"type":"method","name":"REPEAT()","signature":"REPEAT([condition], process, delay, [init])","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path, [delay])","since":"","deprecated":false},{"type":"method","name":"RETURN()","signature":"RETURN(command, [multiple])","since":"","deprecated":false},{"type":"method","name":"REWRITE()","signature":"REWRITE(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"REWRITE2()","signature":"REWRITE2(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"ROUTE()","signature":"ROUTE(url, fn, [middleware], [init])","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(target, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, fn, delay, [limit], [arg])","since":"","deprecated":false},{"type":"method","name":"STOPDEBUG()","signature":"STOPDEBUG()","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":"property","name":"Ta","signature":"Ta","since":"","deprecated":false},{"type":"property","name":"Tangular","signature":"Tangular","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"property","name":"Thelpers","signature":"Thelpers","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...roles)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [fn])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPDATE()","signature":"UPDATE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPLOAD()","signature":"UPLOAD(url, data, [callback], [delay], [progress])","since":"","deprecated":false},{"type":"method","name":"VALID()","signature":"VALID(path, [flags])","since":"","deprecated":false},{"type":"method","name":"VBIND()","signature":"VBIND(html)","since":"","deprecated":false},{"type":"method","name":"VBINDARRAY()","signature":"VBINDARRAY(html, element)","since":"","deprecated":false},{"type":"method","name":"VERSION()","signature":"VERSION(...items)","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, [interval], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI()","signature":"WAPI([name], [data], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI_INIT()","signature":"WAPI_INIT(options)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...args)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, fn, [init])","since":"","deprecated":false},{"type":"method","name":"WATCHONCE()","signature":"WATCHONCE(path, fn)","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"method","name":"WORKFLOW()","signature":"WORKFLOW(declaration, [tasks], [callback])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammaB9IM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/globals/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Fonctions globales","summary":"Les fonctions et les objets que jComponent ajoute à l'objet window.","markdown":"---\ntitle: Fonctions globales\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/globals/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Fonctions globales\n\n> Les fonctions et les objets que jComponent ajoute à l'objet window.\n\njComponent ajoute ces fonctions et ces objets à `window` : tu peux donc les utiliser partout sans import. Pour comprendre d'abord le fonctionnement des paths, lis [Paths](../../guides/paths/).\n\n## API\n\n### ACMD(name, [...args])\n\nType: `method`\n\nCrée une fonction qui appelle [CMD()](#cmd) plus tard.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la commande. |\n| `...args` | `Object` | no |  | Les premiers arguments. |\n\nReturns: `Function` La fonction à appeler.\n\nL'argument de la fonction créée est ajouté comme dernier argument de la commande.\n\nExample: L'utiliser comme callback\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nACMD('refresh')(1);\n```\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrépare un texte importé pour un path et un identifiant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | La valeur de `~PATH~` et de `CLASS`. |\n| `id` | `String` | yes |  | La valeur de `~ID~`. |\n| `text` | `String` | yes |  | Le texte. |\n\nReturns: `String` Le texte modifié.\n\nLe texte est traduit, les variables `--name--` sont remplacées, `~CDN~` devient `DEF.cdn`, `~PATH~` et `CLASS` deviennent le path, et `~ID~` devient l'identifiant.\n\nExample: Remplacer les marqueurs\n```js\nconsole.log(ADAPT('users', 'form1', '~PATH~ and ~ID~')); // users and form1\n```\n\n### ADD(value, [element], [config], [content])\n\nType: `method`\n\nAjoute un composant à la page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object|Array` | yes |  | Le composant. |\n| `element` | `Element|jQuery|Component` | no | `document.body` | L'élément parent. |\n| `config` | `Object|String` | no |  | La configuration. |\n| `content` | `String` | no |  | Le HTML interne. |\n\nUne chaîne a la forme `name__path__config`. Un `!` initial ignore le composant s'il est déjà déclaré. Un objet peut avoir les champs `name`, `path`, `config`, `element` et `prepend`. Un tableau ajoute plusieurs composants.\n\nExample: Ajouter un composant\n```js\nADD('box__data.title__size:10');\nsetTimeout(function() {\n\tconsole.log(FIND('box').config.size); // 10\n}, 1200);\n```\n\n### AEXEC(path, [...args])\n\nType: `method`\n\nCrée une fonction qui appelle [EXEC()](#exec) plus tard.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | La cible. |\n| `...args` | `Object` | no |  | Les premiers arguments. |\n\nReturns: `Function` La fonction à appeler.\n\nL'argument de la fonction créée est ajouté comme dernier argument.\n\nExample: L'utiliser comme callback\n```js\nwindow.save = value => console.log(value); // 5\nAEXEC('save')(5);\n```\n\n### AJAX(url, [data], [callback], [delay])\n\nType: `method`\n\nEnvoie une requête HTTP.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La méthode et l'URL. |\n| `data` | `Object|String` | no |  | Les données. Une requête `GET` les envoie dans la chaîne de requête. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, ou un path. |\n| `delay` | `Number` | no |  | Attend ce nombre de millisecondes avant l'envoi. |\n\nReturns: `Promise` Uniquement quand aucun callback n'est fourni.\n\nL'URL a la forme `METHOD /path/`. D'autres éléments peuvent la suivre, séparés par une espace :\n\n| Élément | Signification |\n| --- | --- |\n| `!METHOD` | Envoie les cookies avec la requête |\n| `{ \"Name\": \"value\" }` | En-têtes de la requête |\n| `<5 minutes>` | Met la réponse en cache, comme [AJAXCACHE()](#ajaxcache) |\n| `(name)` | Applique les réglages de [AJAXCONFIG()](#ajaxconfig) |\n| `repeat` | Répète la requête quand le serveur n'est pas disponible |\n| `cancel` | Annule la requête précédente non terminée vers la même URL |\n| `urlencoded` | Envoie les données sous forme de formulaire encodé en URL |\n| `json` | N'accepte qu'une réponse JSON |\n| `error` | Fait passer la réponse par [ERROR()](#error) |\n| `noencrypt`, `nodecrypt`, `nocsrf` | Ignore le chiffrement, le déchiffrement ou l'en-tête CSRF |\n| `#id` | Nomme la requête pour `cancel`, ou attend une liste de codes |\n| `@flag` | Émet un flag personnalisé |\n\nLe callback reçoit la réponse, le code de statut en cas d'erreur et un objet contenant les détails de la requête. Un callback sous forme de chaîne est un path où la réponse est stockée. Sans callback, la fonction renvoie une Promise, rejetée pour un statut supérieur à 399.\n\nExample: Envoyer des données\n```js\nAJAX('POST /api/users/', { name: 'Peter' }, function(response, err) {\n\tconsole.log(response.method, response.url); // POST /api/users/\n\tconsole.log(response.body); // {\"name\":\"Peter\"}\n});\n```\n\nExample: Utiliser une Promise\n```js\n(async function() {\n\tvar response = await AJAX('GET /api/users/');\n\tconsole.log(response.url); // /api/users/\n})();\n```\n\nExample: Gérer une erreur\n```js\nAJAX('GET /api/missing/', function(response, err) {\n\tconsole.log(err, response); // 404 Not found\n});\n```\n\n### AJAXCACHE(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nEnvoie une requête et met la réponse en cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La méthode et l'URL. |\n| `data` | `Object` | no |  | Les données. |\n| `callback` | `Function|String` | yes |  | `function(response, cached)`, ou un path. |\n| `expire` | `String` | yes |  | Par exemple `5 minutes` ou `session`. |\n| `delay` | `Number` | no |  | Attend ce nombre de millisecondes avant la lecture. |\n| `clear` | `Boolean` | no |  | Avec `true`, ignore la réponse stockée. |\n\nLe callback reçoit la réponse, et `true` quand elle provient du cache. La valeur `session` pour `expire` conserve la réponse en mémoire jusqu'au rechargement de la page.\n\nExample: Mettre une réponse en cache\n```js\nAJAXCACHE('GET /api/users/', function(response, cached) {\n\tconsole.log('first', cached); // first false\n\tAJAXCACHE('GET /api/users/', function(response, cached) {\n\t\tconsole.log('second', cached); // second true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nRenvoie la réponse en cache, puis vérifie sur le serveur s'il en existe une plus récente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La méthode et l'URL. |\n| `data` | `Object` | no |  | Les données. |\n| `callback` | `Function|String` | yes |  | `function(response, cached, updated)`, ou un path. |\n| `expire` | `String` | yes |  | Par exemple `5 minutes`. |\n| `delay` | `Number` | no |  | Attend ce nombre de millisecondes avant la lecture. |\n| `clear` | `Boolean` | no |  | Avec `true`, ignore la réponse stockée. |\n\nQuand le serveur renvoie des données différentes, le callback s'exécute de nouveau avec `false` et `true` comme deuxième et troisième arguments.\n\nExample: Actualiser une réponse en cache\n```js\nAJAXCACHE('GET /api/time/', function() {\n\tAJAXCACHEREVIEW('GET /api/time/', function(response, cached, updated) {\n\t\tconsole.log(response.value, cached, updated === true); // 2 false true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCONFIG(name, fn)\n\nType: `method`\n\nDéclare des réglages qu'une requête peut appliquer par leur nom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom des réglages. |\n| `fn` | `Function` | yes |  | `function(options)`. |\n\nUne requête les applique avec `(name)` dans son URL. La fonction reçoit les options de la requête.\n\nExample: Ajouter un en-tête\n```js\nAJAXCONFIG('secure', function(options) {\n\toptions.headers['X-Token'] = 'abc';\n});\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-Token']); // abc\n\topt.respond({});\n});\nAJAX('GET /api/users/ (secure)', NOOP);\n```\n\n### API(url, [data], [callback])\n\nType: `method`\n\nAppelle un point de terminaison d'API Total.js.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Le point de terminaison et le schéma. |\n| `data` | `Object` | no |  | Les données. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, ou un path. |\n\nReturns: `Object|Promise` L'objet décrit ci-dessus, ou une Promise.\n\nL'URL a la forme `/api/ schema`. La requête est un `POST` contenant le nom du schéma et les données dans son corps. Sans callback, la fonction renvoie une Promise. Avec un callback, elle renvoie un objet doté de `params(value)`, qui renseigne les paramètres du schéma, et de `data(value)`, qui remplace les données.\n\nExample: Appeler un point de terminaison\n```js\nAPI('/api/ users_save', { name: 'Peter' }, function(response) {\n\tconsole.log(response.url); // /api/\n\tconsole.log(response.body); // {\"schema\":\"users_save\",\"data\":{\"name\":\"Peter\"}}\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nDéfinit l'apparence de l'application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Les variables CSS et les champs `dark` et `large`. |\n\nChaque champ devient une variable CSS sur `:root`. `dark` et `large` basculent les classes `ui-dark` et `ui-large` sur le body. `color` est une couleur hexadécimale à six chiffres, qui définit aussi `DEF.color` et la variable `--rgb`.\n\nExample: Utiliser un thème sombre\n```js\nAPPEARANCE({ dark: true, color: '#336699' });\nconsole.log($('#cssappearance').html()); // :root{--color:#336699;--rgb:51,102,153}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\n### ASETTER(selector, method, [...args])\n\nType: `method`\n\nCrée une fonction qui appelle [SETTER()](#setter) plus tard.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un sélecteur comme dans [FIND()](#find). |\n| `method` | `String` | yes |  | Le nom de la méthode. |\n| `...args` | `Object` | no |  | Les premiers arguments de la méthode. |\n\nReturns: `Function` La fonction à appeler.\n\nL'argument de la fonction créée est ajouté comme dernier argument de la méthode : elle convient donc comme callback de requête.\n\nExample: L'utiliser comme callback\n```js\nON('ready', function() {\n\tvar fn = ASETTER('box', 'hello');\n\tfn('Peter');\n\tconsole.log(typeof(fn)); // function\n});\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLit un attribut `data-` sur un élément ou ses parents.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery|Event|Object` | yes |  | La source. |\n| `name` | `String` | no | `id` | Le nom de l'attribut. |\n\nReturns: `String` La valeur.\n\nUn objet simple renvoie son champ portant ce nom.\n\nExample: Lire un identifiant\n```html\n<div id=\"row\" data-id=\"15\" data-type=\"user\"></div>\n<script>\nconsole.log(ATTRD($('#row'))); // 15\nconsole.log(ATTRD($('#row'), 'type')); // user\n</script>\n```\n\n### BIND(path)\n\nType: `method`\n\nActualise les liaisons de données d'un path sans notifier les composants ni les observateurs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Array` | yes |  | Un path ou une liste de paths. |\n\nExample: Actualiser une liaison\n```html\n<span id=\"name\" data-bind=\"user.name__text\"></span>\n<script>\nSET('user', { name: 'Peter' });\nsetTimeout(function() {\n\tGET('user').name = 'Anna';\n\tBIND('user.name');\n\tsetTimeout(function() {\n\t\tconsole.log($('#name').text()); // Anna\n\t}, 300);\n}, 300);\n</script>\n```\n\n### BLOCKED(name, timeout, [callback])\n\nType: `method`\n\nLimite la fréquence d'exécution d'une action.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'action. |\n| `timeout` | `Number|String` | yes |  | Des millisecondes, ou une valeur comme `5 seconds`. |\n| `callback` | `Function` | no |  | S'exécute quand l'action n'est pas bloquée. |\n\nReturns: `Boolean` `true` quand l'action est bloquée.\n\nLe premier appel renvoie `false` et bloque le nom pendant la durée indiquée. Un blocage de plus de 10 secondes est conservé dans le stockage du navigateur.\n\nExample: Autoriser un appel par seconde\n```js\nconsole.log(BLOCKED('save', 1000)); // false\nconsole.log(BLOCKED('save', 1000)); // true\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLit ou écrit une valeur dans le cache du navigateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé. |\n| `value` | `Object` | no |  | La valeur à stocker. |\n| `expire` | `String|Number` | no |  | Par exemple `1 day`, `session`, ou des millisecondes. |\n\nReturns: `Object` La valeur stockée.\n\nUne valeur n'est stockée qu'avec une expiration. La valeur `session` la conserve en mémoire jusqu'au rechargement de la page.\n\nExample: Stocker une valeur\n```js\nCACHE('profile', { name: 'Peter' }, '1 day');\nconsole.log(CACHE('profile')); // {\"name\":\"Peter\"}\n```\n\n### CACHEPATH(path, expire, [rebind])\n\nType: `method`\n\nConserve la valeur d'un path dans le cache du navigateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `expire` | `String` | yes |  | Par exemple `1 month`. |\n| `rebind` | `Boolean` | no | `true` | Avec `false`, la valeur stockée n'est pas restaurée. |\n\nChaque changement du path est stocké, et la valeur stockée est restaurée à la visite suivante. Avec la forme `path__value`, l'expression est la valeur utilisée quand rien n'est stocké.\n\nExample: Mémoriser une valeur\n```js\nCACHEPATH('settings.theme', '1 month');\nSET('settings.theme', 'dark');\nconsole.log(CACHE('PATHS')); // {\"settings.theme\":\"dark\"}\n```\n\n### CAN(path, [flags])\n\nType: `method`\n\nIndique si un formulaire peut être envoyé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous. |\n| `flags` | `String|Array` | no |  | `visible` ou `hidden` limite la vérification à ces composants. |\n\nReturns: `Boolean` Le résultat.\n\nLe résultat est `true` quand au moins un composant du path est touché et qu'aucun n'est invalide. Un path sans composant renvoie aussi `true`.\n\nExample: Activer un bouton d'envoi\n```js\nON('ready', function() {\n\tconsole.log(CAN('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tCHANGE('form.name');\n\tconsole.log(CAN('form.*')); // true\n});\n```\n\n### CHANGE(path, [value])\n\nType: `method`\n\nMarque les composants d'un path comme touchés et modifiés.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Boolean` | no | `true` | Avec `false`, les marques sont retirées. |\n\nExample: Marquer un champ comme modifié\n```js\nON('ready', function() {\n\tCHANGE('form.age');\n\tconsole.log(MODIFIED('form.*')); // [\"form.age\"]\n});\n```\n\n### CL(name, callback)\n\nType: `method`\n\nAttend que les listes de codes soient chargées.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `callback` | `Function` | yes |  | S'exécute quand les listes sont prêtes. |\n\nTu peux séparer plusieurs noms par une virgule. Les valeurs chargées sont stockées dans `DEF.cl`.\n\nExample: Attendre une liste de codes\n```js\nCL_INIT('countries', next => next(['SK', 'CZ']));\nCL('countries', function() {\n\tconsole.log(DEF.cl.countries); // [\"SK\",\"CZ\"]\n});\n```\n\n### CL_INIT(name, source, [expire], [init])\n\nType: `method`\n\nDéclare comment une liste de codes est chargée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `source` | `Function|String` | yes |  | Le chargeur. |\n| `expire` | `String` | no |  | La liste est de nouveau chargée après cette durée. |\n| `init` | `Boolean` | no |  | Avec `true`, charge la liste immédiatement. |\n\nLa source est une fonction qui reçoit `next(value)`, ou une chaîne. Une chaîne qui commence par une méthode HTTP est transmise à [AJAX()](#ajax), et toute autre chaîne à [TAPI()](#tapi). `CLINIT()` est la même fonction.\n\nExample: Charger une liste depuis une URL\n```js\nCL_INIT('roles', 'GET /api/roles/', true);\nsetTimeout(function() {\n\tconsole.log(DEF.cl.roles.url); // /api/roles/\n}, 300);\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nAnnule un minuteur nommé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du minuteur. |\n\nReturns: `Boolean` `true` quand un minuteur était en cours.\n\nExample: Annuler un minuteur\n```js\nsetTimeout2('save', NOOP, 1000);\nconsole.log(clearTimeout2('save')); // true\nconsole.log(clearTimeout2('save')); // false\n```\n\n### CLINIT(name, source, [expire], [init])\n\nType: `method`\n\nLa même fonction que [CL_INIT()](#cl-init).\n\nExample: Même fonction\n```js\nconsole.log(CLINIT === CL_INIT); // true\n```\n\n### CLONE(value, [nopath])\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 ou un path. |\n| `nopath` | `Boolean` | no |  | Avec `true`, une chaîne est renvoyée telle quelle. |\n\nReturns: `Object` La copie.\n\nUne chaîne est traitée comme un path, et la valeur du path est clonée.\n\nExample: Cloner une valeur\n```js\nSET('user', { name: 'Peter' });\nvar copy = CLONE('user');\ncopy.name = 'Anna';\nconsole.log(GET('user.name')); // Peter\nconsole.log(copy.name); // Anna\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nRecharge des listes de codes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `callback` | `Function` | no |  | S'exécute quand les listes sont chargées. |\n\nTu peux séparer plusieurs noms par une virgule.\n\nExample: Recharger une liste\n```js\nvar count = 0;\nCL_INIT('numbers', next => next([++count]), true);\nsetTimeout(function() {\n\tCLRELOAD('numbers', function() {\n\t\tconsole.log(DEF.cl.numbers); // [2]\n\t});\n}, 100);\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nExécute une commande dans tous les composants qui l'ont enregistrée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la commande. |\n| `a` | `Object` | no |  | Jusqu'à cinq arguments, de `a` à `e`. |\n\nLes composants enregistrent des commandes avec `self.command()`.\n\nExample: Exécuter une commande\n```js\nON('ready', function() {\n\tCMD('box.ping', 5);\n});\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // box.ping 5\n});\n```\n\n### COMPILE([container])\n\nType: `method`\n\nRecherche sur la page les nouveaux composants et les nouvelles liaisons.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limite la recherche à cet élément. |\n\nAppelle-la après avoir ajouté du HTML à la main.\n\nExample: Compiler du nouveau HTML\n```js\n$(document.body).append('<ui-component name=\"box\" path=\"data.new\"></ui-component>');\nCOMPILE();\nsetTimeout(function() {\n\tconsole.log(FIND('box').path); // data.new\n}, 500);\n```\n\n### COMPONENT(name, [config], declaration, [dependencies])\n\nType: `method`\n\nDéclare un composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du composant. |\n| `config` | `String|Object` | no |  | La configuration par défaut. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n| `dependencies` | `Array` | no |  | Les fichiers à importer d'abord, ou des noms de composants commençant par `@`. |\n\nTu peux séparer plusieurs noms par une virgule. Une version peut suivre le nom : `box@2`. Le sujet est expliqué en détail dans [Créer des composants](../../guides/creating-components/), et l'objet que reçoit la déclaration est décrit dans [Component](../component/).\n\nExample: Déclarer un composant\n```html\n<ui-component name=\"hello\"></ui-component>\n<script>\nCOMPONENT('hello', 'name:World', function(self, config) {\n\tself.make = () => self.element.text('Hello ' + config.name);\n});\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // Hello World\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nListe les composants d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path avec des flags facultatifs. |\n\nReturns: `Array` Les composants.\n\nLe path s'écrit sans `.*`. Les flags placés après le path filtrent la liste : `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` et `@enabled`.\n\nExample: Filtrer les composants\n```js\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tSET('form.name', 'Peter');\n\tconsole.log(COMPONENTS('form @invalid').map(com => com.path)); // [\"form.age\"]\n});\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nDéfinit la configuration des composants avant leur démarrage.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Les composants à configurer. |\n| `config` | `Object|String|Function` | yes |  | La configuration, ou une fonction qui la renvoie. |\n\nLe sélecteur est un nom de composant, `.path`, `#id`, ou une fonction qui reçoit le composant et renvoie un booléen. Les parties séparées par une espace doivent toutes correspondre, et une virgule sépare les alternatives. Appelle-la avant la compilation des composants.\n\nExample: Configurer par nom\n```js\nCONFIG('box', { size: 10 });\nON('ready', function() {\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### COOKIES\n\nType: `property`\n\nUn objet pour lire et écrire des cookies.\n\nIl possède les méthodes `get(name)`, `set(name, value, expire, [samesite])` et `rem(name)`. `expire` est une `Date` ou une valeur comme `1 day`.\n\nExample: Lire la valeur\n```js\nCOOKIES.set('theme', 'dark', '1 day');\nconsole.log(COOKIES.get('theme') === 'dark' || location.protocol === 'file:'); // true\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopie les champs 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 à écrire. |\n\nReturns: `Object` L'objet cible.\n\nLes objets contenus dans la source sont clonés.\n\nExample: Copier des champs\n```js\nvar target = COPY({ a: 1 }, { b: 2 });\nconsole.log(target); // {\"b\":2,\"a\":1}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nLa même fonction que [STYLE()](#style).\n\nExample: Même fonction\n```js\nconsole.log(CSS === STYLE); // true\n```\n\n### DAPI(name, [data], [callback])\n\nType: `method`\n\nAppelle le point de terminaison d'API défini dans `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du schéma. |\n| `data` | `Object` | no |  | Les données. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, ou un path. |\n\nReturns: `Object|Promise` Identique à [API()](#api).\n\n`DEF.api` est une URL, ou une fonction qui reçoit le nom et les données et renvoie la valeur pour [API()](#api).\n\nExample: Utiliser le point de terminaison par défaut\n```js\nDEF.api = '/api/';\nDAPI('users_list', null, function(response) {\n\tconsole.log(response.url, response.body.schema); // /api/ users_list\n});\n```\n\n### DAYS\n\nType: `property`\n\nLes noms des jours, en commençant par le dimanche.\n\nExample: Lire la valeur\n```js\nconsole.log(DAYS[0]); // Sunday\n```\n\n### DEBUG()\n\nType: `method`\n\nActive le mode de débogage.\n\nLes appels de méthodes manquantes écrivent un avertissement dans la console, et [API()](#api) ajoute le schéma à l'URL. Ce mode ne peut plus être activé une fois qu'une clé a été définie par `DEF.secret()`.\n\nExample: Signaler une méthode manquante\n```js\nDEBUG();\nEXEC('missing.method');\nconsole.log('done'); // done\n```\n\n### DECRYPT(value, [key], [type])\n\nType: `method`\n\nDécode une valeur issue de [ENCRYPT()](#encrypt).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La valeur encodée. |\n| `key` | `String` | no |  | La clé. |\n| `type` | `String` | no |  | Le préfixe de la valeur. |\n\nReturns: `Object` La valeur, ou `undefined` quand la clé ou le préfixe ne correspond pas.\n\nLe JSON est reconverti en objet.\n\nExample: Utiliser une mauvaise clé\n```js\nvar token = ENCRYPT('Peter', 'secret');\nconsole.log(DECRYPT(token, 'secret')); // Peter\nconsole.log(DECRYPT(token, 'other') === undefined); // true\n```\n\n### DEF\n\nType: `property`\n\nLa configuration de la bibliothèque. Consulte [DEF](../def/).\n\nExample: Lire la valeur\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEFAULT(path, [delay], [reset])\n\nType: `method`\n\nRétablit les valeurs par défaut des composants d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous, ou `path__value`. |\n| `delay` | `Number` | no |  | Un délai en millisecondes. |\n| `reset` | `Boolean` | no | `true` | Avec `false`, l'état des composants est conservé. |\n\nUn composant tire sa valeur par défaut de son attribut `default`. Avec la forme `path__value`, c'est l'expression placée après les deux tirets bas qui est écrite dans le path comme valeur par défaut.\n\nExample: Écrire un objet par défaut\n```js\nDEFAULT('form.* __{ name: \"Peter\" }');\nsetTimeout(function() {\n\tconsole.log(GET('form')); // {\"name\":\"Peter\"}\n}, 100);\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 |  | Le parent. |\n| `selector` | `String` | yes |  | Un sélecteur des enfants. |\n| `html` | `String` | yes |  | Le nouveau HTML. |\n| `attribute` | `String` | no |  | L'attribut à comparer. |\n\nReturns: `Object` Les compteurs `add`, `upd` et `rem`.\n\nSeuls les enfants modifiés sont ajoutés ou supprimés. Les enfants sont comparés par leur HTML, ou par la valeur de l'attribut.\n\nExample: Mettre à jour une liste\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n<script>\nvar result = DIFFDOM($('#list'), 'li', '<li>B</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log($('#list').text()); // BC\n</script>\n```\n\n### DISABLED(path, [flags])\n\nType: `method`\n\nL'inverse de [CAN()](#can).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous. |\n| `flags` | `String|Array` | no |  | `visible` ou `hidden` limite la vérification à ces composants. |\n\nReturns: `Boolean` Le résultat.\n\nExample: Désactiver un bouton d'envoi\n```js\nON('ready', function() {\n\tconsole.log(DISABLED('form.*')); // true\n});\n```\n\n### EMIT(name, [...args])\n\nType: `method`\n\nAppelle les gestionnaires d'un événement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `...args` | `Object` | no |  | Les arguments passés aux gestionnaires. |\n\nReturns: `Boolean` `true` quand l'événement a au moins un gestionnaire.\n\nUn flag personnalisé peut suivre le nom, par exemple `EMIT('ping @saved')`.\n\nExample: Émettre un événement\n```js\nON('hello', name => console.log(name)); // Peter\nconsole.log(EMIT('hello', 'Peter')); // true\nconsole.log(EMIT('unknown')); // false\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nUn tableau vide figé.\n\nExample: Lire la valeur\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nUn objet vide figé.\n\nExample: Lire la valeur\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nEncode une valeur en une chaîne hexadécimale signée avec une clé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | La valeur. |\n| `key` | `String` | no |  | La clé. |\n| `type` | `String` | no |  | Un préfixe du résultat. |\n\nReturns: `String` La valeur encodée.\n\nLa valeur est encodée, sans chiffrement fort. Les objets sont convertis en JSON.\n\nExample: Encoder et décoder\n```js\nvar token = ENCRYPT({ id: 5 }, 'secret');\nconsole.log(DECRYPT(token, 'secret')); // {\"id\":5}\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLit ou écrit une variable d'environnement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Le nom, ou un objet contenant des valeurs. |\n| `value` | `Object` | no |  | La valeur. |\n\nReturns: `Object` La valeur de la variable.\n\nUn objet comme premier argument écrit plusieurs variables. Les paths et les URL lisent les variables avec `[name]`. Les variables sont stockées dans `DEF.environment`.\n\nExample: Utiliser une variable\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 le nom, la version et la langue de l'application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'application. |\n| `version` | `String` | no |  | La version. |\n| `language` | `String` | no |  | La langue du HTML importé. |\n| `env` | `Object` | no |  | Les variables d'environnement pour [ENV()](#env). |\n\nLe nom sépare le stockage de l'application dans le navigateur. La fonction définit `DEF.localstorage`, `DEF.version` et `DEF.languagehtml`.\n\nExample: Nommer l'application\n```js\nENVIRONMENT('shop', '1.2', 'en', { api: '/api/' });\nconsole.log(DEF.localstorage, DEF.version, ENV('api')); // shop 1.2 /api/\n```\n\n### ERROR(value, [success], [error])\n\nType: `method`\n\nIndique si une réponse contient une erreur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|Function` | yes |  | La réponse, ou le gestionnaire de succès. |\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|Function` `true` quand la valeur est une erreur, ou le callback créé.\n\nUne `Error`, un objet doté du champ `error` ou un tableau dont le premier élément possède ce champ comptent comme une erreur, et l'événement [ERROR](../events/#error-2) est émis. `success` et `error` sont des fonctions ou des paths.\n\nAvec une fonction comme premier argument, `ERROR(success, [error])` renvoie un callback pour une requête.\n\nExample: Vérifier une réponse\n```js\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\nconsole.log(ERROR({ id: 5 })); // false\n```\n\nExample: Créer un callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 5\n});\ncallback({ id: 5 });\n```\n\n### ERRORS(path, [flags], [highlight])\n\nType: `method`\n\nListe les composants touchés et invalides.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous. |\n| `flags` | `String|Array` | no |  | `visible` ou `hidden` limite la vérification à ces composants. |\n| `highlight` | `Boolean` | no |  | Actualise l'état des composants trouvés. |\n\nReturns: `Array` Les composants.\n\n`ERRORS(path, true)` actualise aussi l'état des composants trouvés.\n\nExample: Trouver les champs invalides\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(ERRORS('form.*').map(com => com.path)); // [\"form.name\"]\n});\n```\n\n### EVALUATE(path, expression, [nopath])\n\nType: `method`\n\nÉvalue une expression JavaScript avec la valeur d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Object` | yes |  | Le path, ou la valeur elle-même quand `nopath` vaut `true`. |\n| `expression` | `String` | yes |  | L'expression. |\n| `nopath` | `Boolean` | no |  | Traite le premier argument comme la valeur. |\n\nReturns: `Object` Le résultat de l'expression.\n\nL'expression peut utiliser les variables `value` et `path`.\n\nExample: Évaluer une expression\n```js\nSET('price', 10);\nconsole.log(EVALUATE('price', 'value * 2')); // 20\nconsole.log(EVALUATE(4, 'value + 1', true)); // 5\n```\n\n### EXE([wait], path, [...args])\n\nType: `method`\n\nLa même fonction que [EXEC()](#exec).\n\nExample: Même fonction\n```js\nconsole.log(EXE === EXEC); // true\n```\n\n### EXEC([wait], path, [...args])\n\nType: `method`\n\nAppelle une fonction, une méthode de plugin, une méthode de composant, une commande ou un événement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Avec `true`, attend la cible. |\n| `path` | `String` | yes |  | La cible. |\n| `...args` | `Object` | no |  | Les arguments. |\n\nLa forme du path détermine la cible :\n\n| Path | Cible |\n| --- | --- |\n| `plugin/method` | Une méthode d'un plugin |\n| `@plugin.method` | Une méthode d'un plugin |\n| `path.to.fn` | Une fonction située sur un path |\n| `#name` | L'événement `name` |\n| `-selector/method` | Une méthode d'un composant, comme avec [SETTER()](#setter) |\n| `&name` | Une commande, comme avec [CMD()](#cmd) |\n\nAvec `true` comme premier argument, l'appel attend que la cible existe. `EXE()` est la même fonction.\n\nExample: Appeler une méthode de plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.hello = function(name) {\n\t\tconsole.log(name); // Peter\n\t};\n});\nEXEC(true, 'users/hello', 'Peter');\n```\n\nExample: Appeler une fonction située sur un path\n```js\nwindow.app = { sum: (a, b) => console.log(a + b) };\nEXEC('app.sum', 1, 2);\nconsole.log(typeof(app.sum)); // function\n```\n\n### EXT(path, value, [delay], [reset])\n\nType: `method`\n\nFusionne les champs d'un objet dans l'objet situé sur un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Les champs à fusionner. |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n| `reset` | `Boolean` | no |  | Avec `true`, les composants du path sont aussi marqués comme non touchés et non modifiés. |\n\nChaque champ est écrit séparément : les autres champs sont donc conservés. `EXTEND()` est la même fonction. Comme avec [SET()](#set), le premier argument peut être une requête et `value` le path cible.\n\nExample: Fusionner des champs\n```js\nSET('user', { name: 'Peter' });\nEXT('user', { age: 30 });\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"age\":30}\n```\n\n### EXTEND(path, value, [delay], [reset])\n\nType: `method`\n\nLa même fonction que [EXT()](#ext).\n\nExample: Même fonction\n```js\nconsole.log(EXTEND === EXT); // true\n```\n\n### EXTENSION(name, [config], declaration)\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 `@plugin`. |\n| `config` | `Object|String` | no |  | Une configuration supplémentaire. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n\nLa déclaration s'exécute pour chaque instance du composant, y compris celles qui existent déjà. Avec un nom qui commence par `@`, elle étend le plugin de ce nom.\n\nExample: Ajouter une méthode à un composant\n```js\nEXTENSION('box', function(self) {\n\tself.bye = () => 'Bye';\n});\nON('ready', function() {\n\tconsole.log(FIND('box').bye()); // Bye\n});\n```\n\n### FIND(selector, [many], [nocache], [callback])\n\nType: `method`\n\nTrouve un composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Element` | yes |  | Ce qu'il faut trouver. |\n| `many` | `Boolean` | no |  | Avec `true`, renvoie toutes les correspondances dans un tableau. |\n| `nocache` | `Boolean` | no |  | Ignore le cache des composants trouvés. |\n| `callback` | `Function` | no |  | Attend le composant et le reçoit. |\n\nReturns: `Component|Array` Le composant trouvé, ou un tableau avec `many`. Rien n'est renvoyé quand un callback est utilisé.\n\nLe sélecteur est un nom de composant, `.path`, `#id`, `name[path]` ou `name@version`, et tu peux combiner des parties avec une espace. Un élément DOM ou un objet jQuery trouve les composants qu'il contient.\n\nAvec un callback, la recherche attend que le composant existe. Le callback peut être le deuxième ou le troisième argument.\n\nExample: Trouver par nom et par path\n```js\nON('ready', function() {\n\tconsole.log(FIND('box').path); // data.box\n\tconsole.log(FIND('.data.box').name); // box\n\tconsole.log(FIND('box', true).length); // 1\n});\n```\n\nExample: Attendre un composant\n```js\nFIND('box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### FN(expression)\n\nType: `method`\n\nCrée une fonction à partir d'une chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expression` | `String` | yes |  | L'expression. |\n\nReturns: `Function` La fonction.\n\nLa chaîne est une fonction fléchée. Une chaîne qui utilise uniquement le mot `value` devient une fonction ayant l'argument `value`.\n\nExample: Créer des fonctions\n```js\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value > 5')(10)); // true\n```\n\n### FORMATTER(fn, [prepend])\n\nType: `method`\n\nEnregistre un formatter global des valeurs de composants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Avec `true`, le formatter s'exécute en premier. |\n\nReturns: `Object` La valeur formatée, quand la fonction exécute les formatters.\n\nLa fonction renvoie la nouvelle valeur, et `undefined` conserve la valeur actuelle. `FORMATTER(value, path, type, [format])` exécute tous les formatters enregistrés.\n\nExample: Formater une valeur\n```js\nFORMATTER(function(path, value, type) {\n\tif (type === 'upper')\n\t\treturn value.toUpperCase();\n});\nconsole.log(FORMATTER('peter', 'user.name', 'upper')); // PETER\n```\n\n### FREE([delay])\n\nType: `method`\n\nSupprime les composants, les liaisons et les observateurs inutilisés.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `10` | Le délai en millisecondes. |\n\nLa bibliothèque le fait aussi toutes les trois minutes.\n\nExample: Nettoyer\n```js\nFREE();\nconsole.log(typeof(FREE)); // function\n```\n\n### FUNC\n\nType: `property`\n\nUn objet vide pour tes propres fonctions partagées.\n\nExample: Lire la valeur\n```js\nFUNC.sum = (a, b) => a + b;\nconsole.log(FUNC.sum(1, 2)); // 3\n```\n\n### GET(path, [scope])\n\nType: `method`\n\nLit la valeur d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `scope` | `Object|Function|Boolean` | no |  | Un objet lit le path relativement à cet objet. Une fonction attend que la valeur ne soit plus `null`, puis la reçoit. `true` réinitialise l'état des composants du path. |\n\nReturns: `Object` La valeur, ou `undefined` quand le path n'a pas de valeur. Avec une fonction comme deuxième argument, rien n'est renvoyé.\n\nDes flags peuvent suivre le path. `@clone` renvoie une copie, `@reset` réinitialise l'état des composants après la lecture, et `@modified` ne renvoie que les valeurs des composants modifiés.\n\nExample: Lire une valeur\n```js\nSET('user', { name: 'Peter', age: 30 });\nconsole.log(GET('user.age')); // 30\nconsole.log(GET('name', { name: 'Anna' })); // Anna\n```\n\nExample: Attendre une valeur\n```js\nGET('settings.theme', function(value) {\n\tconsole.log(value); // dark\n});\nsetTimeout(() => SET('settings.theme', 'dark'), 100);\n```\n\n### GUID([size])\n\nType: `method`\n\nCrée un identifiant aléatoire.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `size` | `Number` | no |  | La longueur. Sans elle, l'identifiant compte 36 caractères au format UUID. |\n\nReturns: `String` L'identifiant.\n\nExample: Créer des identifiants\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value, [unsigned])\n\nType: `method`\n\nCrée un nombre à partir d'une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur. |\n| `unsigned` | `Boolean` | no | `true` | Avec `false`, le résultat peut être négatif. |\n\nReturns: `Number` Le hachage.\n\nLes objets sont hachés d'après leur forme JSON. Un nombre est renvoyé tel quel, un booléen devient `0` ou `1`, et une date devient son horodatage.\n\nExample: Hacher une chaîne\n```js\nconsole.log(HASH('abc')); // 96354\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nIndique si un élément n'est pas affiché.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'élément. |\n\nReturns: `Boolean` Le résultat. Un élément absent renvoie `true`.\n\nExample: Vérifier un élément\n```html\n<div id=\"a\" style=\"display:none\"><span></span></div>\n<script>\nconsole.log(HIDDEN($('#a')[0].firstChild)); // true\nconsole.log(HIDDEN(null)); // true\n</script>\n```\n\n### IMPORT(url, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nCharge un script, un style ou du HTML dans la page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String|Array` | yes |  | L'URL. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | L'endroit où placer le HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Avec `false`, remplace le contenu de la cible. |\n| `preparator` | `Function` | no |  | `function(response, output)` modifie le HTML avant son insertion. |\n\nLe sujet est expliqué dans [Importer du contenu](../../guides/importing/). Un tableau d'URL est chargé une URL après l'autre. Une URL qui commence par `once ` ou `!` n'est chargée qu'une seule fois, et `<path>` devant l'URL ignore l'import quand le path a une valeur. Le callback reçoit `1` après le chargement et `0` quand rien n'a été chargé.\n\nExample: Importer du HTML\n```html\n<div id=\"target\"></div>\n<script>\nIMPORT('/parts/hello.html', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nFonctionne comme [IMPORT()](#import) et met en cache le HTML importé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `expire` | `String` | yes |  | Par exemple `5 minutes` ou `session`. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | L'endroit où placer le HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Avec `false`, remplace le contenu de la cible. |\n| `preparator` | `Function` | no |  | `function(response, output)` modifie le HTML avant son insertion. |\n\nExample: Importer et mettre en cache\n```html\n<div id=\"target\"></div>\n<script>\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### INC(path, [value], [delay], [reset])\n\nType: `method`\n\nAjoute un nombre à la valeur située sur un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Number` | no | `1` | Le nombre à ajouter. |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n| `reset` | `Boolean` | no |  | Avec `true`, les composants du path sont aussi marqués comme non touchés et non modifiés. |\n\nUne valeur absente ou qui n'est pas un nombre compte pour `0`.\n\nExample: Augmenter un compteur\n```js\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 6\n```\n\n### inDOM(element)\n\nType: `method`\n\nIndique si un élément se trouve dans le body de la page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | L'élément. |\n\nReturns: `Boolean` `true`, ou `undefined` quand l'élément se trouve hors du body.\n\nExample: Vérifier un élément\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(inDOM(document.createElement('div')) === undefined); // true\n```\n\n### isIE\n\nType: `property`\n\n`true` dans Internet Explorer.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(isIE)); // boolean\n```\n\n### isMOBILE\n\nType: `property`\n\n`true` sur un appareil mobile.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(isMOBILE)); // boolean\n```\n\n### isPRIVATEMODE\n\nType: `property`\n\n`true` quand le stockage du navigateur n'est pas disponible.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(isPRIVATEMODE)); // boolean\n```\n\n### isROBOT\n\nType: `property`\n\n`true` quand le user agent ressemble à celui d'un robot.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(isROBOT)); // boolean\n```\n\n### isSTANDALONE\n\nType: `property`\n\n`true` quand la page s'exécute en tant qu'application installée.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(isSTANDALONE)); // boolean\n```\n\n### isTOUCH\n\nType: `property`\n\n`true` sur un appareil à écran tactile.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(isTOUCH)); // boolean\n```\n\n### jComponent\n\nType: `property`\n\nUn autre nom de `MAIN`. Consulte [MAIN](../main/).\n\nExample: Lire la valeur\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### LOCALIZE(text)\n\nType: `method`\n\nAjoute des traductions au dictionnaire.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Les traductions. |\n\nChaque ligne a la forme `key : value`, et une ligne qui commence par `//` est ignorée. Les valeurs sont stockées dans `DEF.dictionary`. Le sujet est expliqué dans [Localisation](../../guides/localization/).\n\nExample: Ajouter des traductions\n```js\nLOCALIZE('// Greetings\\nhello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### M\n\nType: `property`\n\nUn nom court de `MAIN`. Consulte [M](../m/).\n\nExample: Lire la valeur\n```js\nconsole.log(M === MAIN); // true\n```\n\n### MACRO(name, declaration)\n\nType: `method`\n\nDéclare une macro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la macro. |\n| `declaration` | `Function` | yes |  | `function(self, element, cls)`. |\n\nLe sujet est expliqué dans [Macros](../../guides/macros/), et l'objet est décrit dans [Macro](../macro/).\n\nExample: Déclarer une macro\n```js\nMACRO('upper', function(self, element) {\n\tself.setter = value => element.text((value || '').toUpperCase());\n});\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### MAIN\n\nType: `property`\n\nL'objet principal de la bibliothèque. Consulte [MAIN](../main/).\n\nExample: Lire la valeur\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### MAKE([target], fn, [update])\n\nType: `method`\n\nConstruit un objet dans une fonction.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Object|String` | no |  | Un objet ou un path. Sans cela, un nouvel objet est créé. |\n| `fn` | `Function` | yes |  | `function(obj, path, set)`. |\n| `update` | `Boolean` | no | `true` | Avec `false`, un objet existant sur le path est réécrit sans réinitialiser ses composants. |\n\nReturns: `Object` L'objet.\n\nUne cible sous forme de chaîne est un path : l'objet situé sur le path est modifié, ou un nouvel objet est créé et écrit à cet endroit. La fonction reçoit l'objet, le path et une fonction `set(path, value)`.\n\nExample: Construire un objet\n```js\nvar obj = MAKE(function(o) {\n\to.name = 'Peter';\n});\nconsole.log(obj); // {\"name\":\"Peter\"}\n```\n\nExample: Construire un objet sur un path\n```js\nMAKE('user', function(o, path, set) {\n\to.name = 'Peter';\n\tset('address.city', 'Bratislava');\n});\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"address\":{\"city\":\"Bratislava\"}}\n```\n\n### MIDDLEWARE(name, fn)\n\nType: `method`\n\nDéclare un middleware de routes. Consulte [Routage](../../guides/routing/).\n\n### MODIFIED(path, [flags])\n\nType: `method`\n\nListe les paths des composants touchés et modifiés.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous. |\n| `flags` | `String|Array` | no |  | `visible` ou `hidden` limite la recherche à ces composants. |\n\nReturns: `Array` Les paths des composants modifiés.\n\nExample: Lister les champs modifiés\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n});\n```\n\n### MONTHS\n\nType: `property`\n\nLes noms des mois.\n\nExample: Lire la valeur\n```js\nconsole.log(MONTHS[11]); // December\n```\n\n### NAV\n\nType: `property`\n\nL'objet routeur. Consulte [Routage](../../guides/routing/).\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` | `Element|jQuery` | yes |  | L'élément. |\n\nReturns: `Number` L'index.\n\nExample: Lire la position\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, target, [before])\n\nType: `method`\n\nPlace un élément après ou avant un autre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'élément à déplacer. |\n| `target` | `Element|jQuery` | yes |  | L'élément de référence. |\n| `before` | `Boolean` | no |  | Avec `true`, le place avant la cible. |\n\nExample: Déplacer un élément\n```html\n<ul><li id=\"a\">A</li><li>B</li><li id=\"c\">C</li></ul>\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` | `Element|jQuery` | yes |  | L'élément. |\n| `up` | `Boolean` | no |  | Avec `true`, le déplace vers le haut. Sinon, il descend. |\n\nExample: Déplacer un élément vers le haut\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BA\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nUne fonction qui ne fait rien.\n\nExample: L'utiliser comme callback vide\n```js\nconsole.log(NOOP() === undefined); // true\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nIndique si la page est en arrière-plan.\n\nReturns: `Boolean` Le résultat.\n\nExample: Vérifier la page\n```js\nconsole.log(typeof(NOTFOCUSED())); // boolean\n```\n\n### NOTIFY(...paths)\n\nType: `method`\n\nActualise les composants et les observateurs de paths exacts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...paths` | `String` | yes |  | Un ou plusieurs paths. |\n\nSeuls les composants dont le path est exactement le même sont actualisés.\n\nExample: Notifier un observateur\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nwindow.user = { name: 'Peter' };\nNOTIFY('user.name');\n```\n\n### NOTMODIFIED(path, [value], [fields])\n\nType: `method`\n\nIndique si une valeur est identique à celle de la dernière vérification.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, ou n'importe quelle clé quand `value` est fourni. |\n| `value` | `Object` | no |  | La valeur à comparer. Sans elle, la valeur du path est utilisée. |\n| `fields` | `Array` | no |  | Compare uniquement ces champs. |\n\nReturns: `Boolean` `true` quand la valeur n'a pas changé.\n\nLa première vérification d'un path renvoie `false`. La valeur est comparée à l'aide d'un hachage de sa forme JSON.\n\nExample: Éviter le travail quand rien n'a changé\n```js\nconsole.log(NOTMODIFIED('list', [1, 2])); // false\nconsole.log(NOTMODIFIED('list', [1, 2])); // true\nconsole.log(NOTMODIFIED('list', [1, 2, 3])); // false\n```\n\n### NOW\n\nType: `property`\n\nLa date actuelle, actualisée chaque minute.\n\nExample: Lire la valeur\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path, [delay])\n\nType: `method`\n\nÉcrit `null` dans un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n\n`NULL()` est la même fonction.\n\nExample: Effacer une valeur\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### NULL(path, [delay])\n\nType: `method`\n\nLa même fonction que [NUL()](#nul).\n\nExample: Même fonction\n```js\nconsole.log(NULL === NUL); // true\n```\n\n### OFF(name, [path], [fn])\n\nType: `method`\n\nSupprime les gestionnaires d'un événement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `path` | `String|Function` | no |  | Le path, ou le gestionnaire quand aucun path n'est nécessaire. |\n| `fn` | `Function` | no |  | Le gestionnaire. |\n\nTu peux séparer plusieurs événements par `+`. La forme `owner#name` supprime les gestionnaires de ce propriétaire, et `owner#` les supprime tous.\n\nExample: Supprimer un gestionnaire\n```js\nvar fn = () => console.log('never');\nON('ping', fn);\nOFF('ping', fn);\nconsole.log(EMIT('ping')); // false\n```\n\nExample: Supprimer les gestionnaires d'un propriétaire\n```js\nON('shop#ping', () => console.log('never'));\nOFF('shop#');\nconsole.log(EMIT('ping')); // false\n```\n\n### ON(name, [path], fn, [init])\n\nType: `method`\n\nEnregistre un gestionnaire d'événement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `path` | `String` | no |  | Le path, pour l'événement `watch`. |\n| `fn` | `Function` | yes |  | Le gestionnaire. |\n| `init` | `Boolean` | no |  | Avec l'événement `watch`, le gestionnaire est aussi appelé immédiatement. |\n\nLe nom peut lister plusieurs événements séparés par une espace ou par ` + `. Un nom qui commence par `^` place le gestionnaire en premier. La forme `owner#name` attribue le gestionnaire à un propriétaire, afin que [OFF()](#off) puisse le supprimer plus tard. Le nom `@flag myflag` réagit à un flag personnalisé sur un path.\n\nL'événement `watch` fonctionne comme [WATCH()](#watch) et utilise `path` et `init`. Les événements de la bibliothèque sont listés dans [Événements](../events/).\n\nExample: Écouter un événement personnalisé\n```js\nON('cart.add', function(id, count) {\n\tconsole.log(id, count); // 15 2\n});\nEMIT('cart.add', 15, 2);\n```\n\nExample: Réagir à un flag personnalisé\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.name Peter\n});\nSET('user.name @saved', 'Peter');\n```\n\n### OPT([obj], fn)\n\nType: `method`\n\nConstruit un objet d'options avec des paths imbriqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | no |  | L'objet à remplir. Sans lui, un nouvel objet est créé. |\n| `fn` | `Function` | yes |  | `function(set, scope)`. |\n\nReturns: `Object` L'objet.\n\nLa fonction reçoit `set(path, value)` et `scope(prefix)`, qui ajoute un préfixe aux paths suivants.\n\nExample: Construire des options\n```js\nvar options = OPT(function(set, scope) {\n\tset('title', 'Users');\n\tscope('grid');\n\tset('limit', 20);\n});\nconsole.log(options); // {\"title\":\"Users\",\"grid\":{\"limit\":20}}\n```\n\n### PARSE(value, [date])\n\nType: `method`\n\nAnalyse du JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Le JSON ou un sélecteur. |\n| `date` | `Boolean` | no | `DEF.jsondate` | Convertit les dates ISO en objets `Date`. |\n\nReturns: `Object` La valeur.\n\nUne chaîne qui commence par `#` ou `.` est un sélecteur d'un élément contenant du JSON. Un JSON invalide renvoie `null`, et un objet est renvoyé tel quel.\n\nExample: Analyser du JSON\n```js\nconsole.log(PARSE('{\"id\":5}').id); // 5\nconsole.log(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d instanceof Date); // true\nconsole.log(PARSE('wrong')); // null\n```\n\n### PARSER(fn, [prepend])\n\nType: `method`\n\nEnregistre un parser global des valeurs de composants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Avec `true`, le parser s'exécute en premier. |\n\nReturns: `Object` La valeur analysée, quand la fonction exécute les parsers.\n\nLa fonction doit toujours renvoyer la valeur. Le parser intégré convertit les types `number`, `currency`, `float`, `boolean`, `bool`, `date` et `datetime`. `PARSER(value, path, type, [format])` exécute tous les parsers enregistrés.\n\nExample: Analyser une valeur\n```js\nconsole.log(PARSER('1 200.5', 'price', 'number')); // 1200.5\nconsole.log(PARSER('on', 'active', 'boolean')); // true\n```\n\n### PLUGIN(name, [fn], [init], [done])\n\nType: `method`\n\nDéclare un plugin, ou renvoie un plugin existant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du plugin. |\n| `fn` | `Function` | no |  | `function(exports)`. |\n| `init` | `Function|String` | no |  | S'exécute avant la déclaration. Une chaîne liste des noms de middlewares. |\n| `done` | `Function` | no |  | Appelé quand le plugin est prêt. |\n\nReturns: `Plugin` Le plugin.\n\nLe sujet est expliqué dans [Plugins](../../guides/plugins/), et l'objet est décrit dans [Plugin](../plugin/).\n\nExample: Déclarer un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.count = 5;\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.users.count); // 5\n}, 500);\n```\n\n### PLUGINABLE(name, fn, [init])\n\nType: `method`\n\nEnregistre un plugin créé lors de son premier appel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du plugin. |\n| `fn` | `Function|String` | yes |  | La déclaration ou une URL. |\n| `init` | `Function|String` | no |  | S'exécute avant la déclaration. |\n\nLa déclaration peut aussi être l'URL d'un fichier qui déclare le plugin.\n\nExample: Créer un plugin à la demande\n```js\nPLUGINABLE('reports', function(exports) {\n\texports.open = function() {\n\t\tconsole.log('opened'); // opened\n\t};\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.reports == null); // true\n\tEXEC('reports/open');\n}, 500);\n```\n\n### PLUGINS\n\nType: `property`\n\nUn objet contenant tous les plugins créés, classés par nom.\n\nExample: Lire un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.limit = 10;\n});\nsetTimeout(function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n}, 500);\n```\n\n### PREF\n\nType: `property`\n\nLes préférences utilisateur stockées. Consulte [PREF](../pref/).\n\nExample: Lire la valeur\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.theme); // dark\n```\n\n### PUSH(path, value, [delay], [reset])\n\nType: `method`\n\nAjoute une valeur au tableau situé sur un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Object|Array` | yes |  | L'élément ou les éléments à ajouter. |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n| `reset` | `Boolean` | no |  | Avec `true`, les composants du path sont aussi marqués comme non touchés et non modifiés. |\n\nUn tableau passé comme valeur ajoute chacun de ses éléments. Si le path ne contient pas de tableau, un nouveau tableau est créé. Un path qui commence par `^` ajoute au début. Comme avec [SET()](#set), le premier argument peut être une requête et `value` le path cible.\n\nExample: Ajouter des éléments\n```js\nPUSH('tags', 'a');\nPUSH('tags', ['b', 'c']);\nPUSH('^tags', 'first');\nconsole.log(GET('tags')); // [\"first\",\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], obj)\n\nType: `method`\n\nAjoute un objet à une URL sous forme de chaîne de requête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'URL, éventuellement avec une méthode. |\n| `obj` | `Object` | yes |  | Les valeurs. |\n\nReturns: `String` L'URL.\n\nLes valeurs vides sont ignorées, les tableaux sont joints par une virgule et les dates utilisent le format ISO.\n\nExample: Construire une URL\n```js\nconsole.log(QUERIFY('GET /users/', { page: 2, tags: ['a', 'b'] })); // GET /users/?page=2&tags=a%2Cb\nconsole.log(QUERIFY({ q: 'x y' })); // ?q=x%20y\n```\n\n### QUEUE([name], fn)\n\nType: `method`\n\nExécute des fonctions les unes après les autres.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Le nom de la file d'attente. |\n| `fn` | `Function` | yes |  | `function(next, pending)`. |\n\nReturns: `Number` Le nombre d'éléments en attente.\n\nLa fonction reçoit `next` et le nombre d'éléments en attente. L'élément suivant démarre après l'appel de `next()`.\n\nExample: Exécuter dans l'ordre\n```js\nQUEUE('tasks', function(next) {\n\tsetTimeout(next, 50);\n});\nQUEUE('tasks', function(next, pending) {\n\tconsole.log('second', pending); // second 0\n\tnext();\n});\n```\n\n### RECONFIGURE(selector, value)\n\nType: `method`\n\nModifie la configuration de tous les composants correspondants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un sélecteur comme dans [FIND()](#find). |\n| `value` | `Object|String` | yes |  | La nouvelle configuration. |\n\nExample: Modifier la configuration\n```js\nON('ready', function() {\n\tRECONFIGURE('box', { size: 10 });\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### REDIRECT(url)\n\nType: `method`\n\nNavigue vers une URL. Consulte [Routage](../../guides/routing/).\n\n### REMOVECACHE(key)\n\nType: `method`\n\nSupprime une valeur du cache du navigateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé. |\n\nExample: Supprimer une valeur\n```js\nCACHE('profile', 'Peter', '1 day');\nREMOVECACHE('profile');\nconsole.log(CACHE('profile') === undefined); // true\n```\n\n### REPEAT([condition], process, delay, [init])\n\nType: `method`\n\nExécute une fonction de manière répétée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | no |  | La condition. |\n| `process` | `Function` | yes |  | `function(counter, scope)`. |\n| `delay` | `Number` | yes |  | Le délai en millisecondes. |\n| `init` | `Boolean` | no |  | Avec `true`, la première exécution démarre immédiatement. |\n\nLa condition est une fonction ou un path, et l'exécution est ignorée tant qu'elle n'est pas remplie. Avec la forme `path__expression`, l'expression reçoit la variable `value`. Tant que la page est en arrière-plan, rien ne s'exécute, sauf si `DEF.repeatfocus` vaut `false`.\n\nExample: Exécuter toutes les 100 ms\n```js\nREPEAT(function(counter) {\n\tif (counter === 3)\n\t\tconsole.log('third run'); // third run\n}, 100);\n```\n\n### REPO\n\nType: `property`\n\nUn objet vide pour tes propres données partagées.\n\nExample: Lire la valeur\n```js\nREPO.items = [1, 2];\nconsole.log(REPO.items.length); // 2\n```\n\n### RESET(path, [delay])\n\nType: `method`\n\nMarque les composants d'un path comme non touchés et non modifiés, puis les valide de nouveau.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous. |\n| `delay` | `Number` | no |  | Un délai en millisecondes. |\n\nExample: Réinitialiser un formulaire\n```js\nON('ready', function() {\n\tSET('form.name', 'Peter');\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n\tRESET('form.*');\n\tconsole.log(MODIFIED('form.*').length); // 0\n});\n```\n\n### RETURN(command, [multiple])\n\nType: `method`\n\nLit une propriété d'un composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `command` | `String` | yes |  | Le sélecteur et la propriété. |\n| `multiple` | `Boolean` | no |  | Avec `true`, lit la propriété de tous les composants correspondants. |\n\nReturns: `Object|Array` La valeur, ou un tableau avec `multiple`.\n\nLa commande a la forme `selector/property`.\n\nExample: Lire une propriété\n```js\nON('ready', function() {\n\tconsole.log(RETURN('box/title')); // Box\n\tconsole.log(RETURN('box/title', true)); // [\"Box\"]\n});\n```\n\n### REWRITE(path, value, [type])\n\nType: `method`\n\nÉcrit une valeur sans actualiser les composants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `type` | `Number` | no |  | Le type de changement passé aux observateurs. |\n\nLes liaisons de données et les observateurs s'exécutent quand même. Utilise le flag `@nowatch` pour ignorer les observateurs.\n\nExample: Écrire sans actualiser les composants\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nREWRITE('user.name', 'Peter');\n```\n\n### REWRITE2(path, value, [type])\n\nType: `method`\n\nÉcrit une valeur sans actualiser les composants ni les liaisons de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `type` | `Number` | no |  | Le type de changement passé aux observateurs. |\n\nLes observateurs s'exécutent quand même.\n\nExample: Écrire sans liaisons\n```js\nREWRITE2('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\n```\n\n### ROUTE(url, fn, [middleware], [init])\n\nType: `method`\n\nDéclare une route. Consulte [Routage](../../guides/routing/).\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\nLes options :\n\n| Option | Type | Description |\n| --- | --- | --- |\n| `orientation` | String | `x` ou `y`. Sans cette option, les deux directions |\n| `visibleX`, `visibleY` | Boolean | Garde la barre de défilement visible |\n| `native` | Boolean | Utilise la barre de défilement du navigateur |\n| `wrap` | Boolean | Avec `false`, le contenu n'est pas enveloppé |\n| `controls` | jQuery | L'élément des contrôles de la barre de défilement |\n| `shadow` | Boolean | Ajoute des ombres sur les bords |\n| `padding` | Number | La marge intérieure des barres. Valeur par défaut : `5` |\n| `minsize` | Number | La taille minimale d'une barre. Valeur par défaut : `50` |\n| `thickness` | Number | L'épaisseur d'une barre. Valeur par défaut : `10` |\n| `margin`, `marginX`, `marginY` | Number | Les marges |\n| `offsetX`, `offsetY` | Number | Ajoutés à la taille de la vue |\n| `parent` | String ou Element | Reprend la taille de ce parent |\n| `autoresize` | Boolean | Avec `false`, la taille n'est pas vérifiée au redimensionnement |\n| `interval` | Number | L'intervalle de vérification de la taille |\n| `onscroll`, `onidle`, `onresize` | Function | Des gestionnaires qui reçoivent la barre de défilement |\n\nL'objet renvoyé possède les méthodes `scrollTop([value])`, `scrollLeft([value])`, `scrollBottom([value])`, `scrollRight([value])`, `scroll(x, y)`, `resize()`, `check()`, `sync(element, [offset])`, `unsync()` et `destroy()`.\n\nExample: Créer une barre de défilement\n```html\n<div id=\"box\" style=\"height:100px\"><div style=\"height:500px\"></div></div>\n<script>\nvar scrollbar = SCROLLBAR($('#box'), { orientation: 'y' });\nconsole.log(typeof(scrollbar.scrollTop)); // function\nconsole.log(M.scrollbars.length); // 1\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nRenvoie la largeur de la barre de défilement du navigateur en pixels.\n\nReturns: `Number` La largeur.\n\nExample: Lire la largeur\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(target, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction ou écrit une valeur, selon la cible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Function|String` | yes |  | Une fonction, une méthode ou un 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\nUne fonction est appelée. Une chaîne contenant `/`, ou un path qui contient une fonction, est transmis à [EXEC()](#exec). Toute autre chaîne est un path, dans lequel le premier argument est écrit.\n\nExample: Fonction ou path\n```js\nSEEX(value => console.log(value), 1); // 1\nSEEX('result.value', 2);\nconsole.log(GET('result.value')); // 2\n```\n\n### SET(path, value, [delay], [reset])\n\nType: `method`\n\nÉcrit une valeur dans un path et actualise tout ce qui y est lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n| `reset` | `Boolean` | no |  | Avec `true`, les composants du path sont aussi marqués comme non touchés et non modifiés. |\n\nLes composants, les liaisons et les observateurs du path sont actualisés. Le troisième argument peut aussi être `true`, ce qui réinitialise aussitôt l'état des composants.\n\nUn path qui commence par `+` ajoute la valeur à un tableau comme [PUSH()](#push). Un path qui commence par `~` la fusionne comme [EXT()](#ext). Des flags peuvent suivre le path : consulte [Flags et modificateurs de path](../../guides/flags/).\n\nQuand le premier argument est une requête comme `GET /api/users/`, la réponse est écrite dans le path indiqué par `value`.\n\nExample: Écrire une valeur\n```js\nSET('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\nExample: Retarder l'écriture\n```js\nSET('search', 'first', 100);\nSET('search', 'second', 100);\nsetTimeout(function() {\n\tconsole.log(GET('search')); // second\n}, 300);\n```\n\nExample: Stocker une réponse\n```js\nSET('GET /api/users/', 'users.response');\nsetTimeout(function() {\n\tconsole.log(GET('users.response.url')); // /api/users/\n}, 200);\n```\n\n### SETTER(selector, method, [...args])\n\nType: `method`\n\nAppelle une méthode de tous les composants correspondants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un sélecteur comme dans [FIND()](#find). |\n| `method` | `String` | yes |  | Le nom de la méthode. |\n| `...args` | `Object` | no |  | Les arguments de la méthode. |\n\nLe sélecteur et la méthode peuvent être réunis sous la forme `selector/method`. Avec `true` comme premier argument, l'appel attend le composant. Un sélecteur qui commence par `!` ne démarre pas un composant différé.\n\nExample: Appeler une méthode\n```js\n// The component logs 'Hello ' + name\nON('ready', function() {\n\tSETTER('box', 'hello', 'Peter');\n\tSETTER('box/hello', 'Anna');\n});\n```\n\n### setTimeout2(name, fn, delay, [limit], [arg])\n\nType: `method`\n\nDémarre un minuteur nommé et annule le minuteur précédent du même nom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du minuteur. |\n| `fn` | `Function` | yes |  | La fonction. |\n| `delay` | `Number` | yes |  | Le délai en millisecondes. |\n| `limit` | `Number` | no |  | Le nombre de reports autorisés pour le minuteur. |\n| `arg` | `Object` | no |  | L'argument de la fonction. |\n\nReturns: `String` Le nom du minuteur.\n\nAvec une limite, le minuteur est reporté au plus ce nombre de fois : la fonction s'exécute donc même en cas d'appels constants.\n\nExample: Ne garder que le dernier appel\n```js\nfunction search(value) {\n\tconsole.log(value); // last\n}\nsetTimeout2('search', search, 50, null, 'first');\nsetTimeout2('search', search, 50, null, 'last');\n```\n\n### STOPDEBUG()\n\nType: `method`\n\nMet sans cesse en pause le débogueur du navigateur tant que les outils de développement sont ouverts.\n\nLa fonction se répète toutes les 5 secondes et ne peut pas être arrêtée.\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 | `DEF.jsoncompress` | Compresse la sortie. |\n| `fields` | `Array|Object|Function` | no |  | Un tableau de champs autorisés, un objet avec `field: false`, ou `function(key, value)`. |\n| `encrypt` | `Boolean` | no |  | Chiffre la sortie avec la clé de `DEF.secret()`. |\n\nReturns: `String` Le JSON.\n\nLa compression supprime les espaces en début et en fin de chaîne, ainsi que les chaînes vides, `false` et `null`.\n\nExample: Sérialiser une valeur\n```js\nconsole.log(STRINGIFY({ a: 1, b: '', c: false }, true)); // {\"a\":1}\nconsole.log(STRINGIFY({ a: 1, b: 2 }, false, ['b'])); // {\"b\":2}\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 du style. L'élément reçoit l'id `css` suivi de cette valeur. |\n| `selector` | `String` | no |  | Un sélecteur qui englobe les règles. |\n\nUn style existant ayant le même identifiant est remplacé. Un sélecteur est ajouté devant chaque règle. `CSS()` est la même fonction.\n\nExample: Ajouter du CSS limité à un sélecteur\n```js\nSTYLE('b { color: red }', 'mystyle', '#panel');\nconsole.log($('#cssmystyle').html()); // #panel b{ color: red }\n```\n\n### Ta\n\nType: `property`\n\nUn nom court de `Tangular`.\n\nExample: Lire la valeur\n```js\nconsole.log(Ta === Tangular); // true\n```\n\n### Tangular\n\nType: `property`\n\nLe moteur de modèles. Consulte [Modèles avec Tangular](../../guides/tangular/).\n\nExample: Lire la valeur\n```js\nconsole.log(Tangular.render('Hello {{ name }}', { name: 'Peter' })); // Hello Peter\n```\n\n### TAPI(name, [data], [callback])\n\nType: `method`\n\nAppelle une API avec [DAPI()](#dapi) quand `DEF.api` est défini, et avec [WAPI()](#wapi) dans le cas contraire.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du schéma. |\n| `data` | `Object` | no |  | Les données. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, ou un path. |\n\nReturns: `Object|Promise` Le résultat de la fonction sélectionnée.\n\nExample: Sélectionner le transport\n```js\nDEF.api = '/api/';\nTAPI('users_list', null, function(response) {\n\tconsole.log(response.url); // /api/\n});\n```\n\n### TEMP\n\nType: `property`\n\nUn objet pour les données temporaires.\n\nLa bibliothèque le remplace par un objet vide toutes les cinq minutes.\n\nExample: Lire la valeur\n```js\nTEMP.value = 5;\nconsole.log(TEMP.value); // 5\n```\n\n### Thelpers\n\nType: `property`\n\nLes helpers du moteur de modèles. Consulte [Helpers Tangular](../tangular-helpers/).\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(Thelpers)); // object\n```\n\n### TOGGLE(path, [delay], [reset])\n\nType: `method`\n\nÉcrit la valeur booléenne opposée dans un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n| `reset` | `Boolean` | no |  | Avec `true`, les composants du path sont aussi marqués comme non touchés et non modifiés. |\n\nExample: Inverser une valeur\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### TRANSLATE(text)\n\nType: `method`\n\nRemplace chaque `@(text)` par sa traduction.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Le texte. |\n\nReturns: `String` Le texte traduit.\n\nLa clé dans `DEF.dictionary` est `HASH(text).toString(36)`, éventuellement avec le préfixe `T`. Un texte sans traduction reste dans la langue d'origine.\n\nExample: Traduire un texte\n```js\nDEF.dictionary[HASH('Hello').toString(36)] = 'Ahoj';\nconsole.log(TRANSLATE('@(Hello), @(Peter)')); // Ahoj, Peter\n```\n\n### UNAUTHORIZED(...roles)\n\nType: `method`\n\nIndique si l'utilisateur actuel ne possède aucun des rôles indiqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...roles` | `String` | yes |  | Les rôles. |\n\nReturns: `Boolean` `true` quand l'utilisateur ne possède aucun de ces rôles.\n\nL'utilisateur est lu dans `window.user`. Les champs `sa` et `su` autorisent tout, et les rôles proviennent de `permissions` ou de `roles`, sous forme de tableau ou d'objet.\n\nExample: Vérifier un rôle\n```js\nwindow.user = { roles: ['editor'] };\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [fn])\n\nType: `method`\n\nSupprime un observateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path observé. |\n| `fn` | `Function` | no |  | La fonction passée à [WATCH()](#watch). |\n\nSans fonction, tous les observateurs du path sont supprimés.\n\nExample: Arrêter l'observation\n```js\nvar count = 0;\nvar fn = () => count++;\nWATCH('value', fn);\nSET('value', 1);\nUNWATCH('value', fn);\nSET('value', 2);\nconsole.log(count); // 1\n```\n\n### UPD(path, [delay], [reset])\n\nType: `method`\n\nIndique à la bibliothèque que la valeur d'un path a changé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la valeur. Consulte [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un nombre supérieur ou égal à 10 retarde le changement d'autant de millisecondes. Un nombre inférieur indique le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n| `reset` | `Boolean` | no |  | Avec `true`, les composants du path sont aussi marqués comme non touchés et non modifiés. |\n\nUtilise-la après avoir modifié directement un objet. Les composants sont actualisés et les observateurs sont appelés. `UPDATE()` est la même fonction. Le deuxième argument peut aussi être `true`, ce qui réinitialise l'état des composants.\n\nExample: Actualiser après une modification directe\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nUPD('user.name');\n```\n\n### UPDATE(path, [delay], [reset])\n\nType: `method`\n\nLa même fonction que [UPD()](#upd).\n\nExample: Même fonction\n```js\nconsole.log(UPDATE === UPD); // true\n```\n\n### UPLOAD(url, data, [callback], [delay], [progress])\n\nType: `method`\n\nEnvoie des données à un serveur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL, éventuellement avec une méthode. |\n| `data` | `FormData|Object` | yes |  | Les données. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, ou un path. |\n| `delay` | `Number` | no |  | Attend ce nombre de millisecondes avant l'envoi. |\n| `progress` | `Function|String` | no |  | `function(percentage)`, ou un path. |\n\nReturns: `Promise` Uniquement quand aucun callback n'est fourni.\n\nLa méthode par défaut est `POST`. `FormData` est envoyé tel quel, et tout le reste en JSON. Sans callback, la fonction renvoie une Promise. `progress` peut être le quatrième argument quand aucun délai n'est nécessaire.\n\nExample: Envoyer un fichier\n```js\nvar data = new FormData();\ndata.append('name', 'photo.jpg');\nUPLOAD('/api/upload/', data, function(response) {\n\tconsole.log(response.url); // /api/upload/\n});\n```\n\n### VALID(path, [flags])\n\nType: `method`\n\nIndique si aucun composant d'un path n'est invalide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec `.*` pour tout ce qui se trouve en dessous. |\n| `flags` | `String|Array` | no |  | `visible` ou `hidden` limite la vérification à ces composants. |\n\nReturns: `Boolean` Le résultat.\n\nContrairement à [CAN()](#can), elle ne regarde pas si les composants sont touchés.\n\nExample: Vérifier un formulaire\n```js\nON('ready', function() {\n\tconsole.log(VALID('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tconsole.log(VALID('form.*')); // true\n});\n```\n\n### VBIND(html)\n\nType: `method`\n\nCrée un binder virtuel à partir de HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | Le HTML avec les liaisons. |\n\nReturns: `VBinder` Le binder virtuel.\n\nL'objet est décrit dans [Binder virtuel](../vbinder/), et le sujet dans [Liaisons virtuelles](../../guides/virtual-bindings/).\n\nExample: Lier un élément détaché\n```js\nvar binder = VBIND('<div><span data-bind=\"name__text\"></span></div>');\nbinder.set({ name: 'Peter' });\nconsole.log(binder.element.find('span').text()); // Peter\n```\n\n### VBINDARRAY(html, element)\n\nType: `method`\n\nAffiche un tableau avec un binder virtuel pour chaque élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | Le HTML d'un élément. |\n| `element` | `Element|jQuery|Component` | yes |  | L'élément parent. |\n\nReturns: `Object` Un objet doté des méthodes `set()`, `get()`, `upd()` et `remove()`.\n\nLe sujet est expliqué dans [Liaisons virtuelles](../../guides/virtual-bindings/).\n\nExample: Afficher une liste\n```html\n<ul id=\"list\"></ul>\n<script>\nvar list = VBINDARRAY('<li data-bind=\"name__text\"></li>', $('#list'));\nlist.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log($('#list').text()); // PeterAnna\n</script>\n```\n\n### VERSION(...items)\n\nType: `method`\n\nSélectionne la version des composants utilisés sans version.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...items` | `String` | yes |  | Les composants et leurs versions. |\n\nChaque élément a la forme `name@version`, et une même chaîne peut lister plusieurs éléments séparés par une virgule.\n\nExample: Sélectionner une version\n```html\n<ui-component name=\"tag\"></ui-component>\n<script>\nCOMPONENT('tag@2', function(self) {\n\tself.make = () => self.element.text('two');\n});\nVERSION('tag@2');\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // two\n});\n</script>\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nIndique si un élément se trouve dans la hauteur visible de la fenêtre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'élément. |\n| `threshold` | `Number` | no | `0` | Une marge en pixels. |\n| `mode` | `String` | no | `visible` | `visible`, `above` ou `below`. |\n\nReturns: `Boolean` Le résultat.\n\nExample: Vérifier un élément\n```html\n<div id=\"box\">Box</div>\n<script>\nconsole.log(VISIBLE($('#box'))); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nUn nom court de `window`.\n\nExample: Lire la valeur\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback, [interval], [timeout])\n\nType: `method`\n\nAttend qu'une condition soit remplie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | La fonction ou le path à vérifier. |\n| `callback` | `Function` | yes |  | `function(err, again)`. |\n| `interval` | `Number` | no | `500` | L'intervalle des vérifications en millisecondes. |\n| `timeout` | `Number` | no |  | La durée d'attente maximale en millisecondes. |\n\nLa condition est une fonction ou un path. Le callback reçoit une erreur après un délai d'expiration, ainsi qu'une fonction qui relance l'attente. Sans délai d'expiration, l'attente ne se termine jamais d'elle-même.\n\nExample: Attendre une valeur\n```js\nWAIT('app.ready', function() {\n\tconsole.log(GET('app.ready')); // true\n}, 50);\nsetTimeout(() => SET('app.ready', true), 100);\n```\n\nExample: Arrêter après un délai d'expiration\n```js\nWAIT(() => false, function(err) {\n\tconsole.log(err.message); // Timeout.\n}, 50, 200);\n```\n\n### WAPI([name], [data], [callback], [timeout])\n\nType: `method`\n\nAppelle une API via la connexion WebSocket.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | no |  | Le nom du schéma, ou les options de connexion. |\n| `data` | `Object` | no |  | Les données. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, ou un path. |\n| `timeout` | `Number` | no | `10000` | Le délai d'expiration en millisecondes. |\n\nReturns: `Object|Promise` La connexion, ou une Promise.\n\nUn objet comme premier argument ouvre la connexion comme [WAPI_INIT()](#wapi-init). Sans argument, la fonction renvoie la connexion ouverte. Sans callback, elle renvoie une Promise. Le délai d'expiration par défaut d'un appel est de 10 secondes.\n\nExample: Appeler via un socket\n```js\nWAPI({ url: '/api/' });\nWAPI('users_list', null, function(response) {\n\tconsole.log(response.schema); // users_list\n});\n```\n\n### WAPI_INIT(options)\n\nType: `method`\n\nOuvre la connexion WebSocket utilisée par [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Les options de connexion. |\n\nReturns: `Object` L'objet d'options avec les méthodes ajoutées.\n\nLes options sont `url`, `reconnect` (un délai en millisecondes, ou `false`), `expire` (se reconnecte après cette durée), `callback` (appelé une fois après la première tentative de connexion), ainsi que les gestionnaires `open`, `close(e)` et `message(data)`.\n\nL'objet renvoyé possède les méthodes `send(name, data, callback, [timeout])`, `on(name, fn)` pour les événements `open`, `close`, `message` et `reconnect`, `emit(name, ...)` et `pause(is)`.\n\nExample: Ouvrir une connexion\n```js\nWAPI_INIT({\n\turl: '/api/',\n\topen: function() {\n\t\tconsole.log('connected'); // connected\n\t}\n});\nconsole.log(typeof(WAPI().send)); // function\n```\n\n### WARN(...args)\n\nType: `method`\n\nÉcrit un avertissement dans la console.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...args` | `Object` | yes |  | Les valeurs à écrire. |\n\nExample: Écrire un avertissement\n```js\nWARN('Disk is full');\nconsole.log(typeof(WARN)); // function\n```\n\n### WATCH(path, fn, [init])\n\nType: `method`\n\nAppelle une fonction quand la valeur d'un path change.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path à observer. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n| `init` | `Boolean` | no |  | Avec `true`, la fonction est aussi appelée immédiatement. |\n\nLa fonction reçoit le path modifié, la valeur et le type de changement : `0` appel initial, `1` manuel, `2` saisie, `3` valeur par défaut. Un path `users.*` réagit aussi à tout ce qui se trouve sous `users`. Tu peux séparer plusieurs paths par une espace, et un path qui commence par `^` s'exécute avant les autres observateurs.\n\nExample: Réagir à un changement\n```js\nWATCH('user.name', function(path, value, type) {\n\tconsole.log(path, value, type); // user.name Peter 1\n});\nSET('user.name', 'Peter');\n```\n\nExample: L'appeler immédiatement\n```js\nSET('count', 5);\nWATCH('count', function(path, value, type) {\n\tconsole.log(value, type); // 5 0\n}, true);\n```\n\n### WATCHONCE(path, fn)\n\nType: `method`\n\nAppelle une fonction uniquement au prochain changement d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path à observer. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n\nExample: Réagir une seule fois\n```js\nWATCHONCE('count', function(path, value) {\n\tconsole.log(value); // 1\n});\nSET('count', 1);\nSET('count', 2);\n```\n\n### WH\n\nType: `property`\n\nLa hauteur de la fenêtre en pixels.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(WH)); // number\n```\n\n### WIDTH([element])\n\nType: `method`\n\nRenvoie la taille d'affichage de la fenêtre ou d'un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | L'élément. |\n\nReturns: `String` `xs`, `sm`, `md` ou `lg`.\n\nLes limites se trouvent dans `DEF.devices`.\n\nExample: Lire la taille d'un élément\n```html\n<div id=\"box\" style=\"width:1000px\"></div>\n<script>\nconsole.log(WIDTH($('#box'))); // md\n</script>\n```\n\n### WORKFLOW(declaration, [tasks], [callback])\n\nType: `method`\n\nExécute des étapes nommées qui se transmettent une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `declaration` | `Function` | yes |  | `function($)`. |\n| `tasks` | `Object` | no |  | Les étapes, classées par nom. |\n| `callback` | `Function` | no |  | `function(value, err, $)`. |\n\nReturns: `Object` Le workflow.\n\nL'objet passé à la déclaration et à chaque étape possède ces membres :\n\n| Membre | Description |\n| --- | --- |\n| `push(name, fn)` | Ajoute une étape : `function($, value)` |\n| `next(name, [value])` | Exécute une étape. Un nom inconnu termine le workflow |\n| `next2(name)` | Renvoie un callback qui exécute l'étape |\n| `done([value])` | Appelle le callback final avec la valeur |\n| `invalid(err)` | Signale une erreur à `error` ou au callback final |\n| `callback(fn)` | Remplace le callback final |\n| `clone()` | Crée un workflow avec les mêmes étapes |\n| `destroy()` | Termine le workflow |\n| `value`, `current`, `prev` | La valeur, l'étape actuelle et l'étape précédente |\n\nExample: Exécuter deux étapes\n```js\nWORKFLOW(function($) {\n\t$.push('load', ($, value) => $.next('save', value + 1));\n\t$.push('save', ($, value) => $.done(value * 2));\n\t$.next('load', 1);\n}, function(value) {\n\tconsole.log(value); // 4\n});\n```\n\n### WW\n\nType: `property`\n\nLa largeur de la fenêtre en pixels.\n\nExample: Lire la valeur\n```js\nconsole.log(typeof(WW)); // number\n```\n","entries":[{"type":"method","name":"ACMD()","signature":"ACMD(name, [...args])","since":"","deprecated":false},{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"ADD()","signature":"ADD(value, [element], [config], [content])","since":"","deprecated":false},{"type":"method","name":"AEXEC()","signature":"AEXEC(path, [...args])","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], [callback], [delay])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHE()","signature":"AJAXCACHE(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHEREVIEW()","signature":"AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCONFIG()","signature":"AJAXCONFIG(name, fn)","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BIND()","signature":"BIND(path)","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(name, 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, [rebind])","since":"","deprecated":false},{"type":"method","name":"CAN()","signature":"CAN(path, [flags])","since":"","deprecated":false},{"type":"method","name":"CHANGE()","signature":"CHANGE(path, [value])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, callback)","since":"","deprecated":false},{"type":"method","name":"CL_INIT()","signature":"CL_INIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [nopath])","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], [e])","since":"","deprecated":false},{"type":"method","name":"COMPILE()","signature":"COMPILE([container])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], declaration, [dependencies])","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":"method","name":"DAPI()","signature":"DAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"method","name":"DEBUG()","signature":"DEBUG()","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DEFAULT()","signature":"DEFAULT(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"DISABLED()","signature":"DISABLED(path, [flags])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [...args])","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(value, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, [flags], [highlight])","since":"","deprecated":false},{"type":"method","name":"EVALUATE()","signature":"EVALUATE(path, expression, [nopath])","since":"","deprecated":false},{"type":"method","name":"EXE()","signature":"EXE([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXT()","signature":"EXT(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTEND()","signature":"EXTEND(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], declaration)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [many], [nocache], [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(expression)","since":"","deprecated":false},{"type":"method","name":"FORMATTER()","signature":"FORMATTER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE([delay])","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [scope])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([size])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value, [unsigned])","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"IMPORTCACHE()","signature":"IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value], [delay], [reset])","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":"method","name":"MACRO()","signature":"MACRO(name, declaration)","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"method","name":"MAKE()","signature":"MAKE([target], fn, [update])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, fn)","since":"","deprecated":false},{"type":"method","name":"MODIFIED()","signature":"MODIFIED(path, [flags])","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"property","name":"NAV","signature":"NAV","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, target, [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":"method","name":"NOTIFY()","signature":"NOTIFY(...paths)","since":"","deprecated":false},{"type":"method","name":"NOTMODIFIED()","signature":"NOTMODIFIED(path, [value], [fields])","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"NULL()","signature":"NULL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [path], [fn])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, [path], fn, [init])","since":"","deprecated":false},{"type":"method","name":"OPT()","signature":"OPT([obj], fn)","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value, [date])","since":"","deprecated":false},{"type":"method","name":"PARSER()","signature":"PARSER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [fn], [init], [done])","since":"","deprecated":false},{"type":"method","name":"PLUGINABLE()","signature":"PLUGINABLE(name, fn, [init])","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, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], obj)","since":"","deprecated":false},{"type":"method","name":"QUEUE()","signature":"QUEUE([name], fn)","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT(url)","since":"","deprecated":false},{"type":"method","name":"REMOVECACHE()","signature":"REMOVECACHE(key)","since":"","deprecated":false},{"type":"method","name":"REPEAT()","signature":"REPEAT([condition], process, delay, [init])","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path, [delay])","since":"","deprecated":false},{"type":"method","name":"RETURN()","signature":"RETURN(command, [multiple])","since":"","deprecated":false},{"type":"method","name":"REWRITE()","signature":"REWRITE(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"REWRITE2()","signature":"REWRITE2(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"ROUTE()","signature":"ROUTE(url, fn, [middleware], [init])","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(target, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, fn, delay, [limit], [arg])","since":"","deprecated":false},{"type":"method","name":"STOPDEBUG()","signature":"STOPDEBUG()","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":"property","name":"Ta","signature":"Ta","since":"","deprecated":false},{"type":"property","name":"Tangular","signature":"Tangular","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"property","name":"Thelpers","signature":"Thelpers","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...roles)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [fn])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPDATE()","signature":"UPDATE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPLOAD()","signature":"UPLOAD(url, data, [callback], [delay], [progress])","since":"","deprecated":false},{"type":"method","name":"VALID()","signature":"VALID(path, [flags])","since":"","deprecated":false},{"type":"method","name":"VBIND()","signature":"VBIND(html)","since":"","deprecated":false},{"type":"method","name":"VBINDARRAY()","signature":"VBINDARRAY(html, element)","since":"","deprecated":false},{"type":"method","name":"VERSION()","signature":"VERSION(...items)","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, [interval], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI()","signature":"WAPI([name], [data], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI_INIT()","signature":"WAPI_INIT(options)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...args)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, fn, [init])","since":"","deprecated":false},{"type":"method","name":"WATCHONCE()","signature":"WATCHONCE(path, fn)","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"method","name":"WORKFLOW()","signature":"WORKFLOW(declaration, [tasks], [callback])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammaB9IM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/globals/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Funzioni globali","summary":"Le funzioni e gli oggetti che jComponent aggiunge all'oggetto window.","markdown":"---\ntitle: Funzioni globali\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/globals/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Funzioni globali\n\n> Le funzioni e gli oggetti che jComponent aggiunge all'oggetto window.\n\njComponent aggiunge queste funzioni e questi oggetti a `window`, quindi puoi usarli ovunque senza importarli. Per capire prima come funzionano i path, leggi [Path](../../guides/paths/).\n\n## API\n\n### ACMD(name, [...args])\n\nType: `method`\n\nCrea una funzione che chiama [CMD()](#cmd) in un secondo momento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n| `...args` | `Object` | no |  | I primi argomenti. |\n\nReturns: `Function` La funzione da chiamare.\n\nL'argomento della funzione creata viene aggiunto come ultimo argomento del comando.\n\nExample: Usala come callback\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nACMD('refresh')(1);\n```\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrepara il testo importato per un path e un identificatore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il valore per `~PATH~` e `CLASS`. |\n| `id` | `String` | yes |  | Il valore per `~ID~`. |\n| `text` | `String` | yes |  | Il testo. |\n\nReturns: `String` Il testo modificato.\n\nIl testo viene tradotto, le variabili `--name--` vengono sostituite, `~CDN~` diventa `DEF.cdn`, `~PATH~` e `CLASS` diventano il path e `~ID~` diventa l'identificatore.\n\nExample: Sostituisci i marcatori\n```js\nconsole.log(ADAPT('users', 'form1', '~PATH~ and ~ID~')); // users and form1\n```\n\n### ADD(value, [element], [config], [content])\n\nType: `method`\n\nAggiunge un componente alla pagina.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object|Array` | yes |  | Il componente. |\n| `element` | `Element|jQuery|Component` | no | `document.body` | L'elemento genitore. |\n| `config` | `Object|String` | no |  | La configurazione. |\n| `content` | `String` | no |  | L'HTML interno. |\n\nUna stringa ha la forma `name__path__config`. Un `!` iniziale salta il componente se è già dichiarato. Un oggetto può avere i campi `name`, `path`, `config`, `element` e `prepend`. Un array aggiunge più componenti.\n\nExample: Aggiungi un componente\n```js\nADD('box__data.title__size:10');\nsetTimeout(function() {\n\tconsole.log(FIND('box').config.size); // 10\n}, 1200);\n```\n\n### AEXEC(path, [...args])\n\nType: `method`\n\nCrea una funzione che chiama [EXEC()](#exec) in un secondo momento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | La destinazione. |\n| `...args` | `Object` | no |  | I primi argomenti. |\n\nReturns: `Function` La funzione da chiamare.\n\nL'argomento della funzione creata viene aggiunto come ultimo argomento.\n\nExample: Usala come callback\n```js\nwindow.save = value => console.log(value); // 5\nAEXEC('save')(5);\n```\n\n### AJAX(url, [data], [callback], [delay])\n\nType: `method`\n\nInvia una richiesta HTTP.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il metodo e l'URL. |\n| `data` | `Object|String` | no |  | I dati. Una richiesta `GET` li invia nella stringa di query. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, oppure un path. |\n| `delay` | `Number` | no |  | Attende questo numero di millisecondi prima dell'invio. |\n\nReturns: `Promise` Solo quando non viene fornita una callback.\n\nL'URL ha la forma `METHOD /path/`. Possono seguire altri elementi, separati da uno spazio:\n\n| Elemento | Significato |\n| --- | --- |\n| `!METHOD` | Invia i cookie con la richiesta |\n| `{ \"Name\": \"value\" }` | Intestazioni della richiesta |\n| `<5 minutes>` | Memorizza la risposta nella cache, come in [AJAXCACHE()](#ajaxcache) |\n| `(name)` | Applica le impostazioni di [AJAXCONFIG()](#ajaxconfig) |\n| `repeat` | Ripete la richiesta quando il server non è disponibile |\n| `cancel` | Annulla la precedente richiesta non terminata allo stesso URL |\n| `urlencoded` | Invia i dati come modulo con codifica URL |\n| `json` | Accetta solo una risposta JSON |\n| `error` | Passa la risposta attraverso [ERROR()](#error) |\n| `noencrypt`, `nodecrypt`, `nocsrf` | Salta la cifratura, la decifratura o l'intestazione CSRF |\n| `#id` | Assegna un nome alla richiesta per `cancel`, oppure attende un elenco di codici |\n| `@flag` | Emette un flag personalizzato |\n\nLa callback riceve la risposta, il codice di stato in caso di errore e un oggetto con i dettagli della richiesta. Una callback di tipo stringa è un path in cui viene memorizzata la risposta. Senza callback, la funzione restituisce una Promise, che viene rifiutata con uno stato superiore a 399.\n\nExample: Invia dati\n```js\nAJAX('POST /api/users/', { name: 'Peter' }, function(response, err) {\n\tconsole.log(response.method, response.url); // POST /api/users/\n\tconsole.log(response.body); // {\"name\":\"Peter\"}\n});\n```\n\nExample: Usa una Promise\n```js\n(async function() {\n\tvar response = await AJAX('GET /api/users/');\n\tconsole.log(response.url); // /api/users/\n})();\n```\n\nExample: Gestisci un errore\n```js\nAJAX('GET /api/missing/', function(response, err) {\n\tconsole.log(err, response); // 404 Not found\n});\n```\n\n### AJAXCACHE(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nInvia una richiesta e memorizza la risposta nella cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il metodo e l'URL. |\n| `data` | `Object` | no |  | I dati. |\n| `callback` | `Function|String` | yes |  | `function(response, cached)`, oppure un path. |\n| `expire` | `String` | yes |  | Ad esempio `5 minutes` o `session`. |\n| `delay` | `Number` | no |  | Attende questo numero di millisecondi prima della lettura. |\n| `clear` | `Boolean` | no |  | Con `true`, ignora la risposta memorizzata. |\n\nLa callback riceve la risposta e `true` quando proviene dalla cache. Il valore `session` per `expire` conserva la risposta in memoria fino al ricaricamento della pagina.\n\nExample: Memorizza una risposta nella cache\n```js\nAJAXCACHE('GET /api/users/', function(response, cached) {\n\tconsole.log('first', cached); // first false\n\tAJAXCACHE('GET /api/users/', function(response, cached) {\n\t\tconsole.log('second', cached); // second true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nRestituisce la risposta dalla cache e poi controlla se sul server ce n'è una più recente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il metodo e l'URL. |\n| `data` | `Object` | no |  | I dati. |\n| `callback` | `Function|String` | yes |  | `function(response, cached, updated)`, oppure un path. |\n| `expire` | `String` | yes |  | Ad esempio `5 minutes`. |\n| `delay` | `Number` | no |  | Attende questo numero di millisecondi prima della lettura. |\n| `clear` | `Boolean` | no |  | Con `true`, ignora la risposta memorizzata. |\n\nQuando il server restituisce dati diversi, la callback viene eseguita di nuovo con `false` e `true` come secondo e terzo argomento.\n\nExample: Aggiorna una risposta nella cache\n```js\nAJAXCACHE('GET /api/time/', function() {\n\tAJAXCACHEREVIEW('GET /api/time/', function(response, cached, updated) {\n\t\tconsole.log(response.value, cached, updated === true); // 2 false true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCONFIG(name, fn)\n\nType: `method`\n\nDichiara impostazioni che una richiesta può applicare per nome.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome delle impostazioni. |\n| `fn` | `Function` | yes |  | `function(options)`. |\n\nUna richiesta le applica con `(name)` nel proprio URL. La funzione riceve le opzioni della richiesta.\n\nExample: Aggiungi un'intestazione\n```js\nAJAXCONFIG('secure', function(options) {\n\toptions.headers['X-Token'] = 'abc';\n});\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-Token']); // abc\n\topt.respond({});\n});\nAJAX('GET /api/users/ (secure)', NOOP);\n```\n\n### API(url, [data], [callback])\n\nType: `method`\n\nChiama un endpoint API di Total.js.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'endpoint e lo schema. |\n| `data` | `Object` | no |  | I dati. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, oppure un path. |\n\nReturns: `Object|Promise` L'oggetto descritto sopra, oppure una Promise.\n\nL'URL ha la forma `/api/ schema`. La richiesta è un `POST` con il nome dello schema e i dati nel corpo. Senza callback, la funzione restituisce una Promise. Con una callback, restituisce un oggetto con `params(value)`, che compila i parametri dello schema, e `data(value)`, che sostituisce i dati.\n\nExample: Chiama un endpoint\n```js\nAPI('/api/ users_save', { name: 'Peter' }, function(response) {\n\tconsole.log(response.url); // /api/\n\tconsole.log(response.body); // {\"schema\":\"users_save\",\"data\":{\"name\":\"Peter\"}}\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nImposta l'aspetto dell'applicazione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Le variabili CSS e i campi `dark` e `large`. |\n\nOgni campo diventa una variabile CSS su `:root`. `dark` e `large` attivano o disattivano le classi `ui-dark` e `ui-large` sul body. `color` è un colore esadecimale a sei cifre, che imposta anche `DEF.color` e la variabile `--rgb`.\n\nExample: Usa un tema scuro\n```js\nAPPEARANCE({ dark: true, color: '#336699' });\nconsole.log($('#cssappearance').html()); // :root{--color:#336699;--rgb:51,102,153}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\n### ASETTER(selector, method, [...args])\n\nType: `method`\n\nCrea una funzione che chiama [SETTER()](#setter) in un secondo momento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selettore come in [FIND()](#find). |\n| `method` | `String` | yes |  | Il nome del metodo. |\n| `...args` | `Object` | no |  | I primi argomenti del metodo. |\n\nReturns: `Function` La funzione da chiamare.\n\nL'argomento della funzione creata viene aggiunto come ultimo argomento del metodo, quindi è adatta come callback di una richiesta.\n\nExample: Usala come callback\n```js\nON('ready', function() {\n\tvar fn = ASETTER('box', 'hello');\n\tfn('Peter');\n\tconsole.log(typeof(fn)); // function\n});\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLegge un attributo `data-` da un elemento o dai suoi genitori.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery|Event|Object` | yes |  | L'origine. |\n| `name` | `String` | no | `id` | Il nome dell'attributo. |\n\nReturns: `String` Il valore.\n\nUn oggetto semplice restituisce il suo campo con quel nome.\n\nExample: Leggi un identificatore\n```html\n<div id=\"row\" data-id=\"15\" data-type=\"user\"></div>\n<script>\nconsole.log(ATTRD($('#row'))); // 15\nconsole.log(ATTRD($('#row'), 'type')); // user\n</script>\n```\n\n### BIND(path)\n\nType: `method`\n\nAggiorna le associazioni dei dati di un path senza notificare i componenti o gli osservatori.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Array` | yes |  | Un path o un elenco di path. |\n\nExample: Aggiorna un'associazione\n```html\n<span id=\"name\" data-bind=\"user.name__text\"></span>\n<script>\nSET('user', { name: 'Peter' });\nsetTimeout(function() {\n\tGET('user').name = 'Anna';\n\tBIND('user.name');\n\tsetTimeout(function() {\n\t\tconsole.log($('#name').text()); // Anna\n\t}, 300);\n}, 300);\n</script>\n```\n\n### BLOCKED(name, timeout, [callback])\n\nType: `method`\n\nLimita la frequenza con cui un'azione può essere eseguita.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'azione. |\n| `timeout` | `Number|String` | yes |  | Millisecondi, oppure un valore come `5 seconds`. |\n| `callback` | `Function` | no |  | Viene eseguita quando l'azione non è bloccata. |\n\nReturns: `Boolean` `true` quando l'azione è bloccata.\n\nLa prima chiamata restituisce `false` e blocca il nome per il tempo indicato. Un blocco più lungo di 10 secondi viene conservato nell'archiviazione del browser.\n\nExample: Consenti una chiamata al secondo\n```js\nconsole.log(BLOCKED('save', 1000)); // false\nconsole.log(BLOCKED('save', 1000)); // true\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLegge o scrive un valore nella cache del browser.\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|Number` | no |  | Ad esempio `1 day`, `session` oppure millisecondi. |\n\nReturns: `Object` Il valore memorizzato.\n\nUn valore viene memorizzato solo con una scadenza. Il valore `session` lo conserva in memoria fino al ricaricamento della pagina.\n\nExample: Salva un valore\n```js\nCACHE('profile', { name: 'Peter' }, '1 day');\nconsole.log(CACHE('profile')); // {\"name\":\"Peter\"}\n```\n\n### CACHEPATH(path, expire, [rebind])\n\nType: `method`\n\nConserva il valore di un path nella cache del browser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `expire` | `String` | yes |  | Ad esempio `1 month`. |\n| `rebind` | `Boolean` | no | `true` | Con `false`, il valore memorizzato non viene ripristinato. |\n\nOgni modifica del path viene memorizzata e il valore memorizzato viene ripristinato alla visita successiva. Con la forma `path__value`, l'espressione è il valore usato quando non c'è nulla di memorizzato.\n\nExample: Ricorda un valore\n```js\nCACHEPATH('settings.theme', '1 month');\nSET('settings.theme', 'dark');\nconsole.log(CACHE('PATHS')); // {\"settings.theme\":\"dark\"}\n```\n\n### CAN(path, [flags])\n\nType: `method`\n\nIndica se un modulo può essere inviato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita il controllo a quei componenti. |\n\nReturns: `Boolean` Il risultato.\n\nIl risultato è `true` quando almeno un componente sul path è stato toccato e nessuno è non valido. Anche un path senza componenti restituisce `true`.\n\nExample: Abilita un pulsante di invio\n```js\nON('ready', function() {\n\tconsole.log(CAN('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tCHANGE('form.name');\n\tconsole.log(CAN('form.*')); // true\n});\n```\n\n### CHANGE(path, [value])\n\nType: `method`\n\nContrassegna i componenti su un path come toccati e modificati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Boolean` | no | `true` | Con `false`, i contrassegni vengono rimossi. |\n\nExample: Contrassegna un campo come modificato\n```js\nON('ready', function() {\n\tCHANGE('form.age');\n\tconsole.log(MODIFIED('form.*')); // [\"form.age\"]\n});\n```\n\n### CL(name, callback)\n\nType: `method`\n\nAttende il caricamento degli elenchi di codici.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'elenco di codici. |\n| `callback` | `Function` | yes |  | Viene eseguita quando gli elenchi sono pronti. |\n\nPuoi separare più nomi con una virgola. I valori caricati vengono memorizzati in `DEF.cl`.\n\nExample: Attendi un elenco di codici\n```js\nCL_INIT('countries', next => next(['SK', 'CZ']));\nCL('countries', function() {\n\tconsole.log(DEF.cl.countries); // [\"SK\",\"CZ\"]\n});\n```\n\n### CL_INIT(name, source, [expire], [init])\n\nType: `method`\n\nDichiara come viene caricato 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 |  | Il caricatore. |\n| `expire` | `String` | no |  | L'elenco viene ricaricato trascorso questo tempo. |\n| `init` | `Boolean` | no |  | Con `true`, carica subito l'elenco. |\n\nL'origine è una funzione che riceve `next(value)`, oppure una stringa. Una stringa che inizia con un metodo HTTP viene passata ad [AJAX()](#ajax), qualsiasi altra stringa a [TAPI()](#tapi). `CLINIT()` è la stessa funzione.\n\nExample: Carica un elenco da un URL\n```js\nCL_INIT('roles', 'GET /api/roles/', true);\nsetTimeout(function() {\n\tconsole.log(DEF.cl.roles.url); // /api/roles/\n}, 300);\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nAnnulla un timer con nome.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del timer. |\n\nReturns: `Boolean` `true` quando un timer era in esecuzione.\n\nExample: Annulla un timer\n```js\nsetTimeout2('save', NOOP, 1000);\nconsole.log(clearTimeout2('save')); // true\nconsole.log(clearTimeout2('save')); // false\n```\n\n### CLINIT(name, source, [expire], [init])\n\nType: `method`\n\nLa stessa funzione di [CL_INIT()](#cl-init).\n\nExample: Stessa funzione\n```js\nconsole.log(CLINIT === CL_INIT); // true\n```\n\n### CLONE(value, [nopath])\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 o un path. |\n| `nopath` | `Boolean` | no |  | Con `true`, una stringa viene restituita così com'è. |\n\nReturns: `Object` La copia.\n\nUna stringa viene trattata come un path e viene clonato il valore del path.\n\nExample: Clona un valore\n```js\nSET('user', { name: 'Peter' });\nvar copy = CLONE('user');\ncopy.name = 'Anna';\nconsole.log(GET('user.name')); // Peter\nconsole.log(copy.name); // Anna\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nRicarica gli elenchi di codici.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'elenco di codici. |\n| `callback` | `Function` | no |  | Viene eseguita quando gli elenchi sono caricati. |\n\nPuoi separare più nomi con una virgola.\n\nExample: Ricarica un elenco\n```js\nvar count = 0;\nCL_INIT('numbers', next => next([++count]), true);\nsetTimeout(function() {\n\tCLRELOAD('numbers', function() {\n\t\tconsole.log(DEF.cl.numbers); // [2]\n\t});\n}, 100);\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nEsegue un comando in tutti i componenti che lo hanno registrato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n| `a` | `Object` | no |  | Fino a cinque argomenti, da `a` a `e`. |\n\nI componenti registrano i comandi con `self.command()`.\n\nExample: Esegui un comando\n```js\nON('ready', function() {\n\tCMD('box.ping', 5);\n});\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // box.ping 5\n});\n```\n\n### COMPILE([container])\n\nType: `method`\n\nCerca nella pagina nuovi componenti e nuove associazioni.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limita la ricerca a questo elemento. |\n\nChiamala dopo aver aggiunto HTML manualmente.\n\nExample: Compila il nuovo HTML\n```js\n$(document.body).append('<ui-component name=\"box\" path=\"data.new\"></ui-component>');\nCOMPILE();\nsetTimeout(function() {\n\tconsole.log(FIND('box').path); // data.new\n}, 500);\n```\n\n### COMPONENT(name, [config], declaration, [dependencies])\n\nType: `method`\n\nDichiara un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del componente. |\n| `config` | `String|Object` | no |  | La configurazione predefinita. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n| `dependencies` | `Array` | no |  | I file da importare prima, oppure nomi di componenti che iniziano con `@`. |\n\nPuoi separare più nomi con una virgola. Il nome può essere seguito da una versione: `box@2`. L'argomento completo è spiegato in [Creare componenti](../../guides/creating-components/) e l'oggetto ricevuto dalla dichiarazione è descritto in [Component](../component/).\n\nExample: Dichiara un componente\n```html\n<ui-component name=\"hello\"></ui-component>\n<script>\nCOMPONENT('hello', 'name:World', function(self, config) {\n\tself.make = () => self.element.text('Hello ' + config.name);\n});\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // Hello World\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nElenca i componenti su un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path con flag facoltativi. |\n\nReturns: `Array` I componenti.\n\nIl path si scrive senza `.*`. I flag dopo il path filtrano l'elenco: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` e `@enabled`.\n\nExample: Filtra i componenti\n```js\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tSET('form.name', 'Peter');\n\tconsole.log(COMPONENTS('form @invalid').map(com => com.path)); // [\"form.age\"]\n});\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nImposta la configurazione dei componenti prima del loro avvio.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Quali componenti configurare. |\n| `config` | `Object|String|Function` | yes |  | La configurazione, oppure una funzione che la restituisce. |\n\nIl selettore è un nome di componente, `.path`, `#id` oppure una funzione che riceve il componente e restituisce un booleano. Le parti separate da uno spazio devono corrispondere tutte, e una virgola separa le alternative. Chiamala prima che i componenti vengano compilati.\n\nExample: Configura per nome\n```js\nCONFIG('box', { size: 10 });\nON('ready', function() {\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### COOKIES\n\nType: `property`\n\nUn oggetto per leggere e scrivere i cookie.\n\nHa i metodi `get(name)`, `set(name, value, expire, [samesite])` e `rem(name)`. `expire` è un `Date` oppure un valore come `1 day`.\n\nExample: Leggi il valore\n```js\nCOOKIES.set('theme', 'dark', '1 day');\nconsole.log(COOKIES.get('theme') === 'dark' || location.protocol === 'file:'); // true\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopia i campi di un oggetto in un altro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | L'oggetto da leggere. |\n| `target` | `Object` | yes |  | L'oggetto in cui scrivere. |\n\nReturns: `Object` L'oggetto di destinazione.\n\nGli oggetti all'interno dell'origine vengono clonati.\n\nExample: Copia i campi\n```js\nvar target = COPY({ a: 1 }, { b: 2 });\nconsole.log(target); // {\"b\":2,\"a\":1}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nLa stessa funzione di [STYLE()](#style).\n\nExample: Stessa funzione\n```js\nconsole.log(CSS === STYLE); // true\n```\n\n### DAPI(name, [data], [callback])\n\nType: `method`\n\nChiama l'endpoint API impostato in `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dello schema. |\n| `data` | `Object` | no |  | I dati. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, oppure un path. |\n\nReturns: `Object|Promise` Uguale a [API()](#api).\n\n`DEF.api` è un URL, oppure una funzione che riceve il nome e i dati e restituisce il valore per [API()](#api).\n\nExample: Usa l'endpoint predefinito\n```js\nDEF.api = '/api/';\nDAPI('users_list', null, function(response) {\n\tconsole.log(response.url, response.body.schema); // /api/ users_list\n});\n```\n\n### DAYS\n\nType: `property`\n\nI nomi dei giorni, a partire dalla domenica.\n\nExample: Leggi il valore\n```js\nconsole.log(DAYS[0]); // Sunday\n```\n\n### DEBUG()\n\nType: `method`\n\nAttiva la modalità di debug.\n\nLe chiamate a metodi mancanti scrivono un avviso nella console e [API()](#api) aggiunge lo schema all'URL. La modalità non può essere attivata dopo che `DEF.secret()` ha impostato una chiave.\n\nExample: Ricevi un avviso per un metodo mancante\n```js\nDEBUG();\nEXEC('missing.method');\nconsole.log('done'); // done\n```\n\n### DECRYPT(value, [key], [type])\n\nType: `method`\n\nDecodifica un valore prodotto da [ENCRYPT()](#encrypt).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il valore codificato. |\n| `key` | `String` | no |  | La chiave. |\n| `type` | `String` | no |  | Il prefisso del valore. |\n\nReturns: `Object` Il valore, oppure `undefined` quando la chiave o il prefisso non corrispondono.\n\nIl JSON viene riconvertito in un oggetto.\n\nExample: Usa una chiave errata\n```js\nvar token = ENCRYPT('Peter', 'secret');\nconsole.log(DECRYPT(token, 'secret')); // Peter\nconsole.log(DECRYPT(token, 'other') === undefined); // true\n```\n\n### DEF\n\nType: `property`\n\nLa configurazione della libreria. Consulta [DEF](../def/).\n\nExample: Leggi il valore\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEFAULT(path, [delay], [reset])\n\nType: `method`\n\nRipristina i valori predefiniti dei componenti su un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso, oppure `path__value`. |\n| `delay` | `Number` | no |  | Un ritardo in millisecondi. |\n| `reset` | `Boolean` | no | `true` | Con `false`, lo stato dei componenti viene mantenuto. |\n\nUn componente prende il valore predefinito dal suo attributo `default`. Con la forma `path__value`, viene invece scritta nel path come valore predefinito l'espressione che segue i due trattini bassi.\n\nExample: Scrivi un oggetto predefinito\n```js\nDEFAULT('form.* __{ name: \"Peter\" }');\nsetTimeout(function() {\n\tconsole.log(GET('form')); // {\"name\":\"Peter\"}\n}, 100);\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 |  | Il genitore. |\n| `selector` | `String` | yes |  | Un selettore dei figli. |\n| `html` | `String` | yes |  | Il nuovo HTML. |\n| `attribute` | `String` | no |  | L'attributo da confrontare. |\n\nReturns: `Object` I conteggi `add`, `upd` e `rem`.\n\nVengono aggiunti o rimossi solo i figli modificati. I figli vengono confrontati in base al loro HTML o al valore dell'attributo.\n\nExample: Aggiorna un elenco\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n<script>\nvar result = DIFFDOM($('#list'), 'li', '<li>B</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log($('#list').text()); // BC\n</script>\n```\n\n### DISABLED(path, [flags])\n\nType: `method`\n\nL'opposto di [CAN()](#can).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita il controllo a quei componenti. |\n\nReturns: `Boolean` Il risultato.\n\nExample: Disabilita un pulsante di invio\n```js\nON('ready', function() {\n\tconsole.log(DISABLED('form.*')); // true\n});\n```\n\n### EMIT(name, [...args])\n\nType: `method`\n\nChiama i gestori di un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `...args` | `Object` | no |  | Gli argomenti passati ai gestori. |\n\nReturns: `Boolean` `true` quando l'evento ha almeno un gestore.\n\nIl nome può essere seguito da un flag personalizzato, ad esempio `EMIT('ping @saved')`.\n\nExample: Emetti un evento\n```js\nON('hello', name => console.log(name)); // Peter\nconsole.log(EMIT('hello', 'Peter')); // true\nconsole.log(EMIT('unknown')); // false\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nUn array vuoto congelato.\n\nExample: Leggi il valore\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nUn oggetto vuoto congelato.\n\nExample: Leggi il valore\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nCodifica un valore in una stringa esadecimale firmata con una chiave.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Il valore. |\n| `key` | `String` | no |  | La chiave. |\n| `type` | `String` | no |  | Un prefisso del risultato. |\n\nReturns: `String` Il valore codificato.\n\nIl valore viene codificato, non cifrato in modo robusto. Gli oggetti vengono convertiti in JSON.\n\nExample: Codifica e decodifica\n```js\nvar token = ENCRYPT({ id: 5 }, 'secret');\nconsole.log(DECRYPT(token, 'secret')); // {\"id\":5}\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLegge o scrive una variabile d'ambiente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Il nome, oppure un oggetto con i valori. |\n| `value` | `Object` | no |  | Il valore. |\n\nReturns: `Object` Il valore della variabile.\n\nUn oggetto come primo argomento scrive più variabili. I path e gli URL leggono le variabili con `[name]`. Le variabili vengono memorizzate in `DEF.environment`.\n\nExample: Usa una variabile\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 il nome, la versione e la lingua dell'applicazione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'applicazione. |\n| `version` | `String` | no |  | La versione. |\n| `language` | `String` | no |  | La lingua dell'HTML importato. |\n| `env` | `Object` | no |  | Le variabili d'ambiente per [ENV()](#env). |\n\nIl nome separa l'archiviazione del browser dell'applicazione. Imposta `DEF.localstorage`, `DEF.version` e `DEF.languagehtml`.\n\nExample: Assegna un nome all'applicazione\n```js\nENVIRONMENT('shop', '1.2', 'en', { api: '/api/' });\nconsole.log(DEF.localstorage, DEF.version, ENV('api')); // shop 1.2 /api/\n```\n\n### ERROR(value, [success], [error])\n\nType: `method`\n\nIndica se una risposta contiene un errore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|Function` | yes |  | La risposta, oppure il gestore del successo. |\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|Function` `true` quando il valore è un errore, oppure la callback creata.\n\nUn `Error`, un oggetto con il campo `error` o un array il cui primo elemento ha quel campo contano come errore, e viene emesso l'evento [ERROR](../events/#error-2). `success` ed `error` sono funzioni o path.\n\nCon una funzione come primo argomento, `ERROR(success, [error])` restituisce una callback per una richiesta.\n\nExample: Controlla una risposta\n```js\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\nconsole.log(ERROR({ id: 5 })); // false\n```\n\nExample: Crea una callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 5\n});\ncallback({ id: 5 });\n```\n\n### ERRORS(path, [flags], [highlight])\n\nType: `method`\n\nElenca i componenti toccati e non validi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita il controllo a quei componenti. |\n| `highlight` | `Boolean` | no |  | Aggiorna lo stato dei componenti trovati. |\n\nReturns: `Array` I componenti.\n\n`ERRORS(path, true)` aggiorna anche lo stato dei componenti che trova.\n\nExample: Trova i campi non validi\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(ERRORS('form.*').map(com => com.path)); // [\"form.name\"]\n});\n```\n\n### EVALUATE(path, expression, [nopath])\n\nType: `method`\n\nValuta un'espressione JavaScript con il valore di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Object` | yes |  | Il path, oppure il valore stesso quando `nopath` è `true`. |\n| `expression` | `String` | yes |  | L'espressione. |\n| `nopath` | `Boolean` | no |  | Tratta il primo argomento come valore. |\n\nReturns: `Object` Il risultato dell'espressione.\n\nL'espressione può usare le variabili `value` e `path`.\n\nExample: Valuta un'espressione\n```js\nSET('price', 10);\nconsole.log(EVALUATE('price', 'value * 2')); // 20\nconsole.log(EVALUATE(4, 'value + 1', true)); // 5\n```\n\n### EXE([wait], path, [...args])\n\nType: `method`\n\nLa stessa funzione di [EXEC()](#exec).\n\nExample: Stessa funzione\n```js\nconsole.log(EXE === EXEC); // true\n```\n\n### EXEC([wait], path, [...args])\n\nType: `method`\n\nChiama una funzione, un metodo di un plugin, un metodo di un componente, un comando o un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Con `true`, attende la destinazione. |\n| `path` | `String` | yes |  | La destinazione. |\n| `...args` | `Object` | no |  | Gli argomenti. |\n\nLa forma del path seleziona la destinazione:\n\n| Path | Destinazione |\n| --- | --- |\n| `plugin/method` | Un metodo di un plugin |\n| `@plugin.method` | Un metodo di un plugin |\n| `path.to.fn` | Una funzione su un path |\n| `#name` | L'evento `name` |\n| `-selector/method` | Un metodo di un componente, come in [SETTER()](#setter) |\n| `&name` | Un comando, come in [CMD()](#cmd) |\n\nCon `true` come primo argomento, la chiamata attende che la destinazione esista. `EXE()` è la stessa funzione.\n\nExample: Chiama un metodo di un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.hello = function(name) {\n\t\tconsole.log(name); // Peter\n\t};\n});\nEXEC(true, 'users/hello', 'Peter');\n```\n\nExample: Chiama una funzione su un path\n```js\nwindow.app = { sum: (a, b) => console.log(a + b) };\nEXEC('app.sum', 1, 2);\nconsole.log(typeof(app.sum)); // function\n```\n\n### EXT(path, value, [delay], [reset])\n\nType: `method`\n\nUnisce i campi di un oggetto all'oggetto su un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Object` | yes |  | I campi da unire. |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n| `reset` | `Boolean` | no |  | Con `true`, i componenti sul path vengono anche contrassegnati come non toccati e non modificati. |\n\nOgni campo viene scritto separatamente, quindi gli altri campi restano. `EXTEND()` è la stessa funzione. Come con [SET()](#set), il primo argomento può essere una richiesta e `value` il path di destinazione.\n\nExample: Unisci i campi\n```js\nSET('user', { name: 'Peter' });\nEXT('user', { age: 30 });\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"age\":30}\n```\n\n### EXTEND(path, value, [delay], [reset])\n\nType: `method`\n\nLa stessa funzione di [EXT()](#ext).\n\nExample: Stessa funzione\n```js\nconsole.log(EXTEND === EXT); // true\n```\n\n### EXTENSION(name, [config], declaration)\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 `@plugin`. |\n| `config` | `Object|String` | no |  | Configurazione aggiuntiva. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n\nLa dichiarazione viene eseguita per ogni istanza del componente, comprese quelle esistenti. Con un nome che inizia con `@`, estende il plugin con quel nome.\n\nExample: Aggiungi un metodo a un componente\n```js\nEXTENSION('box', function(self) {\n\tself.bye = () => 'Bye';\n});\nON('ready', function() {\n\tconsole.log(FIND('box').bye()); // Bye\n});\n```\n\n### FIND(selector, [many], [nocache], [callback])\n\nType: `method`\n\nTrova un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Element` | yes |  | Che cosa trovare. |\n| `many` | `Boolean` | no |  | Con `true`, restituisce tutte le corrispondenze come array. |\n| `nocache` | `Boolean` | no |  | Salta la cache dei componenti trovati. |\n| `callback` | `Function` | no |  | Attende il componente e lo riceve. |\n\nReturns: `Component|Array` Il componente trovato, oppure un array con `many`. Se usi una callback non viene restituito nulla.\n\nIl selettore è un nome di componente, `.path`, `#id`, `name[path]` o `name@version`, e le parti possono essere combinate con uno spazio. Un elemento DOM o un oggetto jQuery trova i componenti al suo interno.\n\nCon una callback, la ricerca attende che il componente esista. La callback può essere il secondo o il terzo argomento.\n\nExample: Trova per nome e path\n```js\nON('ready', function() {\n\tconsole.log(FIND('box').path); // data.box\n\tconsole.log(FIND('.data.box').name); // box\n\tconsole.log(FIND('box', true).length); // 1\n});\n```\n\nExample: Attendi un componente\n```js\nFIND('box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### FN(expression)\n\nType: `method`\n\nCrea una funzione da una stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expression` | `String` | yes |  | L'espressione. |\n\nReturns: `Function` La funzione.\n\nLa stringa è una funzione freccia. Una stringa che usa solo la parola `value` diventa una funzione con l'argomento `value`.\n\nExample: Crea funzioni\n```js\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value > 5')(10)); // true\n```\n\n### FORMATTER(fn, [prepend])\n\nType: `method`\n\nRegistra un formattatore globale dei valori dei componenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Con `true`, il formattatore viene eseguito per primo. |\n\nReturns: `Object` Il valore formattato, quando la funzione esegue i formattatori.\n\nLa funzione restituisce il nuovo valore, e `undefined` mantiene quello corrente. `FORMATTER(value, path, type, [format])` esegue tutti i formattatori registrati.\n\nExample: Formatta un valore\n```js\nFORMATTER(function(path, value, type) {\n\tif (type === 'upper')\n\t\treturn value.toUpperCase();\n});\nconsole.log(FORMATTER('peter', 'user.name', 'upper')); // PETER\n```\n\n### FREE([delay])\n\nType: `method`\n\nRimuove i componenti, le associazioni e gli osservatori non utilizzati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `10` | Il ritardo in millisecondi. |\n\nLa libreria lo fa anche ogni tre minuti.\n\nExample: Fai pulizia\n```js\nFREE();\nconsole.log(typeof(FREE)); // function\n```\n\n### FUNC\n\nType: `property`\n\nUn oggetto vuoto per le tue funzioni condivise.\n\nExample: Leggi il valore\n```js\nFUNC.sum = (a, b) => a + b;\nconsole.log(FUNC.sum(1, 2)); // 3\n```\n\n### GET(path, [scope])\n\nType: `method`\n\nLegge il valore di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `scope` | `Object|Function|Boolean` | no |  | Un oggetto legge il path relativamente a quell'oggetto. Una funzione attende che il valore non sia `null` e poi lo riceve. `true` reimposta lo stato dei componenti sul path. |\n\nReturns: `Object` Il valore, oppure `undefined` quando il path non ha un valore. Con una funzione come secondo argomento non viene restituito nulla.\n\nIl path può essere seguito da flag. `@clone` restituisce una copia, `@reset` reimposta lo stato dei componenti dopo la lettura e `@modified` restituisce solo i valori dei componenti modificati.\n\nExample: Leggi un valore\n```js\nSET('user', { name: 'Peter', age: 30 });\nconsole.log(GET('user.age')); // 30\nconsole.log(GET('name', { name: 'Anna' })); // Anna\n```\n\nExample: Attendi un valore\n```js\nGET('settings.theme', function(value) {\n\tconsole.log(value); // dark\n});\nsetTimeout(() => SET('settings.theme', 'dark'), 100);\n```\n\n### GUID([size])\n\nType: `method`\n\nCrea un identificatore casuale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `size` | `Number` | no |  | La lunghezza. Senza di essa, l'identificatore ha 36 caratteri nella forma di un UUID. |\n\nReturns: `String` L'identificatore.\n\nExample: Crea identificatori\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value, [unsigned])\n\nType: `method`\n\nCrea un numero da un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore. |\n| `unsigned` | `Boolean` | no | `true` | Con `false`, il risultato può essere negativo. |\n\nReturns: `Number` L'hash.\n\nGli oggetti vengono convertiti in hash in base alla loro forma JSON. Un numero viene restituito così com'è, un booleano diventa `0` o `1` e una data diventa il suo valore temporale.\n\nExample: Calcola l'hash di una stringa\n```js\nconsole.log(HASH('abc')); // 96354\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nIndica se un elemento non è visualizzato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'elemento. |\n\nReturns: `Boolean` Il risultato. Un elemento mancante restituisce `true`.\n\nExample: Controlla un elemento\n```html\n<div id=\"a\" style=\"display:none\"><span></span></div>\n<script>\nconsole.log(HIDDEN($('#a')[0].firstChild)); // true\nconsole.log(HIDDEN(null)); // true\n</script>\n```\n\n### IMPORT(url, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nCarica nella pagina uno script, uno stile o dell'HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String|Array` | yes |  | L'URL. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Dove inserire l'HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Con `false`, sostituisce il contenuto della destinazione. |\n| `preparator` | `Function` | no |  | `function(response, output)` modifica l'HTML prima dell'inserimento. |\n\nL'argomento è spiegato in [Importare contenuti](../../guides/importing/). Un array di URL viene caricato un elemento alla volta. Un URL che inizia con `once ` o `!` viene caricato una sola volta, e `<path>` prima dell'URL salta l'importazione quando il path ha un valore. La callback riceve `1` dopo il caricamento e `0` quando non è stato caricato nulla.\n\nExample: Importa HTML\n```html\n<div id=\"target\"></div>\n<script>\nIMPORT('/parts/hello.html', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nFunziona come [IMPORT()](#import) e memorizza nella cache l'HTML importato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `expire` | `String` | yes |  | Ad esempio `5 minutes` o `session`. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Dove inserire l'HTML. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | Con `false`, sostituisce il contenuto della destinazione. |\n| `preparator` | `Function` | no |  | `function(response, output)` modifica l'HTML prima dell'inserimento. |\n\nExample: Importa e memorizza nella cache\n```html\n<div id=\"target\"></div>\n<script>\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### INC(path, [value], [delay], [reset])\n\nType: `method`\n\nAggiunge un numero al valore su un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Number` | no | `1` | Il numero da aggiungere. |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n| `reset` | `Boolean` | no |  | Con `true`, i componenti sul path vengono anche contrassegnati come non toccati e non modificati. |\n\nUn valore mancante o che non è un numero conta come `0`.\n\nExample: Incrementa un contatore\n```js\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 6\n```\n\n### inDOM(element)\n\nType: `method`\n\nIndica se un elemento si trova all'interno del body della pagina.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | L'elemento. |\n\nReturns: `Boolean` `true`, oppure `undefined` quando l'elemento è fuori dal body.\n\nExample: Controlla un elemento\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(inDOM(document.createElement('div')) === undefined); // true\n```\n\n### isIE\n\nType: `property`\n\n`true` in Internet Explorer.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(isIE)); // boolean\n```\n\n### isMOBILE\n\nType: `property`\n\n`true` su un dispositivo mobile.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(isMOBILE)); // boolean\n```\n\n### isPRIVATEMODE\n\nType: `property`\n\n`true` quando l'archiviazione del browser non è disponibile.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(isPRIVATEMODE)); // boolean\n```\n\n### isROBOT\n\nType: `property`\n\n`true` quando lo user agent sembra quello di un robot.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(isROBOT)); // boolean\n```\n\n### isSTANDALONE\n\nType: `property`\n\n`true` quando la pagina viene eseguita come applicazione installata.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(isSTANDALONE)); // boolean\n```\n\n### isTOUCH\n\nType: `property`\n\n`true` su un dispositivo con schermo tattile.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(isTOUCH)); // boolean\n```\n\n### jComponent\n\nType: `property`\n\nUn altro nome di `MAIN`. Consulta [MAIN](../main/).\n\nExample: Leggi il valore\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### LOCALIZE(text)\n\nType: `method`\n\nAggiunge traduzioni al dizionario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Le traduzioni. |\n\nOgni riga ha la forma `key : value` e una riga che inizia con `//` viene saltata. I valori vengono memorizzati in `DEF.dictionary`. L'argomento è spiegato in [Localizzazione](../../guides/localization/).\n\nExample: Aggiungi traduzioni\n```js\nLOCALIZE('// Greetings\\nhello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### M\n\nType: `property`\n\nUn nome breve di `MAIN`. Consulta [M](../m/).\n\nExample: Leggi il valore\n```js\nconsole.log(M === MAIN); // true\n```\n\n### MACRO(name, declaration)\n\nType: `method`\n\nDichiara una macro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome della macro. |\n| `declaration` | `Function` | yes |  | `function(self, element, cls)`. |\n\nL'argomento è spiegato in [Macro](../../guides/macros/) e l'oggetto è descritto in [Macro](../macro/).\n\nExample: Dichiara una macro\n```js\nMACRO('upper', function(self, element) {\n\tself.setter = value => element.text((value || '').toUpperCase());\n});\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### MAIN\n\nType: `property`\n\nL'oggetto principale della libreria. Consulta [MAIN](../main/).\n\nExample: Leggi il valore\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### MAKE([target], fn, [update])\n\nType: `method`\n\nCostruisce un oggetto in una funzione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Object|String` | no |  | Un oggetto o un path. Senza di esso viene creato un nuovo oggetto. |\n| `fn` | `Function` | yes |  | `function(obj, path, set)`. |\n| `update` | `Boolean` | no | `true` | Con `false`, un oggetto esistente sul path viene riscritto senza reimpostare i suoi componenti. |\n\nReturns: `Object` L'oggetto.\n\nUna destinazione di tipo stringa è un path: l'oggetto sul path viene modificato, oppure ne viene creato uno nuovo e scritto lì. La funzione riceve l'oggetto, il path e una funzione `set(path, value)`.\n\nExample: Costruisci un oggetto\n```js\nvar obj = MAKE(function(o) {\n\to.name = 'Peter';\n});\nconsole.log(obj); // {\"name\":\"Peter\"}\n```\n\nExample: Costruisci un oggetto su un path\n```js\nMAKE('user', function(o, path, set) {\n\to.name = 'Peter';\n\tset('address.city', 'Bratislava');\n});\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"address\":{\"city\":\"Bratislava\"}}\n```\n\n### MIDDLEWARE(name, fn)\n\nType: `method`\n\nDichiara un middleware delle rotte. Consulta [Routing](../../guides/routing/).\n\n### MODIFIED(path, [flags])\n\nType: `method`\n\nElenca i path dei componenti toccati e modificati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita la ricerca a quei componenti. |\n\nReturns: `Array` I path dei componenti modificati.\n\nExample: Elenca i campi modificati\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n});\n```\n\n### MONTHS\n\nType: `property`\n\nI nomi dei mesi.\n\nExample: Leggi il valore\n```js\nconsole.log(MONTHS[11]); // December\n```\n\n### NAV\n\nType: `property`\n\nL'oggetto router. Consulta [Routing](../../guides/routing/).\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` | `Element|jQuery` | yes |  | L'elemento. |\n\nReturns: `Number` L'indice.\n\nExample: Leggi la posizione\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, target, [before])\n\nType: `method`\n\nPosiziona un elemento dopo o prima di un altro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'elemento da spostare. |\n| `target` | `Element|jQuery` | yes |  | L'elemento di riferimento. |\n| `before` | `Boolean` | no |  | Con `true`, lo posiziona prima della destinazione. |\n\nExample: Sposta un elemento\n```html\n<ul><li id=\"a\">A</li><li>B</li><li id=\"c\">C</li></ul>\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 elementi fratelli.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'elemento. |\n| `up` | `Boolean` | no |  | Con `true`, lo sposta verso l'alto. Altrimenti lo sposta verso il basso. |\n\nExample: Sposta un elemento verso l'alto\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BA\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nUna funzione che non fa nulla.\n\nExample: Usala come callback vuota\n```js\nconsole.log(NOOP() === undefined); // true\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nIndica se la pagina è in background.\n\nReturns: `Boolean` Il risultato.\n\nExample: Controlla la pagina\n```js\nconsole.log(typeof(NOTFOCUSED())); // boolean\n```\n\n### NOTIFY(...paths)\n\nType: `method`\n\nAggiorna i componenti e gli osservatori di path esatti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...paths` | `String` | yes |  | Uno o più path. |\n\nVengono aggiornati solo i componenti il cui path è esattamente lo stesso.\n\nExample: Notifica un osservatore\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nwindow.user = { name: 'Peter' };\nNOTIFY('user.name');\n```\n\n### NOTMODIFIED(path, [value], [fields])\n\nType: `method`\n\nIndica se un valore è uguale a quello dell'ultimo controllo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, oppure una chiave qualsiasi quando viene fornito `value`. |\n| `value` | `Object` | no |  | Il valore da confrontare. Senza di esso viene usato il valore del path. |\n| `fields` | `Array` | no |  | Confronta solo questi campi. |\n\nReturns: `Boolean` `true` quando il valore non è cambiato.\n\nIl primo controllo di un path restituisce `false`. Il valore viene confrontato tramite un hash della sua forma JSON.\n\nExample: Evita il lavoro quando non è cambiato nulla\n```js\nconsole.log(NOTMODIFIED('list', [1, 2])); // false\nconsole.log(NOTMODIFIED('list', [1, 2])); // true\nconsole.log(NOTMODIFIED('list', [1, 2, 3])); // false\n```\n\n### NOW\n\nType: `property`\n\nLa data corrente, aggiornata ogni minuto.\n\nExample: Leggi il valore\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path, [delay])\n\nType: `method`\n\nScrive `null` in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n\n`NULL()` è la stessa funzione.\n\nExample: Svuota un valore\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### NULL(path, [delay])\n\nType: `method`\n\nLa stessa funzione di [NUL()](#nul).\n\nExample: Stessa funzione\n```js\nconsole.log(NULL === NUL); // true\n```\n\n### OFF(name, [path], [fn])\n\nType: `method`\n\nRimuove i gestori di un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `path` | `String|Function` | no |  | Il path, oppure il gestore quando il path non serve. |\n| `fn` | `Function` | no |  | Il gestore. |\n\nPuoi separare più eventi con `+`. La forma `owner#name` rimuove i gestori di quel proprietario e `owner#` li rimuove tutti.\n\nExample: Rimuovi un gestore\n```js\nvar fn = () => console.log('never');\nON('ping', fn);\nOFF('ping', fn);\nconsole.log(EMIT('ping')); // false\n```\n\nExample: Rimuovi i gestori di un proprietario\n```js\nON('shop#ping', () => console.log('never'));\nOFF('shop#');\nconsole.log(EMIT('ping')); // false\n```\n\n### ON(name, [path], fn, [init])\n\nType: `method`\n\nRegistra un gestore di un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `path` | `String` | no |  | Il path, per l'evento `watch`. |\n| `fn` | `Function` | yes |  | Il gestore. |\n| `init` | `Boolean` | no |  | Con l'evento `watch`, il gestore viene anche chiamato immediatamente. |\n\nIl nome può elencare più eventi separati da uno spazio o da ` + `. Un nome che inizia con `^` mette il gestore al primo posto. La forma `owner#name` assegna il gestore a un proprietario, così [OFF()](#off) può rimuoverlo in seguito. Il nome `@flag myflag` reagisce a un flag personalizzato su un path.\n\nL'evento `watch` funziona come [WATCH()](#watch) e usa `path` e `init`. Gli eventi della libreria sono elencati in [Eventi](../events/).\n\nExample: Ascolta un evento personalizzato\n```js\nON('cart.add', function(id, count) {\n\tconsole.log(id, count); // 15 2\n});\nEMIT('cart.add', 15, 2);\n```\n\nExample: Reagisci a un flag personalizzato\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.name Peter\n});\nSET('user.name @saved', 'Peter');\n```\n\n### OPT([obj], fn)\n\nType: `method`\n\nCostruisce un oggetto di opzioni con path annidati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | no |  | L'oggetto da riempire. Senza di esso viene creato un nuovo oggetto. |\n| `fn` | `Function` | yes |  | `function(set, scope)`. |\n\nReturns: `Object` L'oggetto.\n\nLa funzione riceve `set(path, value)` e `scope(prefix)`, che aggiunge un prefisso ai path successivi.\n\nExample: Costruisci le opzioni\n```js\nvar options = OPT(function(set, scope) {\n\tset('title', 'Users');\n\tscope('grid');\n\tset('limit', 20);\n});\nconsole.log(options); // {\"title\":\"Users\",\"grid\":{\"limit\":20}}\n```\n\n### PARSE(value, [date])\n\nType: `method`\n\nAnalizza un JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il JSON o un selettore. |\n| `date` | `Boolean` | no | `DEF.jsondate` | Converte le date ISO in oggetti `Date`. |\n\nReturns: `Object` Il valore.\n\nUna stringa che inizia con `#` o `.` è un selettore di un elemento che contiene JSON. Un JSON non valido restituisce `null` e un oggetto viene restituito così com'è.\n\nExample: Analizza del JSON\n```js\nconsole.log(PARSE('{\"id\":5}').id); // 5\nconsole.log(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d instanceof Date); // true\nconsole.log(PARSE('wrong')); // null\n```\n\n### PARSER(fn, [prepend])\n\nType: `method`\n\nRegistra un parser globale dei valori dei componenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | Con `true`, il parser viene eseguito per primo. |\n\nReturns: `Object` Il valore analizzato, quando la funzione esegue i parser.\n\nLa funzione deve sempre restituire il valore. Il parser integrato converte i tipi `number`, `currency`, `float`, `boolean`, `bool`, `date` e `datetime`. `PARSER(value, path, type, [format])` esegue tutti i parser registrati.\n\nExample: Analizza un valore\n```js\nconsole.log(PARSER('1 200.5', 'price', 'number')); // 1200.5\nconsole.log(PARSER('on', 'active', 'boolean')); // true\n```\n\n### PLUGIN(name, [fn], [init], [done])\n\nType: `method`\n\nDichiara un plugin o ne restituisce uno esistente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del plugin. |\n| `fn` | `Function` | no |  | `function(exports)`. |\n| `init` | `Function|String` | no |  | Viene eseguito prima della dichiarazione. Una stringa elenca i nomi dei middleware. |\n| `done` | `Function` | no |  | Viene chiamata quando il plugin è pronto. |\n\nReturns: `Plugin` Il plugin.\n\nL'argomento è spiegato in [Plugin](../../guides/plugins/) e l'oggetto è descritto in [Plugin](../plugin/).\n\nExample: Dichiara un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.count = 5;\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.users.count); // 5\n}, 500);\n```\n\n### PLUGINABLE(name, fn, [init])\n\nType: `method`\n\nRegistra un plugin che viene creato alla sua prima chiamata.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del plugin. |\n| `fn` | `Function|String` | yes |  | La dichiarazione o un URL. |\n| `init` | `Function|String` | no |  | Viene eseguito prima della dichiarazione. |\n\nLa dichiarazione può anche essere l'URL di un file che dichiara il plugin.\n\nExample: Crea un plugin su richiesta\n```js\nPLUGINABLE('reports', function(exports) {\n\texports.open = function() {\n\t\tconsole.log('opened'); // opened\n\t};\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.reports == null); // true\n\tEXEC('reports/open');\n}, 500);\n```\n\n### PLUGINS\n\nType: `property`\n\nUn oggetto con tutti i plugin creati, per nome.\n\nExample: Leggi un plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.limit = 10;\n});\nsetTimeout(function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n}, 500);\n```\n\n### PREF\n\nType: `property`\n\nLe preferenze utente memorizzate. Consulta [PREF](../pref/).\n\nExample: Leggi il valore\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.theme); // dark\n```\n\n### PUSH(path, value, [delay], [reset])\n\nType: `method`\n\nAggiunge un valore all'array su un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Object|Array` | yes |  | L'elemento o gli elementi da aggiungere. |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n| `reset` | `Boolean` | no |  | Con `true`, i componenti sul path vengono anche contrassegnati come non toccati e non modificati. |\n\nUn array come valore aggiunge ciascuno dei suoi elementi. Se il path non contiene un array, ne viene creato uno nuovo. Un path che inizia con `^` aggiunge all'inizio. Come con [SET()](#set), il primo argomento può essere una richiesta e `value` il path di destinazione.\n\nExample: Aggiungi degli elementi\n```js\nPUSH('tags', 'a');\nPUSH('tags', ['b', 'c']);\nPUSH('^tags', 'first');\nconsole.log(GET('tags')); // [\"first\",\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], obj)\n\nType: `method`\n\nAggiunge un oggetto a un URL come stringa di query.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'URL, facoltativamente con un metodo. |\n| `obj` | `Object` | yes |  | I valori. |\n\nReturns: `String` L'URL.\n\nI valori vuoti vengono saltati, gli array vengono uniti con una virgola e le date usano il formato ISO.\n\nExample: Costruisci un URL\n```js\nconsole.log(QUERIFY('GET /users/', { page: 2, tags: ['a', 'b'] })); // GET /users/?page=2&tags=a%2Cb\nconsole.log(QUERIFY({ q: 'x y' })); // ?q=x%20y\n```\n\n### QUEUE([name], fn)\n\nType: `method`\n\nEsegue le funzioni una dopo l'altra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Il nome della coda. |\n| `fn` | `Function` | yes |  | `function(next, pending)`. |\n\nReturns: `Number` Il numero di elementi in attesa.\n\nLa funzione riceve `next` e il numero di elementi in attesa. L'elemento successivo parte dopo la chiamata a `next()`.\n\nExample: Esegui in ordine\n```js\nQUEUE('tasks', function(next) {\n\tsetTimeout(next, 50);\n});\nQUEUE('tasks', function(next, pending) {\n\tconsole.log('second', pending); // second 0\n\tnext();\n});\n```\n\n### RECONFIGURE(selector, value)\n\nType: `method`\n\nModifica la configurazione di tutti i componenti corrispondenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selettore come in [FIND()](#find). |\n| `value` | `Object|String` | yes |  | La nuova configurazione. |\n\nExample: Cambia la configurazione\n```js\nON('ready', function() {\n\tRECONFIGURE('box', { size: 10 });\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### REDIRECT(url)\n\nType: `method`\n\nNaviga verso un URL. Consulta [Routing](../../guides/routing/).\n\n### REMOVECACHE(key)\n\nType: `method`\n\nRimuove un valore dalla cache del browser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La chiave. |\n\nExample: Rimuovi un valore\n```js\nCACHE('profile', 'Peter', '1 day');\nREMOVECACHE('profile');\nconsole.log(CACHE('profile') === undefined); // true\n```\n\n### REPEAT([condition], process, delay, [init])\n\nType: `method`\n\nEsegue una funzione ripetutamente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | no |  | La condizione. |\n| `process` | `Function` | yes |  | `function(counter, scope)`. |\n| `delay` | `Number` | yes |  | Il ritardo in millisecondi. |\n| `init` | `Boolean` | no |  | Con `true`, la prima esecuzione parte immediatamente. |\n\nLa condizione è una funzione o un path, e l'esecuzione viene saltata finché non è soddisfatta. Con la forma `path__expression`, l'espressione riceve la variabile `value`. Mentre la pagina è in background non viene eseguito nulla, a meno che `DEF.repeatfocus` non sia `false`.\n\nExample: Esegui ogni 100 ms\n```js\nREPEAT(function(counter) {\n\tif (counter === 3)\n\t\tconsole.log('third run'); // third run\n}, 100);\n```\n\n### REPO\n\nType: `property`\n\nUn oggetto vuoto per i tuoi dati condivisi.\n\nExample: Leggi il valore\n```js\nREPO.items = [1, 2];\nconsole.log(REPO.items.length); // 2\n```\n\n### RESET(path, [delay])\n\nType: `method`\n\nContrassegna i componenti su un path come non toccati e non modificati e li valida di nuovo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso. |\n| `delay` | `Number` | no |  | Un ritardo in millisecondi. |\n\nExample: Reimposta un modulo\n```js\nON('ready', function() {\n\tSET('form.name', 'Peter');\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n\tRESET('form.*');\n\tconsole.log(MODIFIED('form.*').length); // 0\n});\n```\n\n### RETURN(command, [multiple])\n\nType: `method`\n\nLegge una proprietà di un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `command` | `String` | yes |  | Il selettore e la proprietà. |\n| `multiple` | `Boolean` | no |  | Con `true`, legge da tutti i componenti corrispondenti. |\n\nReturns: `Object|Array` Il valore, oppure un array con `multiple`.\n\nIl comando ha la forma `selector/property`.\n\nExample: Leggi una proprietà\n```js\nON('ready', function() {\n\tconsole.log(RETURN('box/title')); // Box\n\tconsole.log(RETURN('box/title', true)); // [\"Box\"]\n});\n```\n\n### REWRITE(path, value, [type])\n\nType: `method`\n\nScrive un valore senza aggiornare i componenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `type` | `Number` | no |  | Il tipo di modifica passato agli osservatori. |\n\nLe associazioni dei dati e gli osservatori vengono comunque eseguiti. Usa il flag `@nowatch` per saltare gli osservatori.\n\nExample: Scrivi senza aggiornare i componenti\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nREWRITE('user.name', 'Peter');\n```\n\n### REWRITE2(path, value, [type])\n\nType: `method`\n\nScrive un valore senza aggiornare i componenti o le associazioni dei dati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `type` | `Number` | no |  | Il tipo di modifica passato agli osservatori. |\n\nGli osservatori vengono comunque eseguiti.\n\nExample: Scrivi senza associazioni\n```js\nREWRITE2('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\n```\n\n### ROUTE(url, fn, [middleware], [init])\n\nType: `method`\n\nDichiara una rotta. Consulta [Routing](../../guides/routing/).\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\nLe opzioni:\n\n| Opzione | Tipo | Descrizione |\n| --- | --- | --- |\n| `orientation` | String | `x` o `y`. Senza di essa, entrambe le direzioni |\n| `visibleX`, `visibleY` | Boolean | Mantiene visibile la barra di scorrimento |\n| `native` | Boolean | Usa la barra di scorrimento del browser |\n| `wrap` | Boolean | Con `false`, il contenuto non viene racchiuso |\n| `controls` | jQuery | L'elemento per i controlli della barra di scorrimento |\n| `shadow` | Boolean | Aggiunge ombre ai bordi |\n| `padding` | Number | Il padding delle barre. Valore predefinito: `5` |\n| `minsize` | Number | La dimensione minima di una barra. Valore predefinito: `50` |\n| `thickness` | Number | Lo spessore di una barra. Valore predefinito: `10` |\n| `margin`, `marginX`, `marginY` | Number | I margini |\n| `offsetX`, `offsetY` | Number | Aggiunti alla dimensione della vista |\n| `parent` | String o Element | Prende la dimensione da questo genitore |\n| `autoresize` | Boolean | Con `false`, la dimensione non viene controllata al ridimensionamento |\n| `interval` | Number | L'intervallo del controllo della dimensione |\n| `onscroll`, `onidle`, `onresize` | Function | Gestori che ricevono la barra di scorrimento |\n\nL'oggetto restituito ha i metodi `scrollTop([value])`, `scrollLeft([value])`, `scrollBottom([value])`, `scrollRight([value])`, `scroll(x, y)`, `resize()`, `check()`, `sync(element, [offset])`, `unsync()` e `destroy()`.\n\nExample: Crea una barra di scorrimento\n```html\n<div id=\"box\" style=\"height:100px\"><div style=\"height:500px\"></div></div>\n<script>\nvar scrollbar = SCROLLBAR($('#box'), { orientation: 'y' });\nconsole.log(typeof(scrollbar.scrollTop)); // function\nconsole.log(M.scrollbars.length); // 1\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nRestituisce la larghezza in pixel della barra di scorrimento del browser.\n\nReturns: `Number` La larghezza.\n\nExample: Leggi la larghezza\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(target, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione o scrive un valore, a seconda della destinazione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Function|String` | yes |  | Una funzione, un metodo o un 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\nUna funzione viene chiamata. Una stringa con `/`, o un path che contiene una funzione, viene passata a [EXEC()](#exec). Qualsiasi altra stringa è un path, in cui viene scritto il primo argomento.\n\nExample: Funzione o path\n```js\nSEEX(value => console.log(value), 1); // 1\nSEEX('result.value', 2);\nconsole.log(GET('result.value')); // 2\n```\n\n### SET(path, value, [delay], [reset])\n\nType: `method`\n\nScrive un valore in un path e aggiorna tutto ciò che è associato a esso.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n| `reset` | `Boolean` | no |  | Con `true`, i componenti sul path vengono anche contrassegnati come non toccati e non modificati. |\n\nI componenti, le associazioni e gli osservatori sul path vengono aggiornati. Il terzo argomento può anche essere `true`, che reimposta subito lo stato dei componenti.\n\nUn path che inizia con `+` aggiunge il valore a un array come [PUSH()](#push). Un path che inizia con `~` lo unisce come [EXT()](#ext). Il path può essere seguito da flag: consulta [Flag e modificatori di path](../../guides/flags/).\n\nQuando il primo argomento è una richiesta come `GET /api/users/`, la risposta viene scritta nel path indicato come `value`.\n\nExample: Scrivi un valore\n```js\nSET('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\nExample: Ritarda la scrittura\n```js\nSET('search', 'first', 100);\nSET('search', 'second', 100);\nsetTimeout(function() {\n\tconsole.log(GET('search')); // second\n}, 300);\n```\n\nExample: Memorizza una risposta\n```js\nSET('GET /api/users/', 'users.response');\nsetTimeout(function() {\n\tconsole.log(GET('users.response.url')); // /api/users/\n}, 200);\n```\n\n### SETTER(selector, method, [...args])\n\nType: `method`\n\nChiama un metodo di tutti i componenti corrispondenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selettore come in [FIND()](#find). |\n| `method` | `String` | yes |  | Il nome del metodo. |\n| `...args` | `Object` | no |  | Gli argomenti del metodo. |\n\nIl selettore e il metodo possono essere uniti come `selector/method`. Con `true` come primo argomento, la chiamata attende il componente. Un selettore che inizia con `!` non avvia un componente lazy.\n\nExample: Chiama un metodo\n```js\n// The component logs 'Hello ' + name\nON('ready', function() {\n\tSETTER('box', 'hello', 'Peter');\n\tSETTER('box/hello', 'Anna');\n});\n```\n\n### setTimeout2(name, fn, delay, [limit], [arg])\n\nType: `method`\n\nAvvia un timer con nome e annulla il timer precedente con lo stesso nome.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del timer. |\n| `fn` | `Function` | yes |  | La funzione. |\n| `delay` | `Number` | yes |  | Il ritardo in millisecondi. |\n| `limit` | `Number` | no |  | Quante volte il timer può essere posticipato. |\n| `arg` | `Object` | no |  | L'argomento della funzione. |\n\nReturns: `String` Il nome del timer.\n\nCon un limite, il timer viene posticipato al massimo quel numero di volte, quindi la funzione viene eseguita anche in presenza di chiamate continue.\n\nExample: Mantieni solo l'ultima chiamata\n```js\nfunction search(value) {\n\tconsole.log(value); // last\n}\nsetTimeout2('search', search, 50, null, 'first');\nsetTimeout2('search', search, 50, null, 'last');\n```\n\n### STOPDEBUG()\n\nType: `method`\n\nContinua a mettere in pausa il debugger del browser finché gli strumenti per sviluppatori sono aperti.\n\nLa funzione si ripete ogni 5 secondi e non può essere interrotta.\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 | `DEF.jsoncompress` | Comprime l'output. |\n| `fields` | `Array|Object|Function` | no |  | Un array di campi consentiti, un oggetto con `field: false`, oppure `function(key, value)`. |\n| `encrypt` | `Boolean` | no |  | Cifra l'output con la chiave di `DEF.secret()`. |\n\nReturns: `String` Il JSON.\n\nLa compressione elimina gli spazi all'inizio e alla fine delle stringhe e rimuove le stringhe vuote, `false` e `null`.\n\nExample: Serializza un valore\n```js\nconsole.log(STRINGIFY({ a: 1, b: '', c: false }, true)); // {\"a\":1}\nconsole.log(STRINGIFY({ a: 1, b: 2 }, false, ['b'])); // {\"b\":2}\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 dello stile. L'elemento riceve l'id `css` seguito da questo valore. |\n| `selector` | `String` | no |  | Un selettore che racchiude le regole. |\n\nUno stile esistente con lo stesso identificatore viene sostituito. Prima di ogni regola viene aggiunto un selettore. `CSS()` è la stessa funzione.\n\nExample: Aggiungi CSS con scope\n```js\nSTYLE('b { color: red }', 'mystyle', '#panel');\nconsole.log($('#cssmystyle').html()); // #panel b{ color: red }\n```\n\n### Ta\n\nType: `property`\n\nUn nome breve di `Tangular`.\n\nExample: Leggi il valore\n```js\nconsole.log(Ta === Tangular); // true\n```\n\n### Tangular\n\nType: `property`\n\nIl motore di template. Consulta [Template con Tangular](../../guides/tangular/).\n\nExample: Leggi il valore\n```js\nconsole.log(Tangular.render('Hello {{ name }}', { name: 'Peter' })); // Hello Peter\n```\n\n### TAPI(name, [data], [callback])\n\nType: `method`\n\nChiama un'API con [DAPI()](#dapi) quando `DEF.api` è impostato, altrimenti con [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dello schema. |\n| `data` | `Object` | no |  | I dati. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, oppure un path. |\n\nReturns: `Object|Promise` Il risultato della funzione selezionata.\n\nExample: Seleziona il trasporto\n```js\nDEF.api = '/api/';\nTAPI('users_list', null, function(response) {\n\tconsole.log(response.url); // /api/\n});\n```\n\n### TEMP\n\nType: `property`\n\nUn oggetto per i dati temporanei.\n\nLa libreria lo sostituisce con un oggetto vuoto ogni cinque minuti.\n\nExample: Leggi il valore\n```js\nTEMP.value = 5;\nconsole.log(TEMP.value); // 5\n```\n\n### Thelpers\n\nType: `property`\n\nGli helper del motore di template. Consulta [Helper di Tangular](../tangular-helpers/).\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(Thelpers)); // object\n```\n\n### TOGGLE(path, [delay], [reset])\n\nType: `method`\n\nScrive in un path il valore booleano opposto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n| `reset` | `Boolean` | no |  | Con `true`, i componenti sul path vengono anche contrassegnati come non toccati e non modificati. |\n\nExample: Inverti un valore\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### TRANSLATE(text)\n\nType: `method`\n\nSostituisce ogni `@(text)` con la sua traduzione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Il testo. |\n\nReturns: `String` Il testo tradotto.\n\nLa chiave in `DEF.dictionary` è `HASH(text).toString(36)`, facoltativamente con il prefisso `T`. Un testo senza traduzione resta nella lingua originale.\n\nExample: Traduci un testo\n```js\nDEF.dictionary[HASH('Hello').toString(36)] = 'Ahoj';\nconsole.log(TRANSLATE('@(Hello), @(Peter)')); // Ahoj, Peter\n```\n\n### UNAUTHORIZED(...roles)\n\nType: `method`\n\nIndica se all'utente corrente mancano tutti i ruoli indicati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...roles` | `String` | yes |  | I ruoli. |\n\nReturns: `Boolean` `true` quando l'utente non ha nessuno dei ruoli.\n\nL'utente viene letto da `window.user`. I campi `sa` e `su` consentono tutto, e i ruoli provengono da `permissions` o `roles`, come array o come oggetto.\n\nExample: Controlla un ruolo\n```js\nwindow.user = { roles: ['editor'] };\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [fn])\n\nType: `method`\n\nRimuove un osservatore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path osservato. |\n| `fn` | `Function` | no |  | La funzione passata a [WATCH()](#watch). |\n\nSenza una funzione, vengono rimossi tutti gli osservatori del path.\n\nExample: Smetti di osservare\n```js\nvar count = 0;\nvar fn = () => count++;\nWATCH('value', fn);\nSET('value', 1);\nUNWATCH('value', fn);\nSET('value', 2);\nconsole.log(count); // 1\n```\n\n### UPD(path, [delay], [reset])\n\nType: `method`\n\nComunica alla libreria che il valore su un path è cambiato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path del valore. Consulta [Path](../../guides/paths/). |\n| `delay` | `Number` | no |  | Un numero pari o superiore a 10 ritarda la modifica di altrettanti millisecondi. Un numero inferiore è il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n| `reset` | `Boolean` | no |  | Con `true`, i componenti sul path vengono anche contrassegnati come non toccati e non modificati. |\n\nUsala dopo aver modificato direttamente un oggetto. I componenti vengono aggiornati e gli osservatori vengono chiamati. `UPDATE()` è la stessa funzione. Il secondo argomento può anche essere `true`, che reimposta lo stato dei componenti.\n\nExample: Aggiorna dopo una modifica diretta\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nUPD('user.name');\n```\n\n### UPDATE(path, [delay], [reset])\n\nType: `method`\n\nLa stessa funzione di [UPD()](#upd).\n\nExample: Stessa funzione\n```js\nconsole.log(UPDATE === UPD); // true\n```\n\n### UPLOAD(url, data, [callback], [delay], [progress])\n\nType: `method`\n\nCarica dati su un server.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL, facoltativamente con un metodo. |\n| `data` | `FormData|Object` | yes |  | I dati. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, oppure un path. |\n| `delay` | `Number` | no |  | Attende questo numero di millisecondi prima dell'invio. |\n| `progress` | `Function|String` | no |  | `function(percentage)`, oppure un path. |\n\nReturns: `Promise` Solo quando non viene fornita una callback.\n\nIl metodo predefinito è `POST`. `FormData` viene inviato così com'è e qualsiasi altro dato come JSON. Senza callback, la funzione restituisce una Promise. `progress` può essere il quarto argomento quando non serve un ritardo.\n\nExample: Carica un file\n```js\nvar data = new FormData();\ndata.append('name', 'photo.jpg');\nUPLOAD('/api/upload/', data, function(response) {\n\tconsole.log(response.url); // /api/upload/\n});\n```\n\n### VALID(path, [flags])\n\nType: `method`\n\nIndica se nessun componente su un path è non valido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, facoltativamente con `.*` per tutto ciò che si trova sotto di esso. |\n| `flags` | `String|Array` | no |  | `visible` o `hidden` limita il controllo a quei componenti. |\n\nReturns: `Boolean` Il risultato.\n\nA differenza di [CAN()](#can), non verifica se i componenti sono stati toccati.\n\nExample: Controlla un modulo\n```js\nON('ready', function() {\n\tconsole.log(VALID('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tconsole.log(VALID('form.*')); // true\n});\n```\n\n### VBIND(html)\n\nType: `method`\n\nCrea un binder virtuale dall'HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | L'HTML con le associazioni. |\n\nReturns: `VBinder` Il binder virtuale.\n\nL'oggetto è descritto in [Binder virtuale](../vbinder/) e l'argomento in [Associazioni virtuali](../../guides/virtual-bindings/).\n\nExample: Associa un elemento separato dalla pagina\n```js\nvar binder = VBIND('<div><span data-bind=\"name__text\"></span></div>');\nbinder.set({ name: 'Peter' });\nconsole.log(binder.element.find('span').text()); // Peter\n```\n\n### VBINDARRAY(html, element)\n\nType: `method`\n\nRenderizza un array con un binder virtuale per ogni elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | L'HTML di un elemento. |\n| `element` | `Element|jQuery|Component` | yes |  | L'elemento genitore. |\n\nReturns: `Object` Un oggetto con i metodi `set()`, `get()`, `upd()` e `remove()`.\n\nL'argomento è spiegato in [Associazioni virtuali](../../guides/virtual-bindings/).\n\nExample: Renderizza un elenco\n```html\n<ul id=\"list\"></ul>\n<script>\nvar list = VBINDARRAY('<li data-bind=\"name__text\"></li>', $('#list'));\nlist.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log($('#list').text()); // PeterAnna\n</script>\n```\n\n### VERSION(...items)\n\nType: `method`\n\nSeleziona la versione dei componenti usati senza una versione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...items` | `String` | yes |  | I componenti e le loro versioni. |\n\nOgni elemento ha la forma `name@version` e una stringa può elencare più elementi separati da una virgola.\n\nExample: Seleziona una versione\n```html\n<ui-component name=\"tag\"></ui-component>\n<script>\nCOMPONENT('tag@2', function(self) {\n\tself.make = () => self.element.text('two');\n});\nVERSION('tag@2');\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // two\n});\n</script>\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nIndica se un elemento si trova nell'altezza visibile della finestra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | L'elemento. |\n| `threshold` | `Number` | no | `0` | Un margine in pixel. |\n| `mode` | `String` | no | `visible` | `visible`, `above` o `below`. |\n\nReturns: `Boolean` Il risultato.\n\nExample: Controlla un elemento\n```html\n<div id=\"box\">Box</div>\n<script>\nconsole.log(VISIBLE($('#box'))); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nUn nome breve di `window`.\n\nExample: Leggi il valore\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback, [interval], [timeout])\n\nType: `method`\n\nAttende che una condizione sia soddisfatta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | La funzione o il path da controllare. |\n| `callback` | `Function` | yes |  | `function(err, again)`. |\n| `interval` | `Number` | no | `500` | L'intervallo dei controlli in millisecondi. |\n| `timeout` | `Number` | no |  | L'attesa massima in millisecondi. |\n\nLa condizione è una funzione o un path. La callback riceve un errore dopo un timeout e una funzione che riavvia l'attesa. Senza un timeout, l'attesa non termina mai da sola.\n\nExample: Attendi un valore\n```js\nWAIT('app.ready', function() {\n\tconsole.log(GET('app.ready')); // true\n}, 50);\nsetTimeout(() => SET('app.ready', true), 100);\n```\n\nExample: Interrompi dopo un timeout\n```js\nWAIT(() => false, function(err) {\n\tconsole.log(err.message); // Timeout.\n}, 50, 200);\n```\n\n### WAPI([name], [data], [callback], [timeout])\n\nType: `method`\n\nChiama un'API tramite la connessione WebSocket.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | no |  | Il nome dello schema, oppure le opzioni di connessione. |\n| `data` | `Object` | no |  | I dati. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)`, oppure un path. |\n| `timeout` | `Number` | no | `10000` | Il timeout in millisecondi. |\n\nReturns: `Object|Promise` La connessione, oppure una Promise.\n\nUn oggetto come primo argomento apre la connessione come [WAPI_INIT()](#wapi-init). Senza argomenti, la funzione restituisce la connessione aperta. Senza callback, restituisce una Promise. Il timeout predefinito di una chiamata è di 10 secondi.\n\nExample: Chiama tramite un socket\n```js\nWAPI({ url: '/api/' });\nWAPI('users_list', null, function(response) {\n\tconsole.log(response.schema); // users_list\n});\n```\n\n### WAPI_INIT(options)\n\nType: `method`\n\nApre la connessione WebSocket usata da [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Le opzioni di connessione. |\n\nReturns: `Object` L'oggetto delle opzioni con i metodi aggiunti.\n\nLe opzioni sono `url`, `reconnect` (un ritardo in millisecondi, oppure `false`), `expire` (si riconnette trascorso questo tempo), `callback` (chiamata una volta dopo il primo tentativo di connessione) e i gestori `open`, `close(e)` e `message(data)`.\n\nL'oggetto restituito ha i metodi `send(name, data, callback, [timeout])`, `on(name, fn)` per gli eventi `open`, `close`, `message` e `reconnect`, `emit(name, ...)` e `pause(is)`.\n\nExample: Apri una connessione\n```js\nWAPI_INIT({\n\turl: '/api/',\n\topen: function() {\n\t\tconsole.log('connected'); // connected\n\t}\n});\nconsole.log(typeof(WAPI().send)); // function\n```\n\n### WARN(...args)\n\nType: `method`\n\nScrive un avviso nella console.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...args` | `Object` | yes |  | I valori da scrivere. |\n\nExample: Scrivi un avviso\n```js\nWARN('Disk is full');\nconsole.log(typeof(WARN)); // function\n```\n\n### WATCH(path, fn, [init])\n\nType: `method`\n\nChiama una funzione quando il valore su un path cambia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path da osservare. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n| `init` | `Boolean` | no |  | Con `true`, la funzione viene anche chiamata immediatamente. |\n\nLa funzione riceve il path modificato, il valore e il tipo di modifica: `0` chiamata iniziale, `1` manuale, `2` input, `3` predefinito. Un path `users.*` reagisce anche a tutto ciò che si trova sotto `users`. Puoi separare più path con uno spazio, e un path che inizia con `^` viene eseguito prima degli altri osservatori.\n\nExample: Reagisci a una modifica\n```js\nWATCH('user.name', function(path, value, type) {\n\tconsole.log(path, value, type); // user.name Peter 1\n});\nSET('user.name', 'Peter');\n```\n\nExample: Chiamala immediatamente\n```js\nSET('count', 5);\nWATCH('count', function(path, value, type) {\n\tconsole.log(value, type); // 5 0\n}, true);\n```\n\n### WATCHONCE(path, fn)\n\nType: `method`\n\nChiama una funzione solo alla prossima modifica di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path da osservare. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n\nExample: Reagisci una sola volta\n```js\nWATCHONCE('count', function(path, value) {\n\tconsole.log(value); // 1\n});\nSET('count', 1);\nSET('count', 2);\n```\n\n### WH\n\nType: `property`\n\nL'altezza della finestra in pixel.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(WH)); // number\n```\n\n### WIDTH([element])\n\nType: `method`\n\nRestituisce la dimensione di visualizzazione della finestra o di un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | L'elemento. |\n\nReturns: `String` `xs`, `sm`, `md` o `lg`.\n\nI limiti si trovano in `DEF.devices`.\n\nExample: Leggi la dimensione di un elemento\n```html\n<div id=\"box\" style=\"width:1000px\"></div>\n<script>\nconsole.log(WIDTH($('#box'))); // md\n</script>\n```\n\n### WORKFLOW(declaration, [tasks], [callback])\n\nType: `method`\n\nEsegue passaggi con nome che si trasmettono un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `declaration` | `Function` | yes |  | `function($)`. |\n| `tasks` | `Object` | no |  | I passaggi per nome. |\n| `callback` | `Function` | no |  | `function(value, err, $)`. |\n\nReturns: `Object` Il workflow.\n\nL'oggetto passato alla dichiarazione e a ogni passaggio ha questi membri:\n\n| Membro | Descrizione |\n| --- | --- |\n| `push(name, fn)` | Aggiunge un passaggio: `function($, value)` |\n| `next(name, [value])` | Esegue un passaggio. Un nome sconosciuto termina il workflow |\n| `next2(name)` | Restituisce una callback che esegue il passaggio |\n| `done([value])` | Chiama la callback finale con il valore |\n| `invalid(err)` | Segnala un errore a `error` o alla callback finale |\n| `callback(fn)` | Sostituisce la callback finale |\n| `clone()` | Crea un workflow con gli stessi passaggi |\n| `destroy()` | Termina il workflow |\n| `value`, `current`, `prev` | Il valore, il passaggio corrente e il passaggio precedente |\n\nExample: Esegui due passaggi\n```js\nWORKFLOW(function($) {\n\t$.push('load', ($, value) => $.next('save', value + 1));\n\t$.push('save', ($, value) => $.done(value * 2));\n\t$.next('load', 1);\n}, function(value) {\n\tconsole.log(value); // 4\n});\n```\n\n### WW\n\nType: `property`\n\nLa larghezza della finestra in pixel.\n\nExample: Leggi il valore\n```js\nconsole.log(typeof(WW)); // number\n```\n","entries":[{"type":"method","name":"ACMD()","signature":"ACMD(name, [...args])","since":"","deprecated":false},{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"ADD()","signature":"ADD(value, [element], [config], [content])","since":"","deprecated":false},{"type":"method","name":"AEXEC()","signature":"AEXEC(path, [...args])","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], [callback], [delay])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHE()","signature":"AJAXCACHE(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHEREVIEW()","signature":"AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCONFIG()","signature":"AJAXCONFIG(name, fn)","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BIND()","signature":"BIND(path)","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(name, 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, [rebind])","since":"","deprecated":false},{"type":"method","name":"CAN()","signature":"CAN(path, [flags])","since":"","deprecated":false},{"type":"method","name":"CHANGE()","signature":"CHANGE(path, [value])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, callback)","since":"","deprecated":false},{"type":"method","name":"CL_INIT()","signature":"CL_INIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [nopath])","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], [e])","since":"","deprecated":false},{"type":"method","name":"COMPILE()","signature":"COMPILE([container])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], declaration, [dependencies])","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":"method","name":"DAPI()","signature":"DAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"method","name":"DEBUG()","signature":"DEBUG()","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DEFAULT()","signature":"DEFAULT(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"DISABLED()","signature":"DISABLED(path, [flags])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [...args])","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(value, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, [flags], [highlight])","since":"","deprecated":false},{"type":"method","name":"EVALUATE()","signature":"EVALUATE(path, expression, [nopath])","since":"","deprecated":false},{"type":"method","name":"EXE()","signature":"EXE([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXT()","signature":"EXT(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTEND()","signature":"EXTEND(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], declaration)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [many], [nocache], [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(expression)","since":"","deprecated":false},{"type":"method","name":"FORMATTER()","signature":"FORMATTER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE([delay])","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [scope])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([size])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value, [unsigned])","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"IMPORTCACHE()","signature":"IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value], [delay], [reset])","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":"method","name":"MACRO()","signature":"MACRO(name, declaration)","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"method","name":"MAKE()","signature":"MAKE([target], fn, [update])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, fn)","since":"","deprecated":false},{"type":"method","name":"MODIFIED()","signature":"MODIFIED(path, [flags])","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"property","name":"NAV","signature":"NAV","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, target, [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":"method","name":"NOTIFY()","signature":"NOTIFY(...paths)","since":"","deprecated":false},{"type":"method","name":"NOTMODIFIED()","signature":"NOTMODIFIED(path, [value], [fields])","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"NULL()","signature":"NULL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [path], [fn])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, [path], fn, [init])","since":"","deprecated":false},{"type":"method","name":"OPT()","signature":"OPT([obj], fn)","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value, [date])","since":"","deprecated":false},{"type":"method","name":"PARSER()","signature":"PARSER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [fn], [init], [done])","since":"","deprecated":false},{"type":"method","name":"PLUGINABLE()","signature":"PLUGINABLE(name, fn, [init])","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, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], obj)","since":"","deprecated":false},{"type":"method","name":"QUEUE()","signature":"QUEUE([name], fn)","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT(url)","since":"","deprecated":false},{"type":"method","name":"REMOVECACHE()","signature":"REMOVECACHE(key)","since":"","deprecated":false},{"type":"method","name":"REPEAT()","signature":"REPEAT([condition], process, delay, [init])","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path, [delay])","since":"","deprecated":false},{"type":"method","name":"RETURN()","signature":"RETURN(command, [multiple])","since":"","deprecated":false},{"type":"method","name":"REWRITE()","signature":"REWRITE(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"REWRITE2()","signature":"REWRITE2(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"ROUTE()","signature":"ROUTE(url, fn, [middleware], [init])","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(target, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, fn, delay, [limit], [arg])","since":"","deprecated":false},{"type":"method","name":"STOPDEBUG()","signature":"STOPDEBUG()","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":"property","name":"Ta","signature":"Ta","since":"","deprecated":false},{"type":"property","name":"Tangular","signature":"Tangular","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"property","name":"Thelpers","signature":"Thelpers","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...roles)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [fn])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPDATE()","signature":"UPDATE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPLOAD()","signature":"UPLOAD(url, data, [callback], [delay], [progress])","since":"","deprecated":false},{"type":"method","name":"VALID()","signature":"VALID(path, [flags])","since":"","deprecated":false},{"type":"method","name":"VBIND()","signature":"VBIND(html)","since":"","deprecated":false},{"type":"method","name":"VBINDARRAY()","signature":"VBINDARRAY(html, element)","since":"","deprecated":false},{"type":"method","name":"VERSION()","signature":"VERSION(...items)","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, [interval], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI()","signature":"WAPI([name], [data], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI_INIT()","signature":"WAPI_INIT(options)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...args)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, fn, [init])","since":"","deprecated":false},{"type":"method","name":"WATCHONCE()","signature":"WATCHONCE(path, fn)","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"method","name":"WORKFLOW()","signature":"WORKFLOW(declaration, [tasks], [callback])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammaB9IM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/globals/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Globálne funkcie","summary":"Funkcie a objekty, ktoré jComponent pridáva do objektu window.","markdown":"---\ntitle: \"Globálne funkcie\"\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/globals/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Globálne funkcie\n\n> Funkcie a objekty, ktoré jComponent pridáva do objektu window.\n\njComponent pridáva tieto funkcie a objekty do `window`, takže ich môžeš používať kdekoľvek bez importu. Ak sa chceš najprv dozvedieť, ako fungujú paths, prečítaj si [Paths](../../guides/paths/).\n\n## API\n\n### ACMD(name, [...args])\n\nType: `method`\n\nVytvorí funkciu, ktorá neskôr zavolá [CMD()](#cmd).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov príkazu. |\n| `...args` | `Object` | no |  | Prvé argumenty. |\n\nReturns: `Function` Funkcia, ktorá sa má zavolať.\n\nArgument vytvorenej funkcie sa pridá ako posledný argument príkazu.\n\nExample: Použi ako callback\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nACMD('refresh')(1);\n```\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPripraví importovaný text pre path a identifikátor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Hodnota pre `~PATH~` a `CLASS`. |\n| `id` | `String` | yes |  | Hodnota pre `~ID~`. |\n| `text` | `String` | yes |  | Text. |\n\nReturns: `String` Zmenený text.\n\nText sa preloží, premenné `--name--` sa nahradia, `~CDN~` sa zmení na `DEF.cdn`, `~PATH~` a `CLASS` sa zmenia na path a `~ID~` sa zmení na identifikátor.\n\nExample: Nahraď značky\n```js\nconsole.log(ADAPT('users', 'form1', '~PATH~ and ~ID~')); // users and form1\n```\n\n### ADD(value, [element], [config], [content])\n\nType: `method`\n\nPridá komponent na stránku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object|Array` | yes |  | Komponent. |\n| `element` | `Element|jQuery|Component` | no | `document.body` | Nadradený element. |\n| `config` | `Object|String` | no |  | Konfigurácia. |\n| `content` | `String` | no |  | Vnútorné HTML. |\n\nReťazec má tvar `name__path__config`. Úvodný znak `!` komponent preskočí, ak je už deklarovaný. Objekt môže mať polia `name`, `path`, `config`, `element` a `prepend`. Pole pridá viac komponentov.\n\nExample: Pridaj komponent\n```js\nADD('box__data.title__size:10');\nsetTimeout(function() {\n\tconsole.log(FIND('box').config.size); // 10\n}, 1200);\n```\n\n### AEXEC(path, [...args])\n\nType: `method`\n\nVytvorí funkciu, ktorá neskôr zavolá [EXEC()](#exec).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Cieľ. |\n| `...args` | `Object` | no |  | Prvé argumenty. |\n\nReturns: `Function` Funkcia, ktorá sa má zavolať.\n\nArgument vytvorenej funkcie sa pridá ako posledný argument.\n\nExample: Použi ako callback\n```js\nwindow.save = value => console.log(value); // 5\nAEXEC('save')(5);\n```\n\n### AJAX(url, [data], [callback], [delay])\n\nType: `method`\n\nOdošle požiadavku HTTP.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Metóda a URL. |\n| `data` | `Object|String` | no |  | Dáta. Požiadavka `GET` ich odošle v reťazci dotazu. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` alebo path. |\n| `delay` | `Number` | no |  | Pred odoslaním počká zadaný počet milisekúnd. |\n\nReturns: `Promise` Iba ak nie je zadaný callback.\n\nURL má tvar `METHOD /path/`. Za ňou môžu nasledovať ďalšie položky oddelené medzerou:\n\n| Položka | Význam |\n| --- | --- |\n| `!METHOD` | Odošle s požiadavkou cookies |\n| `{ \"Name\": \"value\" }` | Hlavičky požiadavky |\n| `<5 minutes>` | Uloží odpoveď do cache ako [AJAXCACHE()](#ajaxcache) |\n| `(name)` | Použije nastavenia z [AJAXCONFIG()](#ajaxconfig) |\n| `repeat` | Zopakuje požiadavku, keď server nie je dostupný |\n| `cancel` | Zruší predchádzajúcu nedokončenú požiadavku na rovnakú URL |\n| `urlencoded` | Odošle dáta ako formulár kódovaný pre URL |\n| `json` | Prijme iba odpoveď vo formáte JSON |\n| `error` | Odovzdá odpoveď funkcii [ERROR()](#error) |\n| `noencrypt`, `nodecrypt`, `nocsrf` | Preskočí šifrovanie, dešifrovanie alebo hlavičku CSRF |\n| `#id` | Pomenuje požiadavku pre `cancel` alebo čaká na zoznam kódov |\n| `@flag` | Vyšle vlastný flag |\n\nCallback dostane odpoveď, pri chybe stavový kód a objekt s podrobnosťami požiadavky. Callback v podobe reťazca je path, do ktorého sa odpoveď uloží. Bez callbacku funkcia vráti Promise, ktorý sa pri stave vyššom ako 399 zamietne.\n\nExample: Odošli dáta\n```js\nAJAX('POST /api/users/', { name: 'Peter' }, function(response, err) {\n\tconsole.log(response.method, response.url); // POST /api/users/\n\tconsole.log(response.body); // {\"name\":\"Peter\"}\n});\n```\n\nExample: Použi Promise\n```js\n(async function() {\n\tvar response = await AJAX('GET /api/users/');\n\tconsole.log(response.url); // /api/users/\n})();\n```\n\nExample: Spracuj chybu\n```js\nAJAX('GET /api/missing/', function(response, err) {\n\tconsole.log(err, response); // 404 Not found\n});\n```\n\n### AJAXCACHE(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nOdošle požiadavku a uloží odpoveď do cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Metóda a URL. |\n| `data` | `Object` | no |  | Dáta. |\n| `callback` | `Function|String` | yes |  | `function(response, cached)` alebo path. |\n| `expire` | `String` | yes |  | Napríklad `5 minutes` alebo `session`. |\n| `delay` | `Number` | no |  | Pred čítaním počká zadaný počet milisekúnd. |\n| `clear` | `Boolean` | no |  | S hodnotou `true` ignoruje uloženú odpoveď. |\n\nCallback dostane odpoveď a `true`, keď pochádza z cache. Hodnota `session` v `expire` uchováva odpoveď v pamäti až do opätovného načítania stránky.\n\nExample: Ulož odpoveď do cache\n```js\nAJAXCACHE('GET /api/users/', function(response, cached) {\n\tconsole.log('first', cached); // first false\n\tAJAXCACHE('GET /api/users/', function(response, cached) {\n\t\tconsole.log('second', cached); // second true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])\n\nType: `method`\n\nVráti odpoveď z cache a potom overí na serveri, či neexistuje novšia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Metóda a URL. |\n| `data` | `Object` | no |  | Dáta. |\n| `callback` | `Function|String` | yes |  | `function(response, cached, updated)` alebo path. |\n| `expire` | `String` | yes |  | Napríklad `5 minutes`. |\n| `delay` | `Number` | no |  | Pred čítaním počká zadaný počet milisekúnd. |\n| `clear` | `Boolean` | no |  | S hodnotou `true` ignoruje uloženú odpoveď. |\n\nKeď server vráti iné dáta, callback sa spustí znova s hodnotami `false` a `true` ako druhým a tretím argumentom.\n\nExample: Obnov odpoveď z cache\n```js\nAJAXCACHE('GET /api/time/', function() {\n\tAJAXCACHEREVIEW('GET /api/time/', function(response, cached, updated) {\n\t\tconsole.log(response.value, cached, updated === true); // 2 false true\n\t}, '5 minutes');\n}, '5 minutes');\n```\n\n### AJAXCONFIG(name, fn)\n\nType: `method`\n\nDeklaruje nastavenia, ktoré môže požiadavka použiť podľa názvu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov nastavení. |\n| `fn` | `Function` | yes |  | `function(options)`. |\n\nPožiadavka ich použije zápisom `(name)` vo svojej URL. Funkcia dostane možnosti požiadavky.\n\nExample: Pridaj hlavičku\n```js\nAJAXCONFIG('secure', function(options) {\n\toptions.headers['X-Token'] = 'abc';\n});\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-Token']); // abc\n\topt.respond({});\n});\nAJAX('GET /api/users/ (secure)', NOOP);\n```\n\n### API(url, [data], [callback])\n\nType: `method`\n\nZavolá koncový bod API Total.js.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Koncový bod a schéma. |\n| `data` | `Object` | no |  | Dáta. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` alebo path. |\n\nReturns: `Object|Promise` Objekt popísaný vyššie alebo Promise.\n\nURL má tvar `/api/ schema`. Požiadavka je typu `POST` a v tele obsahuje názov schémy a dáta. Bez callbacku funkcia vráti Promise. S callbackom vráti objekt s metódami `params(value)`, ktorá vyplní parametre schémy, a `data(value)`, ktorá nahradí dáta.\n\nExample: Zavolaj koncový bod\n```js\nAPI('/api/ users_save', { name: 'Peter' }, function(response) {\n\tconsole.log(response.url); // /api/\n\tconsole.log(response.body); // {\"schema\":\"users_save\",\"data\":{\"name\":\"Peter\"}}\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nNastaví vzhľad aplikácie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Premenné CSS a polia `dark` a `large`. |\n\nKaždé pole sa stane premennou CSS na `:root`. `dark` a `large` prepínajú triedy `ui-dark` a `ui-large` na elemente body. `color` je šesťmiestna hexadecimálna farba, ktorá nastaví aj `DEF.color` a premennú `--rgb`.\n\nExample: Použi tmavú tému\n```js\nAPPEARANCE({ dark: true, color: '#336699' });\nconsole.log($('#cssappearance').html()); // :root{--color:#336699;--rgb:51,102,153}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\n### ASETTER(selector, method, [...args])\n\nType: `method`\n\nVytvorí funkciu, ktorá neskôr zavolá [SETTER()](#setter).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor ako vo [FIND()](#find). |\n| `method` | `String` | yes |  | Názov metódy. |\n| `...args` | `Object` | no |  | Prvé argumenty metódy. |\n\nReturns: `Function` Funkcia, ktorá sa má zavolať.\n\nArgument vytvorenej funkcie sa pridá ako posledný argument metódy, takže sa hodí ako callback požiadavky.\n\nExample: Použi ako callback\n```js\nON('ready', function() {\n\tvar fn = ASETTER('box', 'hello');\n\tfn('Peter');\n\tconsole.log(typeof(fn)); // function\n});\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nPrečíta atribút `data-` z elementu alebo jeho rodičov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery|Event|Object` | yes |  | Zdroj. |\n| `name` | `String` | no | `id` | Názov atribútu. |\n\nReturns: `String` Hodnota.\n\nPri obyčajnom objekte vráti jeho pole s týmto názvom.\n\nExample: Prečítaj identifikátor\n```html\n<div id=\"row\" data-id=\"15\" data-type=\"user\"></div>\n<script>\nconsole.log(ATTRD($('#row'))); // 15\nconsole.log(ATTRD($('#row'), 'type')); // user\n</script>\n```\n\n### BIND(path)\n\nType: `method`\n\nObnoví dátové väzby path bez upozornenia komponentov alebo sledovačov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Array` | yes |  | Jeden path alebo zoznam paths. |\n\nExample: Obnov väzbu\n```html\n<span id=\"name\" data-bind=\"user.name__text\"></span>\n<script>\nSET('user', { name: 'Peter' });\nsetTimeout(function() {\n\tGET('user').name = 'Anna';\n\tBIND('user.name');\n\tsetTimeout(function() {\n\t\tconsole.log($('#name').text()); // Anna\n\t}, 300);\n}, 300);\n</script>\n```\n\n### BLOCKED(name, timeout, [callback])\n\nType: `method`\n\nObmedzí, ako často sa môže akcia spustiť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov akcie. |\n| `timeout` | `Number|String` | yes |  | Milisekundy alebo hodnota, napríklad `5 seconds`. |\n| `callback` | `Function` | no |  | Spustí sa, keď akcia nie je zablokovaná. |\n\nReturns: `Boolean` `true`, keď je akcia zablokovaná.\n\nPrvé volanie vráti `false` a zablokuje názov na zadaný čas. Blokovanie dlhšie ako 10 sekúnd sa uchováva v úložisku prehliadača.\n\nExample: Povoľ jedno volanie za sekundu\n```js\nconsole.log(BLOCKED('save', 1000)); // false\nconsole.log(BLOCKED('save', 1000)); // true\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nPrečíta alebo zapíše hodnotu v cache prehliadača.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Kľúč. |\n| `value` | `Object` | no |  | Hodnota na uloženie. |\n| `expire` | `String|Number` | no |  | Napríklad `1 day`, `session` alebo milisekundy. |\n\nReturns: `Object` Uložená hodnota.\n\nHodnota sa uloží iba s expiráciou. Hodnota `session` ju uchováva v pamäti až do opätovného načítania stránky.\n\nExample: Ulož hodnotu\n```js\nCACHE('profile', { name: 'Peter' }, '1 day');\nconsole.log(CACHE('profile')); // {\"name\":\"Peter\"}\n```\n\n### CACHEPATH(path, expire, [rebind])\n\nType: `method`\n\nUchováva hodnotu path v cache prehliadača.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `expire` | `String` | yes |  | Napríklad `1 month`. |\n| `rebind` | `Boolean` | no | `true` | S hodnotou `false` sa uložená hodnota neobnoví. |\n\nKaždá zmena path sa uloží a uložená hodnota sa pri ďalšej návšteve obnoví. V tvare `path__value` je výraz hodnotou, ktorá sa použije, keď nie je nič uložené.\n\nExample: Zapamätaj si hodnotu\n```js\nCACHEPATH('settings.theme', '1 month');\nSET('settings.theme', 'dark');\nconsole.log(CACHE('PATHS')); // {\"settings.theme\":\"dark\"}\n```\n\n### CAN(path, [flags])\n\nType: `method`\n\nZistí, či sa dá formulár odoslať.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním. |\n| `flags` | `String|Array` | no |  | `visible` alebo `hidden` obmedzí kontrolu na tieto komponenty. |\n\nReturns: `Boolean` Výsledok.\n\nVýsledok je `true`, keď sa používateľ dotkol aspoň jedného komponentu na path a žiadny nie je neplatný. Path bez komponentov tiež vráti `true`.\n\nExample: Povoľ tlačidlo na odoslanie\n```js\nON('ready', function() {\n\tconsole.log(CAN('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tCHANGE('form.name');\n\tconsole.log(CAN('form.*')); // true\n});\n```\n\n### CHANGE(path, [value])\n\nType: `method`\n\nOznačí komponenty na path ako dotknuté a zmenené.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Boolean` | no | `true` | S hodnotou `false` sa označenia odstránia. |\n\nExample: Označ pole ako zmenené\n```js\nON('ready', function() {\n\tCHANGE('form.age');\n\tconsole.log(MODIFIED('form.*')); // [\"form.age\"]\n});\n```\n\n### CL(name, callback)\n\nType: `method`\n\nPočká, kým sa načítajú zoznamy kódov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `callback` | `Function` | yes |  | Spustí sa, keď sú zoznamy pripravené. |\n\nViac názvov môžeš oddeliť čiarkou. Načítané hodnoty sa ukladajú do `DEF.cl`.\n\nExample: Počkaj na zoznam kódov\n```js\nCL_INIT('countries', next => next(['SK', 'CZ']));\nCL('countries', function() {\n\tconsole.log(DEF.cl.countries); // [\"SK\",\"CZ\"]\n});\n```\n\n### CL_INIT(name, source, [expire], [init])\n\nType: `method`\n\nDeklaruje, ako sa zoznam kódov načíta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `source` | `Function|String` | yes |  | Načítavač. |\n| `expire` | `String` | no |  | Po uplynutí tohto času sa zoznam načíta znova. |\n| `init` | `Boolean` | no |  | S hodnotou `true` načíta zoznam okamžite. |\n\nZdroj je funkcia, ktorá dostane `next(value)`, alebo reťazec. Reťazec začínajúci metódou HTTP ide do [AJAX()](#ajax) a každý iný reťazec do [TAPI()](#tapi). `CLINIT()` je tá istá funkcia.\n\nExample: Načítaj zoznam z URL\n```js\nCL_INIT('roles', 'GET /api/roles/', true);\nsetTimeout(function() {\n\tconsole.log(DEF.cl.roles.url); // /api/roles/\n}, 300);\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nZruší pomenovaný časovač.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov časovača. |\n\nReturns: `Boolean` `true`, keď časovač bežal.\n\nExample: Zruš časovač\n```js\nsetTimeout2('save', NOOP, 1000);\nconsole.log(clearTimeout2('save')); // true\nconsole.log(clearTimeout2('save')); // false\n```\n\n### CLINIT(name, source, [expire], [init])\n\nType: `method`\n\nRovnaká funkcia ako [CL_INIT()](#cl-init).\n\nExample: Rovnaká funkcia\n```js\nconsole.log(CLINIT === CL_INIT); // true\n```\n\n### CLONE(value, [nopath])\n\nType: `method`\n\nVytvorí hlbokú kópiu hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | Hodnota alebo path. |\n| `nopath` | `Boolean` | no |  | S hodnotou `true` sa reťazec vráti tak, ako je. |\n\nReturns: `Object` Kópia.\n\nReťazec sa považuje za path a naklonuje sa hodnota tohto path.\n\nExample: Naklonuj hodnotu\n```js\nSET('user', { name: 'Peter' });\nvar copy = CLONE('user');\ncopy.name = 'Anna';\nconsole.log(GET('user.name')); // Peter\nconsole.log(copy.name); // Anna\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nZnova načíta zoznamy kódov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `callback` | `Function` | no |  | Spustí sa po načítaní zoznamov. |\n\nViac názvov môžeš oddeliť čiarkou.\n\nExample: Znova načítaj zoznam\n```js\nvar count = 0;\nCL_INIT('numbers', next => next([++count]), true);\nsetTimeout(function() {\n\tCLRELOAD('numbers', function() {\n\t\tconsole.log(DEF.cl.numbers); // [2]\n\t});\n}, 100);\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nSpustí príkaz vo všetkých komponentoch, ktoré si ho zaregistrovali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov príkazu. |\n| `a` | `Object` | no |  | Až päť argumentov, `a` až `e`. |\n\nKomponenty registrujú príkazy pomocou `self.command()`.\n\nExample: Spusti príkaz\n```js\nON('ready', function() {\n\tCMD('box.ping', 5);\n});\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // box.ping 5\n});\n```\n\n### COMPILE([container])\n\nType: `method`\n\nVyhľadá na stránke nové komponenty a väzby.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Obmedzí vyhľadávanie na tento element. |\n\nZavolaj ju po ručnom pridaní HTML.\n\nExample: Skompiluj nové HTML\n```js\n$(document.body).append('<ui-component name=\"box\" path=\"data.new\"></ui-component>');\nCOMPILE();\nsetTimeout(function() {\n\tconsole.log(FIND('box').path); // data.new\n}, 500);\n```\n\n### COMPONENT(name, [config], declaration, [dependencies])\n\nType: `method`\n\nDeklaruje komponent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov komponentu. |\n| `config` | `String|Object` | no |  | Predvolená konfigurácia. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n| `dependencies` | `Array` | no |  | Súbory, ktoré sa majú importovať ako prvé, alebo názvy komponentov začínajúce na `@`. |\n\nViac názvov môžeš oddeliť čiarkou. Za názvom môže nasledovať verzia: `box@2`. Celú tému vysvetľuje [Vytváranie komponentov](../../guides/creating-components/) a objekt, ktorý deklarácia dostane, popisuje [Komponent](../component/).\n\nExample: Deklaruj komponent\n```html\n<ui-component name=\"hello\"></ui-component>\n<script>\nCOMPONENT('hello', 'name:World', function(self, config) {\n\tself.make = () => self.element.text('Hello ' + config.name);\n});\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // Hello World\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nVypíše komponenty na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path s voliteľnými flagmi. |\n\nReturns: `Array` Komponenty.\n\nPath sa píše bez `.*`. Flagy za path filtrujú zoznam: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` a `@enabled`.\n\nExample: Filtruj komponenty\n```js\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tSET('form.name', 'Peter');\n\tconsole.log(COMPONENTS('form @invalid').map(com => com.path)); // [\"form.age\"]\n});\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nNastaví konfiguráciu komponentov pred ich spustením.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Ktoré komponenty sa majú nakonfigurovať. |\n| `config` | `Object|String|Function` | yes |  | Konfigurácia alebo funkcia, ktorá ju vráti. |\n\nSelektor je názov komponentu, `.path`, `#id` alebo funkcia, ktorá dostane komponent a vráti logickú hodnotu. Časti oddelené medzerou sa musia zhodovať všetky a čiarka oddeľuje alternatívy. Zavolaj ju pred kompiláciou komponentov.\n\nExample: Nakonfiguruj podľa názvu\n```js\nCONFIG('box', { size: 10 });\nON('ready', function() {\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### COOKIES\n\nType: `property`\n\nObjekt na čítanie a zápis cookies.\n\nMá metódy `get(name)`, `set(name, value, expire, [samesite])` a `rem(name)`. `expire` je `Date` alebo hodnota, napríklad `1 day`.\n\nExample: Prečítaj hodnotu\n```js\nCOOKIES.set('theme', 'dark', '1 day');\nconsole.log(COOKIES.get('theme') === 'dark' || location.protocol === 'file:'); // true\n```\n\n### COPY(source, target)\n\nType: `method`\n\nSkopíruje polia jedného objektu do druhého.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | Objekt na čítanie. |\n| `target` | `Object` | yes |  | Objekt na zápis. |\n\nReturns: `Object` Cieľový objekt.\n\nObjekty vnútri zdroja sa naklonujú.\n\nExample: Skopíruj polia\n```js\nvar target = COPY({ a: 1 }, { b: 2 });\nconsole.log(target); // {\"b\":2,\"a\":1}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nRovnaká funkcia ako [STYLE()](#style).\n\nExample: Rovnaká funkcia\n```js\nconsole.log(CSS === STYLE); // true\n```\n\n### DAPI(name, [data], [callback])\n\nType: `method`\n\nZavolá koncový bod API nastavený v `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov schémy. |\n| `data` | `Object` | no |  | Dáta. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` alebo path. |\n\nReturns: `Object|Promise` To isté ako [API()](#api).\n\n`DEF.api` je URL alebo funkcia, ktorá dostane názov a dáta a vráti hodnotu pre [API()](#api).\n\nExample: Použi predvolený koncový bod\n```js\nDEF.api = '/api/';\nDAPI('users_list', null, function(response) {\n\tconsole.log(response.url, response.body.schema); // /api/ users_list\n});\n```\n\n### DAYS\n\nType: `property`\n\nNázvy dní, počnúc nedeľou.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(DAYS[0]); // Sunday\n```\n\n### DEBUG()\n\nType: `method`\n\nZapne režim ladenia.\n\nVolania chýbajúcich metód zapíšu do konzoly upozornenie a [API()](#api) pridá schému do URL. Režim sa nedá zapnúť po tom, čo `DEF.secret()` nastavil kľúč.\n\nExample: Upozorni na chýbajúcu metódu\n```js\nDEBUG();\nEXEC('missing.method');\nconsole.log('done'); // done\n```\n\n### DECRYPT(value, [key], [type])\n\nType: `method`\n\nDekóduje hodnotu z [ENCRYPT()](#encrypt).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Zakódovaná hodnota. |\n| `key` | `String` | no |  | Kľúč. |\n| `type` | `String` | no |  | Predpona hodnoty. |\n\nReturns: `Object` Hodnota alebo `undefined`, keď kľúč alebo predpona nesedí.\n\nJSON sa spätne prevedie na objekt.\n\nExample: Použi nesprávny kľúč\n```js\nvar token = ENCRYPT('Peter', 'secret');\nconsole.log(DECRYPT(token, 'secret')); // Peter\nconsole.log(DECRYPT(token, 'other') === undefined); // true\n```\n\n### DEF\n\nType: `property`\n\nKonfigurácia knižnice. Pozri [DEF](../def/).\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEFAULT(path, [delay], [reset])\n\nType: `method`\n\nObnoví predvolené hodnoty komponentov na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním, alebo `path__value`. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n| `reset` | `Boolean` | no | `true` | S hodnotou `false` sa stav komponentov zachová. |\n\nKomponent berie svoju predvolenú hodnotu z atribútu `default`. V tvare `path__value` sa do path namiesto toho ako predvolená hodnota zapíše výraz za dvoma podčiarkovníkmi.\n\nExample: Zapíš predvolený objekt\n```js\nDEFAULT('form.* __{ name: \"Peter\" }');\nsetTimeout(function() {\n\tconsole.log(GET('form')); // {\"name\":\"Peter\"}\n}, 100);\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nAktualizuje potomkov elementu tak, aby zodpovedali novému HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Rodič. |\n| `selector` | `String` | yes |  | Selektor potomkov. |\n| `html` | `String` | yes |  | Nové HTML. |\n| `attribute` | `String` | no |  | Atribút na porovnanie. |\n\nReturns: `Object` Počty `add`, `upd` a `rem`.\n\nPridajú alebo odstránia sa iba zmenení potomkovia. Potomkovia sa porovnávajú podľa svojho HTML alebo podľa hodnoty atribútu.\n\nExample: Aktualizuj zoznam\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n<script>\nvar result = DIFFDOM($('#list'), 'li', '<li>B</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log($('#list').text()); // BC\n</script>\n```\n\n### DISABLED(path, [flags])\n\nType: `method`\n\nOpak [CAN()](#can).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním. |\n| `flags` | `String|Array` | no |  | `visible` alebo `hidden` obmedzí kontrolu na tieto komponenty. |\n\nReturns: `Boolean` Výsledok.\n\nExample: Zakáž tlačidlo na odoslanie\n```js\nON('ready', function() {\n\tconsole.log(DISABLED('form.*')); // true\n});\n```\n\n### EMIT(name, [...args])\n\nType: `method`\n\nZavolá obslužné funkcie udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `...args` | `Object` | no |  | Argumenty odovzdané obslužným funkciám. |\n\nReturns: `Boolean` `true`, keď má udalosť aspoň jednu obslužnú funkciu.\n\nZa názvom môže nasledovať vlastný flag, napríklad `EMIT('ping @saved')`.\n\nExample: Vyšli udalosť\n```js\nON('hello', name => console.log(name)); // Peter\nconsole.log(EMIT('hello', 'Peter')); // true\nconsole.log(EMIT('unknown')); // false\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nZmrazené prázdne pole.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nZmrazený prázdny objekt.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nZakóduje hodnotu do hexadecimálneho reťazca podpísaného kľúčom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Hodnota. |\n| `key` | `String` | no |  | Kľúč. |\n| `type` | `String` | no |  | Predpona výsledku. |\n\nReturns: `String` Zakódovaná hodnota.\n\nHodnota je zakódovaná, nie silno zašifrovaná. Objekty sa prevedú na JSON.\n\nExample: Zakóduj a dekóduj\n```js\nvar token = ENCRYPT({ id: 5 }, 'secret');\nconsole.log(DECRYPT(token, 'secret')); // {\"id\":5}\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše premennú prostredia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Názov alebo objekt s hodnotami. |\n| `value` | `Object` | no |  | Hodnota. |\n\nReturns: `Object` Hodnota premennej.\n\nObjekt v prvom argumente zapíše viac premenných. Paths a URL čítajú premenné pomocou `[name]`. Premenné sa ukladajú do `DEF.environment`.\n\nExample: Použi premennú\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í názov, verziu a jazyk aplikácie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov aplikácie. |\n| `version` | `String` | no |  | Verzia. |\n| `language` | `String` | no |  | Jazyk importovaného HTML. |\n| `env` | `Object` | no |  | Premenné prostredia pre [ENV()](#env). |\n\nNázov oddeľuje úložisko prehliadača danej aplikácie. Nastavuje `DEF.localstorage`, `DEF.version` a `DEF.languagehtml`.\n\nExample: Pomenuj aplikáciu\n```js\nENVIRONMENT('shop', '1.2', 'en', { api: '/api/' });\nconsole.log(DEF.localstorage, DEF.version, ENV('api')); // shop 1.2 /api/\n```\n\n### ERROR(value, [success], [error])\n\nType: `method`\n\nZistí, či odpoveď obsahuje chybu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|Function` | yes |  | Odpoveď alebo obslužná funkcia úspechu. |\n| `success` | `Function|String` | no |  | Spustí sa, keď nenastala chyba. |\n| `error` | `Function|String` | no |  | Spustí sa, keď nastala chyba. |\n\nReturns: `Boolean|Function` `true`, keď je hodnota chybou, alebo vytvorený callback.\n\nZa chybu sa považuje `Error`, objekt s poľom `error` alebo pole, ktorého prvá položka toto pole má, a vyšle sa udalosť [ERROR](../events/#error-2). `success` a `error` sú funkcie alebo paths.\n\nS funkciou v prvom argumente vráti `ERROR(success, [error])` callback pre požiadavku.\n\nExample: Skontroluj odpoveď\n```js\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\nconsole.log(ERROR({ id: 5 })); // false\n```\n\nExample: Vytvor callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 5\n});\ncallback({ id: 5 });\n```\n\n### ERRORS(path, [flags], [highlight])\n\nType: `method`\n\nVypíše komponenty, ktoré sú dotknuté a neplatné.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním. |\n| `flags` | `String|Array` | no |  | `visible` alebo `hidden` obmedzí kontrolu na tieto komponenty. |\n| `highlight` | `Boolean` | no |  | Obnoví stav nájdených komponentov. |\n\nReturns: `Array` Komponenty.\n\n`ERRORS(path, true)` zároveň obnoví stav nájdených komponentov.\n\nExample: Nájdi neplatné polia\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(ERRORS('form.*').map(com => com.path)); // [\"form.name\"]\n});\n```\n\n### EVALUATE(path, expression, [nopath])\n\nType: `method`\n\nVyhodnotí výraz JavaScriptu s hodnotou path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|Object` | yes |  | Path alebo samotná hodnota, keď má `nopath` hodnotu `true`. |\n| `expression` | `String` | yes |  | Výraz. |\n| `nopath` | `Boolean` | no |  | Považuje prvý argument za hodnotu. |\n\nReturns: `Object` Výsledok výrazu.\n\nVýraz môže používať premenné `value` a `path`.\n\nExample: Vyhodnoť výraz\n```js\nSET('price', 10);\nconsole.log(EVALUATE('price', 'value * 2')); // 20\nconsole.log(EVALUATE(4, 'value + 1', true)); // 5\n```\n\n### EXE([wait], path, [...args])\n\nType: `method`\n\nRovnaká funkcia ako [EXEC()](#exec).\n\nExample: Rovnaká funkcia\n```js\nconsole.log(EXE === EXEC); // true\n```\n\n### EXEC([wait], path, [...args])\n\nType: `method`\n\nZavolá funkciu, metódu pluginu, metódu komponentu, príkaz alebo udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | S hodnotou `true` čaká na cieľ. |\n| `path` | `String` | yes |  | Cieľ. |\n| `...args` | `Object` | no |  | Argumenty. |\n\nTvar path určuje cieľ:\n\n| Path | Cieľ |\n| --- | --- |\n| `plugin/method` | Metóda pluginu |\n| `@plugin.method` | Metóda pluginu |\n| `path.to.fn` | Funkcia na path |\n| `#name` | Udalosť `name` |\n| `-selector/method` | Metóda komponentu, ako v [SETTER()](#setter) |\n| `&name` | Príkaz, ako v [CMD()](#cmd) |\n\nS hodnotou `true` v prvom argumente volanie počká, kým cieľ nebude existovať. `EXE()` je tá istá funkcia.\n\nExample: Zavolaj metódu pluginu\n```js\nPLUGIN('users', function(exports) {\n\texports.hello = function(name) {\n\t\tconsole.log(name); // Peter\n\t};\n});\nEXEC(true, 'users/hello', 'Peter');\n```\n\nExample: Zavolaj funkciu na path\n```js\nwindow.app = { sum: (a, b) => console.log(a + b) };\nEXEC('app.sum', 1, 2);\nconsole.log(typeof(app.sum)); // function\n```\n\n### EXT(path, value, [delay], [reset])\n\nType: `method`\n\nZlúči polia objektu do objektu na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Polia na zlúčenie. |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n| `reset` | `Boolean` | no |  | S hodnotou `true` sa komponenty na path zároveň označia ako nedotknuté a nezmenené. |\n\nKaždé pole sa zapisuje samostatne, takže ostatné polia zostávajú. `EXTEND()` je tá istá funkcia. Rovnako ako pri [SET()](#set) môže byť prvým argumentom požiadavka a `value` cieľovým path.\n\nExample: Zlúč polia\n```js\nSET('user', { name: 'Peter' });\nEXT('user', { age: 30 });\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"age\":30}\n```\n\n### EXTEND(path, value, [delay], [reset])\n\nType: `method`\n\nRovnaká funkcia ako [EXT()](#ext).\n\nExample: Rovnaká funkcia\n```js\nconsole.log(EXTEND === EXT); // true\n```\n\n### EXTENSION(name, [config], declaration)\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 `@plugin`. |\n| `config` | `Object|String` | no |  | Dodatočná konfigurácia. |\n| `declaration` | `Function` | yes |  | `function(self, config, cls)`. |\n\nDeklarácia sa spustí pre každú inštanciu komponentu vrátane existujúcich. S názvom začínajúcim na `@` rozšíri plugin s týmto názvom.\n\nExample: Pridaj komponentu metódu\n```js\nEXTENSION('box', function(self) {\n\tself.bye = () => 'Bye';\n});\nON('ready', function() {\n\tconsole.log(FIND('box').bye()); // Bye\n});\n```\n\n### FIND(selector, [many], [nocache], [callback])\n\nType: `method`\n\nNájde komponent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Element` | yes |  | Čo sa má nájsť. |\n| `many` | `Boolean` | no |  | S hodnotou `true` vráti všetky zhody ako pole. |\n| `nocache` | `Boolean` | no |  | Preskočí cache nájdených komponentov. |\n| `callback` | `Function` | no |  | Počká na komponent a dostane ho. |\n\nReturns: `Component|Array` Nájdený komponent alebo pole, ak je zadané `many`. Pri použití callbacku sa nevráti nič.\n\nSelektor je názov komponentu, `.path`, `#id`, `name[path]` alebo `name@version` a časti môžeš kombinovať medzerou. Element DOM alebo objekt jQuery nájde komponenty vnútri seba.\n\nS callbackom vyhľadávanie počká, kým komponent nebude existovať. Callback môže byť druhý alebo tretí argument.\n\nExample: Nájdi podľa názvu a path\n```js\nON('ready', function() {\n\tconsole.log(FIND('box').path); // data.box\n\tconsole.log(FIND('.data.box').name); // box\n\tconsole.log(FIND('box', true).length); // 1\n});\n```\n\nExample: Počkaj na komponent\n```js\nFIND('box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### FN(expression)\n\nType: `method`\n\nVytvorí funkciu z reťazca.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expression` | `String` | yes |  | Výraz. |\n\nReturns: `Function` Funkcia.\n\nReťazec je šípková funkcia. Reťazec, ktorý používa iba slovo `value`, sa zmení na funkciu s argumentom `value`.\n\nExample: Vytvor funkcie\n```js\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value > 5')(10)); // true\n```\n\n### FORMATTER(fn, [prepend])\n\nType: `method`\n\nZaregistruje globálny formátovač hodnôt komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | S hodnotou `true` sa formátovač spustí ako prvý. |\n\nReturns: `Object` Naformátovaná hodnota, keď funkcia spúšťa formátovače.\n\nFunkcia vráti novú hodnotu a `undefined` zachová aktuálnu. `FORMATTER(value, path, type, [format])` spustí všetky zaregistrované formátovače.\n\nExample: Naformátuj hodnotu\n```js\nFORMATTER(function(path, value, type) {\n\tif (type === 'upper')\n\t\treturn value.toUpperCase();\n});\nconsole.log(FORMATTER('peter', 'user.name', 'upper')); // PETER\n```\n\n### FREE([delay])\n\nType: `method`\n\nOdstráni nepoužívané komponenty, väzby a sledovače.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `10` | Oneskorenie v milisekundách. |\n\nKnižnica to robí aj každé tri minúty.\n\nExample: Upratuj\n```js\nFREE();\nconsole.log(typeof(FREE)); // function\n```\n\n### FUNC\n\nType: `property`\n\nPrázdny objekt pre tvoje vlastné zdieľané funkcie.\n\nExample: Prečítaj hodnotu\n```js\nFUNC.sum = (a, b) => a + b;\nconsole.log(FUNC.sum(1, 2)); // 3\n```\n\n### GET(path, [scope])\n\nType: `method`\n\nPrečíta hodnotu path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `scope` | `Object|Function|Boolean` | no |  | Objekt prečíta path relatívne voči tomuto objektu. Funkcia počká, kým hodnota nebude iná ako `null`, a potom ju dostane. `true` vynuluje stav komponentov na path. |\n\nReturns: `Object` Hodnota alebo `undefined`, keď path nemá hodnotu. S funkciou v druhom argumente sa nevráti nič.\n\nZa path môžu nasledovať flagy. `@clone` vráti kópiu, `@reset` po prečítaní vynuluje stav komponentov a `@modified` vráti iba hodnoty zmenených komponentov.\n\nExample: Prečítaj hodnotu\n```js\nSET('user', { name: 'Peter', age: 30 });\nconsole.log(GET('user.age')); // 30\nconsole.log(GET('name', { name: 'Anna' })); // Anna\n```\n\nExample: Počkaj na hodnotu\n```js\nGET('settings.theme', function(value) {\n\tconsole.log(value); // dark\n});\nsetTimeout(() => SET('settings.theme', 'dark'), 100);\n```\n\n### GUID([size])\n\nType: `method`\n\nVytvorí náhodný identifikátor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `size` | `Number` | no |  | Dĺžka. Bez nej má identifikátor 36 znakov v tvare UUID. |\n\nReturns: `String` Identifikátor.\n\nExample: Vytvor identifikátory\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value, [unsigned])\n\nType: `method`\n\nVytvorí číslo z hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota. |\n| `unsigned` | `Boolean` | no | `true` | S hodnotou `false` môže byť výsledok záporný. |\n\nReturns: `Number` Hash.\n\nObjekty sa hashujú podľa svojej podoby v JSON. Číslo sa vráti tak, ako je, logická hodnota sa zmení na `0` alebo `1` a dátum na svoj čas.\n\nExample: Vytvor hash reťazca\n```js\nconsole.log(HASH('abc')); // 96354\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nZistí, či element nie je zobrazený.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Element. |\n\nReturns: `Boolean` Výsledok. Chýbajúci element vráti `true`.\n\nExample: Skontroluj element\n```html\n<div id=\"a\" style=\"display:none\"><span></span></div>\n<script>\nconsole.log(HIDDEN($('#a')[0].firstChild)); // true\nconsole.log(HIDDEN(null)); // true\n</script>\n```\n\n### IMPORT(url, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nNačíta do stránky skript, štýl alebo HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String|Array` | yes |  | URL. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Kam sa má HTML vložiť. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | S hodnotou `false` nahradí obsah cieľa. |\n| `preparator` | `Function` | no |  | `function(response, output)` upraví HTML pred vložením. |\n\nTéma je vysvetlená v časti [Import obsahu](../../guides/importing/). Pole URL adries sa načítava postupne. URL, ktorá začína na `once ` alebo `!`, sa načíta iba raz a `<path>` pred URL preskočí import, keď má path hodnotu. Callback dostane po načítaní `1` a `0`, keď sa nič nenačítalo.\n\nExample: Importuj HTML\n```html\n<div id=\"target\"></div>\n<script>\nIMPORT('/parts/hello.html', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])\n\nType: `method`\n\nFunguje ako [IMPORT()](#import) a importované HTML ukladá do cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL. |\n| `expire` | `String` | yes |  | Napríklad `5 minutes` alebo `session`. |\n| `target` | `String|Element|jQuery|Component` | no | `body` | Kam sa má HTML vložiť. |\n| `callback` | `Function` | no |  | `function(result)`. |\n| `insert` | `Boolean` | no | `true` | S hodnotou `false` nahradí obsah cieľa. |\n| `preparator` | `Function` | no |  | `function(response, output)` upraví HTML pred vložením. |\n\nExample: Importuj a ulož do cache\n```html\n<div id=\"target\"></div>\n<script>\nIMPORTCACHE('/parts/hello.html', '5 minutes', '#target', function(result) {\n\tconsole.log(result, $('#target').text()); // 1 Hello\n});\n</script>\n```\n\n### INC(path, [value], [delay], [reset])\n\nType: `method`\n\nPripočíta číslo k hodnote na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Number` | no | `1` | Číslo, ktoré sa má pripočítať. |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n| `reset` | `Boolean` | no |  | S hodnotou `true` sa komponenty na path zároveň označia ako nedotknuté a nezmenené. |\n\nChýbajúca hodnota alebo hodnota, ktorá nie je číslo, sa počíta ako `0`.\n\nExample: Zvýš počítadlo\n```js\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 6\n```\n\n### inDOM(element)\n\nType: `method`\n\nZistí, či je element vnútri tela stránky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | Element. |\n\nReturns: `Boolean` `true` alebo `undefined`, keď je element mimo tela stránky.\n\nExample: Skontroluj element\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(inDOM(document.createElement('div')) === undefined); // true\n```\n\n### isIE\n\nType: `property`\n\n`true` v Internet Exploreri.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(isIE)); // boolean\n```\n\n### isMOBILE\n\nType: `property`\n\n`true` na mobilnom zariadení.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(isMOBILE)); // boolean\n```\n\n### isPRIVATEMODE\n\nType: `property`\n\n`true`, keď úložisko prehliadača nie je dostupné.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(isPRIVATEMODE)); // boolean\n```\n\n### isROBOT\n\nType: `property`\n\n`true`, keď user agent vyzerá ako robot.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(isROBOT)); // boolean\n```\n\n### isSTANDALONE\n\nType: `property`\n\n`true`, keď stránka beží ako nainštalovaná aplikácia.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(isSTANDALONE)); // boolean\n```\n\n### isTOUCH\n\nType: `property`\n\n`true` na zariadení s dotykovou obrazovkou.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(isTOUCH)); // boolean\n```\n\n### jComponent\n\nType: `property`\n\nIný názov pre `MAIN`. Pozri [MAIN](../main/).\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### LOCALIZE(text)\n\nType: `method`\n\nPridá preklady do slovníka.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Preklady. |\n\nKaždý riadok má tvar `key : value` a riadok začínajúci na `//` sa preskočí. Hodnoty sa ukladajú do `DEF.dictionary`. Téma je vysvetlená v časti [Lokalizácia](../../guides/localization/).\n\nExample: Pridaj preklady\n```js\nLOCALIZE('// Greetings\\nhello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### M\n\nType: `property`\n\nKrátky názov pre `MAIN`. Pozri [M](../m/).\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(M === MAIN); // true\n```\n\n### MACRO(name, declaration)\n\nType: `method`\n\nDeklaruje macro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov macra. |\n| `declaration` | `Function` | yes |  | `function(self, element, cls)`. |\n\nTéma je vysvetlená v časti [Macros](../../guides/macros/) a objekt popisuje [Macro](../macro/).\n\nExample: Deklaruj macro\n```js\nMACRO('upper', function(self, element) {\n\tself.setter = value => element.text((value || '').toUpperCase());\n});\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### MAIN\n\nType: `property`\n\nHlavný objekt knižnice. Pozri [MAIN](../main/).\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### MAKE([target], fn, [update])\n\nType: `method`\n\nZostaví objekt vo funkcii.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Object|String` | no |  | Objekt alebo path. Bez neho sa vytvorí nový objekt. |\n| `fn` | `Function` | yes |  | `function(obj, path, set)`. |\n| `update` | `Boolean` | no | `true` | S hodnotou `false` sa existujúci objekt na path zapíše späť bez vynulovania jeho komponentov. |\n\nReturns: `Object` Objekt.\n\nCieľ v podobe reťazca je path: objekt na path sa zmení alebo sa vytvorí nový a zapíše sa tam. Funkcia dostane objekt, path a funkciu `set(path, value)`.\n\nExample: Zostav objekt\n```js\nvar obj = MAKE(function(o) {\n\to.name = 'Peter';\n});\nconsole.log(obj); // {\"name\":\"Peter\"}\n```\n\nExample: Zostav objekt na path\n```js\nMAKE('user', function(o, path, set) {\n\to.name = 'Peter';\n\tset('address.city', 'Bratislava');\n});\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"address\":{\"city\":\"Bratislava\"}}\n```\n\n### MIDDLEWARE(name, fn)\n\nType: `method`\n\nDeklaruje middleware trás. Pozri [Smerovanie](../../guides/routing/).\n\n### MODIFIED(path, [flags])\n\nType: `method`\n\nVypíše paths komponentov, ktoré sú dotknuté a zmenené.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním. |\n| `flags` | `String|Array` | no |  | `visible` alebo `hidden` obmedzí vyhľadávanie na tieto komponenty. |\n\nReturns: `Array` Paths zmenených komponentov.\n\nExample: Vypíš zmenené polia\n```js\nON('ready', function() {\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n});\n```\n\n### MONTHS\n\nType: `property`\n\nNázvy mesiacov.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(MONTHS[11]); // December\n```\n\n### NAV\n\nType: `property`\n\nObjekt smerovača. Pozri [Smerovanie](../../guides/routing/).\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` | `Element|jQuery` | yes |  | Element. |\n\nReturns: `Number` Index.\n\nExample: Prečítaj pozíciu\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, target, [before])\n\nType: `method`\n\nUmiestni element za iný element alebo pred neho.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Element, ktorý sa má presunúť. |\n| `target` | `Element|jQuery` | yes |  | Referenčný element. |\n| `before` | `Boolean` | no |  | S hodnotou `true` ho umiestni pred cieľ. |\n\nExample: Presuň element\n```html\n<ul><li id=\"a\">A</li><li>B</li><li id=\"c\">C</li></ul>\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nPresunie element o jednu pozíciu medzi jeho súrodencami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Element. |\n| `up` | `Boolean` | no |  | S hodnotou `true` ho presunie nahor. Inak ho presunie nadol. |\n\nExample: Presuň element nahor\n```html\n<ul><li>A</li><li id=\"b\">B</li></ul>\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BA\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nFunkcia, ktorá nič nerobí.\n\nExample: Použi ako prázdny callback\n```js\nconsole.log(NOOP() === undefined); // true\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nZistí, či je stránka na pozadí.\n\nReturns: `Boolean` Výsledok.\n\nExample: Skontroluj stránku\n```js\nconsole.log(typeof(NOTFOCUSED())); // boolean\n```\n\n### NOTIFY(...paths)\n\nType: `method`\n\nObnoví komponenty a sledovače presne zadaných paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...paths` | `String` | yes |  | Jeden alebo viac paths. |\n\nObnovia sa iba komponenty, ktorých path je presne rovnaký.\n\nExample: Upozorni sledovač\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nwindow.user = { name: 'Peter' };\nNOTIFY('user.name');\n```\n\n### NOTMODIFIED(path, [value], [fields])\n\nType: `method`\n\nZistí, či je hodnota rovnaká ako pri poslednej kontrole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path alebo ľubovoľný kľúč, keď je zadané `value`. |\n| `value` | `Object` | no |  | Hodnota na porovnanie. Bez nej sa použije hodnota path. |\n| `fields` | `Array` | no |  | Porovnáva iba tieto polia. |\n\nReturns: `Boolean` `true`, keď sa hodnota nezmenila.\n\nPrvá kontrola path vráti `false`. Hodnota sa porovnáva podľa hashu svojej podoby v JSON.\n\nExample: Preskoč prácu, keď sa nič nezmenilo\n```js\nconsole.log(NOTMODIFIED('list', [1, 2])); // false\nconsole.log(NOTMODIFIED('list', [1, 2])); // true\nconsole.log(NOTMODIFIED('list', [1, 2, 3])); // false\n```\n\n### NOW\n\nType: `property`\n\nAktuálny dátum, obnovovaný každú minútu.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path, [delay])\n\nType: `method`\n\nZapíše `null` do path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n\n`NULL()` je tá istá funkcia.\n\nExample: Vymaž hodnotu\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### NULL(path, [delay])\n\nType: `method`\n\nRovnaká funkcia ako [NUL()](#nul).\n\nExample: Rovnaká funkcia\n```js\nconsole.log(NULL === NUL); // true\n```\n\n### OFF(name, [path], [fn])\n\nType: `method`\n\nOdstráni obslužné funkcie udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `path` | `String|Function` | no |  | Path alebo obslužná funkcia, keď path nie je potrebný. |\n| `fn` | `Function` | no |  | Obslužná funkcia. |\n\nViac udalostí môžeš oddeliť znakom `+`. Tvar `owner#name` odstráni obslužné funkcie daného vlastníka a `owner#` odstráni všetky.\n\nExample: Odstráň obslužnú funkciu\n```js\nvar fn = () => console.log('never');\nON('ping', fn);\nOFF('ping', fn);\nconsole.log(EMIT('ping')); // false\n```\n\nExample: Odstráň obslužné funkcie vlastníka\n```js\nON('shop#ping', () => console.log('never'));\nOFF('shop#');\nconsole.log(EMIT('ping')); // false\n```\n\n### ON(name, [path], fn, [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| `path` | `String` | no |  | Path pre udalosť `watch`. |\n| `fn` | `Function` | yes |  | Obslužná funkcia. |\n| `init` | `Boolean` | no |  | Pri udalosti `watch` sa obslužná funkcia zavolá aj okamžite. |\n\nNázov môže uvádzať viac udalostí oddelených medzerou alebo ` + `. Názov začínajúci na `^` zaradí obslužnú funkciu na prvé miesto. Tvar `owner#name` priradí obslužnú funkciu vlastníkovi, takže ju [OFF()](#off) môže neskôr odstrániť. Názov `@flag myflag` reaguje na vlastný flag na path.\n\nUdalosť `watch` funguje ako [WATCH()](#watch) a používa `path` a `init`. Udalosti knižnice uvádza časť [Udalosti](../events/).\n\nExample: Počúvaj vlastnú udalosť\n```js\nON('cart.add', function(id, count) {\n\tconsole.log(id, count); // 15 2\n});\nEMIT('cart.add', 15, 2);\n```\n\nExample: Reaguj na vlastný flag\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.name Peter\n});\nSET('user.name @saved', 'Peter');\n```\n\n### OPT([obj], fn)\n\nType: `method`\n\nZostaví objekt možností s vnorenými paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | no |  | Objekt, ktorý sa má naplniť. Bez neho sa vytvorí nový objekt. |\n| `fn` | `Function` | yes |  | `function(set, scope)`. |\n\nReturns: `Object` Objekt.\n\nFunkcia dostane `set(path, value)` a `scope(prefix)`, ktorá pridá predponu k ďalším paths.\n\nExample: Zostav možnosti\n```js\nvar options = OPT(function(set, scope) {\n\tset('title', 'Users');\n\tscope('grid');\n\tset('limit', 20);\n});\nconsole.log(options); // {\"title\":\"Users\",\"grid\":{\"limit\":20}}\n```\n\n### PARSE(value, [date])\n\nType: `method`\n\nSpracuje JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | JSON alebo selektor. |\n| `date` | `Boolean` | no | `DEF.jsondate` | Prevedie dátumy ISO na objekty `Date`. |\n\nReturns: `Object` Hodnota.\n\nReťazec začínajúci na `#` alebo `.` je selektor elementu s JSON. Neplatný JSON vráti `null` a objekt sa vráti tak, ako je.\n\nExample: Spracuj JSON\n```js\nconsole.log(PARSE('{\"id\":5}').id); // 5\nconsole.log(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d instanceof Date); // true\nconsole.log(PARSE('wrong')); // null\n```\n\n### PARSER(fn, [prepend])\n\nType: `method`\n\nZaregistruje globálny parser hodnôt komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(path, value, type, format)`. |\n| `prepend` | `Boolean` | no |  | S hodnotou `true` sa parser spustí ako prvý. |\n\nReturns: `Object` Spracovaná hodnota, keď funkcia spúšťa parsery.\n\nFunkcia musí vždy vrátiť hodnotu. Vstavaný parser prevádza typy `number`, `currency`, `float`, `boolean`, `bool`, `date` a `datetime`. `PARSER(value, path, type, [format])` spustí všetky zaregistrované parsery.\n\nExample: Spracuj hodnotu\n```js\nconsole.log(PARSER('1 200.5', 'price', 'number')); // 1200.5\nconsole.log(PARSER('on', 'active', 'boolean')); // true\n```\n\n### PLUGIN(name, [fn], [init], [done])\n\nType: `method`\n\nDeklaruje plugin alebo vráti existujúci.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov pluginu. |\n| `fn` | `Function` | no |  | `function(exports)`. |\n| `init` | `Function|String` | no |  | Spustí sa pred deklaráciou. Reťazec uvádza názvy middlewarov. |\n| `done` | `Function` | no |  | Zavolá sa, keď je plugin pripravený. |\n\nReturns: `Plugin` Plugin.\n\nTéma je vysvetlená v časti [Pluginy](../../guides/plugins/) a objekt popisuje [Plugin](../plugin/).\n\nExample: Deklaruj plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.count = 5;\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.users.count); // 5\n}, 500);\n```\n\n### PLUGINABLE(name, fn, [init])\n\nType: `method`\n\nZaregistruje plugin, ktorý sa vytvorí pri prvom volaní.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov pluginu. |\n| `fn` | `Function|String` | yes |  | Deklarácia alebo URL. |\n| `init` | `Function|String` | no |  | Spustí sa pred deklaráciou. |\n\nDeklarácia môže byť aj URL súboru, ktorý plugin deklaruje.\n\nExample: Vytvor plugin na požiadanie\n```js\nPLUGINABLE('reports', function(exports) {\n\texports.open = function() {\n\t\tconsole.log('opened'); // opened\n\t};\n});\nsetTimeout(function() {\n\tconsole.log(PLUGINS.reports == null); // true\n\tEXEC('reports/open');\n}, 500);\n```\n\n### PLUGINS\n\nType: `property`\n\nObjekt so všetkými vytvorenými pluginmi podľa názvu.\n\nExample: Prečítaj plugin\n```js\nPLUGIN('users', function(exports) {\n\texports.limit = 10;\n});\nsetTimeout(function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n}, 500);\n```\n\n### PREF\n\nType: `property`\n\nUložené preferencie používateľa. Pozri [PREF](../pref/).\n\nExample: Prečítaj hodnotu\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.theme); // dark\n```\n\n### PUSH(path, value, [delay], [reset])\n\nType: `method`\n\nPridá hodnotu do poľa na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Object|Array` | yes |  | Položka alebo položky, ktoré sa majú pridať. |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n| `reset` | `Boolean` | no |  | S hodnotou `true` sa komponenty na path zároveň označia ako nedotknuté a nezmenené. |\n\nPole v hodnote pridá každú svoju položku. Ak path neobsahuje pole, vytvorí sa nové. Path začínajúci na `^` pridáva na začiatok. Rovnako ako pri [SET()](#set) môže byť prvým argumentom požiadavka a `value` cieľovým path.\n\nExample: Pridaj položky\n```js\nPUSH('tags', 'a');\nPUSH('tags', ['b', 'c']);\nPUSH('^tags', 'first');\nconsole.log(GET('tags')); // [\"first\",\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], obj)\n\nType: `method`\n\nPridá objekt k URL ako reťazec dotazu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | URL, voliteľne s metódou. |\n| `obj` | `Object` | yes |  | Hodnoty. |\n\nReturns: `String` URL.\n\nPrázdne hodnoty sa preskočia, polia sa spoja čiarkou a dátumy používajú formát ISO.\n\nExample: Zostav URL\n```js\nconsole.log(QUERIFY('GET /users/', { page: 2, tags: ['a', 'b'] })); // GET /users/?page=2&tags=a%2Cb\nconsole.log(QUERIFY({ q: 'x y' })); // ?q=x%20y\n```\n\n### QUEUE([name], fn)\n\nType: `method`\n\nSpúšťa funkcie jednu po druhej.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Názov frontu. |\n| `fn` | `Function` | yes |  | `function(next, pending)`. |\n\nReturns: `Number` Počet čakajúcich položiek.\n\nFunkcia dostane `next` a počet čakajúcich položiek. Ďalšia položka sa spustí po zavolaní `next()`.\n\nExample: Spúšťaj v poradí\n```js\nQUEUE('tasks', function(next) {\n\tsetTimeout(next, 50);\n});\nQUEUE('tasks', function(next, pending) {\n\tconsole.log('second', pending); // second 0\n\tnext();\n});\n```\n\n### RECONFIGURE(selector, value)\n\nType: `method`\n\nZmení konfiguráciu všetkých zodpovedajúcich komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor ako vo [FIND()](#find). |\n| `value` | `Object|String` | yes |  | Nová konfigurácia. |\n\nExample: Zmeň konfiguráciu\n```js\nON('ready', function() {\n\tRECONFIGURE('box', { size: 10 });\n\tconsole.log(FIND('box').config.size); // 10\n});\n```\n\n### REDIRECT(url)\n\nType: `method`\n\nPrejde na URL. Pozri [Smerovanie](../../guides/routing/).\n\n### REMOVECACHE(key)\n\nType: `method`\n\nOdstráni hodnotu z cache prehliadača.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Kľúč. |\n\nExample: Odstráň hodnotu\n```js\nCACHE('profile', 'Peter', '1 day');\nREMOVECACHE('profile');\nconsole.log(CACHE('profile') === undefined); // true\n```\n\n### REPEAT([condition], process, delay, [init])\n\nType: `method`\n\nOpakovane spúšťa funkciu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | no |  | Podmienka. |\n| `process` | `Function` | yes |  | `function(counter, scope)`. |\n| `delay` | `Number` | yes |  | Oneskorenie v milisekundách. |\n| `init` | `Boolean` | no |  | S hodnotou `true` sa prvé spustenie začne okamžite. |\n\nPodmienka je funkcia alebo path a spustenie sa preskočí, kým nie je splnená. V tvare `path__expression` dostane výraz premennú `value`. Kým je stránka na pozadí, nič sa nespúšťa, pokiaľ `DEF.repeatfocus` nemá hodnotu `false`.\n\nExample: Spúšťaj každých 100 ms\n```js\nREPEAT(function(counter) {\n\tif (counter === 3)\n\t\tconsole.log('third run'); // third run\n}, 100);\n```\n\n### REPO\n\nType: `property`\n\nPrázdny objekt pre tvoje vlastné zdieľané dáta.\n\nExample: Prečítaj hodnotu\n```js\nREPO.items = [1, 2];\nconsole.log(REPO.items.length); // 2\n```\n\n### RESET(path, [delay])\n\nType: `method`\n\nOznačí komponenty na path ako nedotknuté a nezmenené a znova ich zvaliduje.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nExample: Vynuluj formulár\n```js\nON('ready', function() {\n\tSET('form.name', 'Peter');\n\tCHANGE('form.name');\n\tconsole.log(MODIFIED('form.*')); // [\"form.name\"]\n\tRESET('form.*');\n\tconsole.log(MODIFIED('form.*').length); // 0\n});\n```\n\n### RETURN(command, [multiple])\n\nType: `method`\n\nPrečíta vlastnosť komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `command` | `String` | yes |  | Selektor a vlastnosť. |\n| `multiple` | `Boolean` | no |  | S hodnotou `true` číta zo všetkých zodpovedajúcich komponentov. |\n\nReturns: `Object|Array` Hodnota alebo pole, ak je zadané `multiple`.\n\nPríkaz má tvar `selector/property`.\n\nExample: Prečítaj vlastnosť\n```js\nON('ready', function() {\n\tconsole.log(RETURN('box/title')); // Box\n\tconsole.log(RETURN('box/title', true)); // [\"Box\"]\n});\n```\n\n### REWRITE(path, value, [type])\n\nType: `method`\n\nZapíše hodnotu bez obnovenia komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `type` | `Number` | no |  | Typ zmeny odovzdaný sledovačom. |\n\nDátové väzby a sledovače sa spúšťajú aj naďalej. Ak chceš sledovače preskočiť, použi flag `@nowatch`.\n\nExample: Zapíš bez obnovenia komponentov\n```js\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Peter\n});\nREWRITE('user.name', 'Peter');\n```\n\n### REWRITE2(path, value, [type])\n\nType: `method`\n\nZapíše hodnotu bez obnovenia komponentov alebo dátových väzieb.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `type` | `Number` | no |  | Typ zmeny odovzdaný sledovačom. |\n\nSledovače sa spúšťajú aj naďalej.\n\nExample: Zapíš bez väzieb\n```js\nREWRITE2('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\n```\n\n### ROUTE(url, fn, [middleware], [init])\n\nType: `method`\n\nDeklaruje trasu. Pozri [Smerovanie](../../guides/routing/).\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| `orientation` | String | `x` alebo `y`. Bez nej oba smery |\n| `visibleX`, `visibleY` | Boolean | Ponechá posuvník viditeľný |\n| `native` | Boolean | Použije posuvník prehliadača |\n| `wrap` | Boolean | S hodnotou `false` sa obsah neobalí |\n| `controls` | jQuery | Element pre ovládacie prvky posuvníka |\n| `shadow` | Boolean | Pridá tiene na okrajoch |\n| `padding` | Number | Vnútorný okraj pruhov. Predvolená hodnota: `5` |\n| `minsize` | Number | Najmenšia veľkosť pruhu. Predvolená hodnota: `50` |\n| `thickness` | Number | Hrúbka pruhu. Predvolená hodnota: `10` |\n| `margin`, `marginX`, `marginY` | Number | Okraje |\n| `offsetX`, `offsetY` | Number | Pripočíta sa k veľkosti zobrazenia |\n| `parent` | String alebo Element | Prevezme veľkosť z tohto rodiča |\n| `autoresize` | Boolean | S hodnotou `false` sa veľkosť pri zmene rozmerov nekontroluje |\n| `interval` | Number | Interval kontroly veľkosti |\n| `onscroll`, `onidle`, `onresize` | Function | Obslužné funkcie, ktoré dostanú posuvník |\n\nVrátený objekt má metódy `scrollTop([value])`, `scrollLeft([value])`, `scrollBottom([value])`, `scrollRight([value])`, `scroll(x, y)`, `resize()`, `check()`, `sync(element, [offset])`, `unsync()` a `destroy()`.\n\nExample: Vytvor posuvník\n```html\n<div id=\"box\" style=\"height:100px\"><div style=\"height:500px\"></div></div>\n<script>\nvar scrollbar = SCROLLBAR($('#box'), { orientation: 'y' });\nconsole.log(typeof(scrollbar.scrollTop)); // function\nconsole.log(M.scrollbars.length); // 1\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nVráti šírku posuvníka prehliadača v pixeloch.\n\nReturns: `Number` Šírka.\n\nExample: Prečítaj šírku\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(target, [a], [b], [c], [d])\n\nType: `method`\n\nPodľa cieľa zavolá funkciu alebo zapíše hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Function|String` | yes |  | Funkcia, metóda 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\nFunkcia sa zavolá. Reťazec s `/` alebo path obsahujúci funkciu ide do [EXEC()](#exec). Každý iný reťazec je path a zapíše sa doň prvý argument.\n\nExample: Funkcia alebo path\n```js\nSEEX(value => console.log(value), 1); // 1\nSEEX('result.value', 2);\nconsole.log(GET('result.value')); // 2\n```\n\n### SET(path, value, [delay], [reset])\n\nType: `method`\n\nZapíše hodnotu do path a obnoví všetko, čo je naň naviazané.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n| `reset` | `Boolean` | no |  | S hodnotou `true` sa komponenty na path zároveň označia ako nedotknuté a nezmenené. |\n\nKomponenty, väzby a sledovače na path sa obnovia. Tretí argument môže byť aj `true`, čo okamžite vynuluje stav komponentov.\n\nPath začínajúci na `+` pridá hodnotu do poľa ako [PUSH()](#push). Path začínajúci na `~` ju zlúči ako [EXT()](#ext). Za path môžu nasledovať flagy: pozri [Flagy a modifikátory path](../../guides/flags/).\n\nKeď je prvým argumentom požiadavka, napríklad `GET /api/users/`, odpoveď sa zapíše do path zadaného ako `value`.\n\nExample: Zapíš hodnotu\n```js\nSET('user.name', 'Peter');\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\nExample: Oneskor zápis\n```js\nSET('search', 'first', 100);\nSET('search', 'second', 100);\nsetTimeout(function() {\n\tconsole.log(GET('search')); // second\n}, 300);\n```\n\nExample: Ulož odpoveď\n```js\nSET('GET /api/users/', 'users.response');\nsetTimeout(function() {\n\tconsole.log(GET('users.response.url')); // /api/users/\n}, 200);\n```\n\n### SETTER(selector, method, [...args])\n\nType: `method`\n\nZavolá metódu všetkých zodpovedajúcich komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor ako vo [FIND()](#find). |\n| `method` | `String` | yes |  | Názov metódy. |\n| `...args` | `Object` | no |  | Argumenty metódy. |\n\nSelektor a metódu môžeš spojiť ako `selector/method`. S hodnotou `true` v prvom argumente volanie počká na komponent. Selektor začínajúci na `!` nespustí komponent s odloženým načítaním.\n\nExample: Zavolaj metódu\n```js\n// The component logs 'Hello ' + name\nON('ready', function() {\n\tSETTER('box', 'hello', 'Peter');\n\tSETTER('box/hello', 'Anna');\n});\n```\n\n### setTimeout2(name, fn, delay, [limit], [arg])\n\nType: `method`\n\nSpustí pomenovaný časovač a zruší predchádzajúci časovač s rovnakým názvom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov časovača. |\n| `fn` | `Function` | yes |  | Funkcia. |\n| `delay` | `Number` | yes |  | Oneskorenie v milisekundách. |\n| `limit` | `Number` | no |  | Koľkokrát sa môže časovač odložiť. |\n| `arg` | `Object` | no |  | Argument funkcie. |\n\nReturns: `String` Názov časovača.\n\nS limitom sa časovač odloží najviac toľkokrát, takže funkcia sa spustí aj pri neustálych volaniach.\n\nExample: Ponechaj iba posledné volanie\n```js\nfunction search(value) {\n\tconsole.log(value); // last\n}\nsetTimeout2('search', search, 50, null, 'first');\nsetTimeout2('search', search, 50, null, 'last');\n```\n\n### STOPDEBUG()\n\nType: `method`\n\nKým sú otvorené vývojárske nástroje, opakovane pozastavuje ladiaci nástroj prehliadača.\n\nFunkcia sa opakuje každých 5 sekúnd a nedá sa zastaviť.\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 | `DEF.jsoncompress` | Skomprimuje výstup. |\n| `fields` | `Array|Object|Function` | no |  | Pole povolených polí, objekt s `field: false` alebo `function(key, value)`. |\n| `encrypt` | `Boolean` | no |  | Zašifruje výstup kľúčom z `DEF.secret()`. |\n\nReturns: `String` JSON.\n\nKompresia oreže reťazce a odstráni prázdne reťazce, `false` a `null`.\n\nExample: Serializuj hodnotu\n```js\nconsole.log(STRINGIFY({ a: 1, b: '', c: false }, true)); // {\"a\":1}\nconsole.log(STRINGIFY({ a: 1, b: 2 }, false, ['b'])); // {\"b\":2}\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 štýlu. Element dostane id `css` a za ním túto hodnotu. |\n| `selector` | `String` | no |  | Selektor, ktorý obaľuje pravidlá. |\n\nExistujúci štýl s rovnakým identifikátorom sa nahradí. Pred každé pravidlo sa pridá selektor. `CSS()` je tá istá funkcia.\n\nExample: Pridaj CSS obmedzené selektorom\n```js\nSTYLE('b { color: red }', 'mystyle', '#panel');\nconsole.log($('#cssmystyle').html()); // #panel b{ color: red }\n```\n\n### Ta\n\nType: `property`\n\nKrátky názov pre `Tangular`.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(Ta === Tangular); // true\n```\n\n### Tangular\n\nType: `property`\n\nŠablónovací nástroj. Pozri [Šablóny s Tangularom](../../guides/tangular/).\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(Tangular.render('Hello {{ name }}', { name: 'Peter' })); // Hello Peter\n```\n\n### TAPI(name, [data], [callback])\n\nType: `method`\n\nZavolá API pomocou [DAPI()](#dapi), keď je nastavené `DEF.api`, a inak pomocou [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov schémy. |\n| `data` | `Object` | no |  | Dáta. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` alebo path. |\n\nReturns: `Object|Promise` Výsledok vybranej funkcie.\n\nExample: Vyber spôsob prenosu\n```js\nDEF.api = '/api/';\nTAPI('users_list', null, function(response) {\n\tconsole.log(response.url); // /api/\n});\n```\n\n### TEMP\n\nType: `property`\n\nObjekt pre dočasné dáta.\n\nKnižnica ho každých päť minút nahradí prázdnym objektom.\n\nExample: Prečítaj hodnotu\n```js\nTEMP.value = 5;\nconsole.log(TEMP.value); // 5\n```\n\n### Thelpers\n\nType: `property`\n\nHelpery šablónovacieho nástroja. Pozri [Helpery Tangular](../tangular-helpers/).\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(Thelpers)); // object\n```\n\n### TOGGLE(path, [delay], [reset])\n\nType: `method`\n\nZapíše do path opačnú logickú hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n| `reset` | `Boolean` | no |  | S hodnotou `true` sa komponenty na path zároveň označia ako nedotknuté a nezmenené. |\n\nExample: Prepni hodnotu\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### TRANSLATE(text)\n\nType: `method`\n\nNahradí každý výskyt `@(text)` jeho prekladom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Text. |\n\nReturns: `String` Preložený text.\n\nKľúč v `DEF.dictionary` je `HASH(text).toString(36)`, voliteľne s predponou `T`. Text bez prekladu zostane v pôvodnom jazyku.\n\nExample: Prelož text\n```js\nDEF.dictionary[HASH('Hello').toString(36)] = 'Ahoj';\nconsole.log(TRANSLATE('@(Hello), @(Peter)')); // Ahoj, Peter\n```\n\n### UNAUTHORIZED(...roles)\n\nType: `method`\n\nZistí, či aktuálny používateľ nemá žiadnu zo zadaných rolí.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...roles` | `String` | yes |  | Roly. |\n\nReturns: `Boolean` `true`, keď používateľ nemá žiadnu z rolí.\n\nPoužívateľ sa načíta z `window.user`. Polia `sa` a `su` povoľujú všetko a roly pochádzajú z `permissions` alebo `roles`, ako pole alebo objekt.\n\nExample: Skontroluj rolu\n```js\nwindow.user = { roles: ['editor'] };\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [fn])\n\nType: `method`\n\nOdstráni sledovač.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Sledovaný path. |\n| `fn` | `Function` | no |  | Funkcia odovzdaná do [WATCH()](#watch). |\n\nBez funkcie sa odstránia všetky sledovače daného path.\n\nExample: Zastav sledovanie\n```js\nvar count = 0;\nvar fn = () => count++;\nWATCH('value', fn);\nSET('value', 1);\nUNWATCH('value', fn);\nSET('value', 2);\nconsole.log(count); // 1\n```\n\n### UPD(path, [delay], [reset])\n\nType: `method`\n\nOznámi knižnici, že sa hodnota na path zmenila.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path hodnoty. Pozri [Paths](../../guides/paths/). |\n| `delay` | `Number` | no |  | Číslo 10 alebo vyššie oneskorí zmenu o daný počet milisekúnd. Menšie číslo je typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n| `reset` | `Boolean` | no |  | S hodnotou `true` sa komponenty na path zároveň označia ako nedotknuté a nezmenené. |\n\nPouži ju po priamej zmene objektu. Komponenty sa obnovia a sledovače sa zavolajú. `UPDATE()` je tá istá funkcia. Druhý argument môže byť aj `true`, čo vynuluje stav komponentov.\n\nExample: Obnov po priamej zmene\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nUPD('user.name');\n```\n\n### UPDATE(path, [delay], [reset])\n\nType: `method`\n\nRovnaká funkcia ako [UPD()](#upd).\n\nExample: Rovnaká funkcia\n```js\nconsole.log(UPDATE === UPD); // true\n```\n\n### UPLOAD(url, data, [callback], [delay], [progress])\n\nType: `method`\n\nNahrá dáta na server.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL, voliteľne s metódou. |\n| `data` | `FormData|Object` | yes |  | Dáta. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` alebo path. |\n| `delay` | `Number` | no |  | Pred odoslaním počká zadaný počet milisekúnd. |\n| `progress` | `Function|String` | no |  | `function(percentage)` alebo path. |\n\nReturns: `Promise` Iba ak nie je zadaný callback.\n\nPredvolená metóda je `POST`. `FormData` sa odošle tak, ako je, a všetko ostatné ako JSON. Bez callbacku funkcia vráti Promise. Keď nepotrebuješ oneskorenie, `progress` môže byť štvrtým argumentom.\n\nExample: Nahraj súbor\n```js\nvar data = new FormData();\ndata.append('name', 'photo.jpg');\nUPLOAD('/api/upload/', data, function(response) {\n\tconsole.log(response.url); // /api/upload/\n});\n```\n\n### VALID(path, [flags])\n\nType: `method`\n\nZistí, či žiadny komponent na path nie je neplatný.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s `.*` pre všetko pod ním. |\n| `flags` | `String|Array` | no |  | `visible` alebo `hidden` obmedzí kontrolu na tieto komponenty. |\n\nReturns: `Boolean` Výsledok.\n\nNa rozdiel od [CAN()](#can) neberie do úvahy, či sú komponenty dotknuté.\n\nExample: Skontroluj formulár\n```js\nON('ready', function() {\n\tconsole.log(VALID('form.*')); // false\n\tSET('form', { name: 'Peter', age: 30 });\n\tconsole.log(VALID('form.*')); // true\n});\n```\n\n### VBIND(html)\n\nType: `method`\n\nVytvorí z HTML virtuálny binder.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | HTML s väzbami. |\n\nReturns: `VBinder` Virtuálny binder.\n\nObjekt popisuje [Virtuálny binder](../vbinder/) a tému [Virtuálne väzby](../../guides/virtual-bindings/).\n\nExample: Naviaž samostatný element\n```js\nvar binder = VBIND('<div><span data-bind=\"name__text\"></span></div>');\nbinder.set({ name: 'Peter' });\nconsole.log(binder.element.find('span').text()); // Peter\n```\n\n### VBINDARRAY(html, element)\n\nType: `method`\n\nVykreslí pole s virtuálnym binderom pre každú položku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `html` | `String` | yes |  | HTML jednej položky. |\n| `element` | `Element|jQuery|Component` | yes |  | Nadradený element. |\n\nReturns: `Object` Objekt s metódami `set()`, `get()`, `upd()` a `remove()`.\n\nTéma je vysvetlená v časti [Virtuálne väzby](../../guides/virtual-bindings/).\n\nExample: Vykresli zoznam\n```html\n<ul id=\"list\"></ul>\n<script>\nvar list = VBINDARRAY('<li data-bind=\"name__text\"></li>', $('#list'));\nlist.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log($('#list').text()); // PeterAnna\n</script>\n```\n\n### VERSION(...items)\n\nType: `method`\n\nVyberie verziu komponentov, ktoré sa používajú bez verzie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...items` | `String` | yes |  | Komponenty a ich verzie. |\n\nKaždá položka má tvar `name@version` a jeden reťazec môže uvádzať viac položiek oddelených čiarkou.\n\nExample: Vyber verziu\n```html\n<ui-component name=\"tag\"></ui-component>\n<script>\nCOMPONENT('tag@2', function(self) {\n\tself.make = () => self.element.text('two');\n});\nVERSION('tag@2');\nON('ready', function() {\n\tconsole.log($('ui-component').text()); // two\n});\n</script>\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nZistí, či je element vo viditeľnej výške okna.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element|jQuery` | yes |  | Element. |\n| `threshold` | `Number` | no | `0` | Okraj v pixeloch. |\n| `mode` | `String` | no | `visible` | `visible`, `above` alebo `below`. |\n\nReturns: `Boolean` Výsledok.\n\nExample: Skontroluj element\n```html\n<div id=\"box\">Box</div>\n<script>\nconsole.log(VISIBLE($('#box'))); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nKrátky názov pre `window`.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback, [interval], [timeout])\n\nType: `method`\n\nPočká, kým sa nesplní podmienka.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Funkcia alebo path, ktorý sa má kontrolovať. |\n| `callback` | `Function` | yes |  | `function(err, again)`. |\n| `interval` | `Number` | no | `500` | Interval kontrol v milisekundách. |\n| `timeout` | `Number` | no |  | Najdlhšie čakanie v milisekundách. |\n\nPodmienka je funkcia alebo path. Callback dostane po vypršaní časového limitu chybu a funkciu, ktorá čakanie spustí znova. Bez časového limitu sa čakanie samo nikdy neskončí.\n\nExample: Počkaj na hodnotu\n```js\nWAIT('app.ready', function() {\n\tconsole.log(GET('app.ready')); // true\n}, 50);\nsetTimeout(() => SET('app.ready', true), 100);\n```\n\nExample: Zastav po vypršaní časového limitu\n```js\nWAIT(() => false, function(err) {\n\tconsole.log(err.message); // Timeout.\n}, 50, 200);\n```\n\n### WAPI([name], [data], [callback], [timeout])\n\nType: `method`\n\nZavolá API cez spojenie WebSocket.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | no |  | Názov schémy alebo možnosti spojenia. |\n| `data` | `Object` | no |  | Dáta. |\n| `callback` | `Function|String` | no |  | `function(response, err, output)` alebo path. |\n| `timeout` | `Number` | no | `10000` | Časový limit v milisekundách. |\n\nReturns: `Object|Promise` Spojenie alebo Promise.\n\nObjekt v prvom argumente otvorí spojenie ako [WAPI_INIT()](#wapi-init). Bez argumentov funkcia vráti otvorené spojenie. Bez callbacku vráti Promise. Predvolený časový limit volania je 10 sekúnd.\n\nExample: Zavolaj cez socket\n```js\nWAPI({ url: '/api/' });\nWAPI('users_list', null, function(response) {\n\tconsole.log(response.schema); // users_list\n});\n```\n\n### WAPI_INIT(options)\n\nType: `method`\n\nOtvorí spojenie WebSocket, ktoré používa [WAPI()](#wapi).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Možnosti spojenia. |\n\nReturns: `Object` Objekt možností s pridanými metódami.\n\nMožnosti sú `url`, `reconnect` (oneskorenie v milisekundách alebo `false`), `expire` (po tomto čase sa spojenie obnoví), `callback` (zavolá sa raz po prvom pokuse o spojenie) a obslužné funkcie `open`, `close(e)` a `message(data)`.\n\nVrátený objekt má metódy `send(name, data, callback, [timeout])`, `on(name, fn)` pre udalosti `open`, `close`, `message` a `reconnect`, `emit(name, ...)` a `pause(is)`.\n\nExample: Otvor spojenie\n```js\nWAPI_INIT({\n\turl: '/api/',\n\topen: function() {\n\t\tconsole.log('connected'); // connected\n\t}\n});\nconsole.log(typeof(WAPI().send)); // function\n```\n\n### WARN(...args)\n\nType: `method`\n\nZapíše upozornenie do konzoly.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `...args` | `Object` | yes |  | Hodnoty na zápis. |\n\nExample: Zapíš upozornenie\n```js\nWARN('Disk is full');\nconsole.log(typeof(WARN)); // function\n```\n\n### WATCH(path, fn, [init])\n\nType: `method`\n\nZavolá funkciu, keď sa zmení hodnota na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, ktorý sa má sledovať. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n| `init` | `Boolean` | no |  | S hodnotou `true` sa funkcia zavolá aj okamžite. |\n\nFunkcia dostane zmenený path, hodnotu a typ zmeny: `0` počiatočné volanie, `1` ručná, `2` vstup, `3` predvolená. Path `users.*` reaguje aj na všetko pod `users`. Viac paths môžeš oddeliť medzerou a path začínajúci na `^` sa spustí pred ostatnými sledovačmi.\n\nExample: Reaguj na zmenu\n```js\nWATCH('user.name', function(path, value, type) {\n\tconsole.log(path, value, type); // user.name Peter 1\n});\nSET('user.name', 'Peter');\n```\n\nExample: Zavolaj ju okamžite\n```js\nSET('count', 5);\nWATCH('count', function(path, value, type) {\n\tconsole.log(value, type); // 5 0\n}, true);\n```\n\n### WATCHONCE(path, fn)\n\nType: `method`\n\nZavolá funkciu iba pri najbližšej zmene path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, ktorý sa má sledovať. |\n| `fn` | `Function` | yes |  | `function(path, value, type)`. |\n\nExample: Reaguj raz\n```js\nWATCHONCE('count', function(path, value) {\n\tconsole.log(value); // 1\n});\nSET('count', 1);\nSET('count', 2);\n```\n\n### WH\n\nType: `property`\n\nVýška okna v pixeloch.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(WH)); // number\n```\n\n### WIDTH([element])\n\nType: `method`\n\nVráti veľkosť zobrazenia okna alebo elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | Element. |\n\nReturns: `String` `xs`, `sm`, `md` alebo `lg`.\n\nLimity sú v `DEF.devices`.\n\nExample: Prečítaj veľkosť elementu\n```html\n<div id=\"box\" style=\"width:1000px\"></div>\n<script>\nconsole.log(WIDTH($('#box'))); // md\n</script>\n```\n\n### WORKFLOW(declaration, [tasks], [callback])\n\nType: `method`\n\nSpúšťa pomenované kroky, ktoré si odovzdávajú hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `declaration` | `Function` | yes |  | `function($)`. |\n| `tasks` | `Object` | no |  | Kroky podľa názvu. |\n| `callback` | `Function` | no |  | `function(value, err, $)`. |\n\nReturns: `Object` Workflow.\n\nObjekt odovzdaný deklarácii a každému kroku má týchto členov:\n\n| Člen | Popis |\n| --- | --- |\n| `push(name, fn)` | Pridá krok: `function($, value)` |\n| `next(name, [value])` | Spustí krok. Neznámy názov ukončí workflow |\n| `next2(name)` | Vráti callback, ktorý krok spustí |\n| `done([value])` | Zavolá záverečný callback s hodnotou |\n| `invalid(err)` | Nahlási chybu do `error` alebo záverečnému callbacku |\n| `callback(fn)` | Nahradí záverečný callback |\n| `clone()` | Vytvorí workflow s rovnakými krokmi |\n| `destroy()` | Ukončí workflow |\n| `value`, `current`, `prev` | Hodnota, aktuálny krok a predchádzajúci krok |\n\nExample: Spusti dva kroky\n```js\nWORKFLOW(function($) {\n\t$.push('load', ($, value) => $.next('save', value + 1));\n\t$.push('save', ($, value) => $.done(value * 2));\n\t$.next('load', 1);\n}, function(value) {\n\tconsole.log(value); // 4\n});\n```\n\n### WW\n\nType: `property`\n\nŠírka okna v pixeloch.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(typeof(WW)); // number\n```\n","entries":[{"type":"method","name":"ACMD()","signature":"ACMD(name, [...args])","since":"","deprecated":false},{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"ADD()","signature":"ADD(value, [element], [config], [content])","since":"","deprecated":false},{"type":"method","name":"AEXEC()","signature":"AEXEC(path, [...args])","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], [callback], [delay])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHE()","signature":"AJAXCACHE(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCACHEREVIEW()","signature":"AJAXCACHEREVIEW(url, [data], callback, expire, [delay], [clear])","since":"","deprecated":false},{"type":"method","name":"AJAXCONFIG()","signature":"AJAXCONFIG(name, fn)","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BIND()","signature":"BIND(path)","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(name, 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, [rebind])","since":"","deprecated":false},{"type":"method","name":"CAN()","signature":"CAN(path, [flags])","since":"","deprecated":false},{"type":"method","name":"CHANGE()","signature":"CHANGE(path, [value])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, callback)","since":"","deprecated":false},{"type":"method","name":"CL_INIT()","signature":"CL_INIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [expire], [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [nopath])","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], [e])","since":"","deprecated":false},{"type":"method","name":"COMPILE()","signature":"COMPILE([container])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], declaration, [dependencies])","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":"method","name":"DAPI()","signature":"DAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"method","name":"DEBUG()","signature":"DEBUG()","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DEFAULT()","signature":"DEFAULT(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"DISABLED()","signature":"DISABLED(path, [flags])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [...args])","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(value, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, [flags], [highlight])","since":"","deprecated":false},{"type":"method","name":"EVALUATE()","signature":"EVALUATE(path, expression, [nopath])","since":"","deprecated":false},{"type":"method","name":"EXE()","signature":"EXE([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC([wait], path, [...args])","since":"","deprecated":false},{"type":"method","name":"EXT()","signature":"EXT(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTEND()","signature":"EXTEND(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], declaration)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [many], [nocache], [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(expression)","since":"","deprecated":false},{"type":"method","name":"FORMATTER()","signature":"FORMATTER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE([delay])","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [scope])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([size])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value, [unsigned])","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"IMPORTCACHE()","signature":"IMPORTCACHE(url, expire, [target], [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value], [delay], [reset])","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":"method","name":"MACRO()","signature":"MACRO(name, declaration)","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"method","name":"MAKE()","signature":"MAKE([target], fn, [update])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, fn)","since":"","deprecated":false},{"type":"method","name":"MODIFIED()","signature":"MODIFIED(path, [flags])","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"property","name":"NAV","signature":"NAV","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, target, [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":"method","name":"NOTIFY()","signature":"NOTIFY(...paths)","since":"","deprecated":false},{"type":"method","name":"NOTMODIFIED()","signature":"NOTMODIFIED(path, [value], [fields])","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"NULL()","signature":"NULL(path, [delay])","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [path], [fn])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, [path], fn, [init])","since":"","deprecated":false},{"type":"method","name":"OPT()","signature":"OPT([obj], fn)","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value, [date])","since":"","deprecated":false},{"type":"method","name":"PARSER()","signature":"PARSER(fn, [prepend])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [fn], [init], [done])","since":"","deprecated":false},{"type":"method","name":"PLUGINABLE()","signature":"PLUGINABLE(name, fn, [init])","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, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], obj)","since":"","deprecated":false},{"type":"method","name":"QUEUE()","signature":"QUEUE([name], fn)","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT(url)","since":"","deprecated":false},{"type":"method","name":"REMOVECACHE()","signature":"REMOVECACHE(key)","since":"","deprecated":false},{"type":"method","name":"REPEAT()","signature":"REPEAT([condition], process, delay, [init])","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path, [delay])","since":"","deprecated":false},{"type":"method","name":"RETURN()","signature":"RETURN(command, [multiple])","since":"","deprecated":false},{"type":"method","name":"REWRITE()","signature":"REWRITE(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"REWRITE2()","signature":"REWRITE2(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"ROUTE()","signature":"ROUTE(url, fn, [middleware], [init])","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(target, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, fn, delay, [limit], [arg])","since":"","deprecated":false},{"type":"method","name":"STOPDEBUG()","signature":"STOPDEBUG()","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":"property","name":"Ta","signature":"Ta","since":"","deprecated":false},{"type":"property","name":"Tangular","signature":"Tangular","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], [callback])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"property","name":"Thelpers","signature":"Thelpers","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...roles)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [fn])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPDATE()","signature":"UPDATE(path, [delay], [reset])","since":"","deprecated":false},{"type":"method","name":"UPLOAD()","signature":"UPLOAD(url, data, [callback], [delay], [progress])","since":"","deprecated":false},{"type":"method","name":"VALID()","signature":"VALID(path, [flags])","since":"","deprecated":false},{"type":"method","name":"VBIND()","signature":"VBIND(html)","since":"","deprecated":false},{"type":"method","name":"VBINDARRAY()","signature":"VBINDARRAY(html, element)","since":"","deprecated":false},{"type":"method","name":"VERSION()","signature":"VERSION(...items)","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, [interval], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI()","signature":"WAPI([name], [data], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"WAPI_INIT()","signature":"WAPI_INIT(options)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...args)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, fn, [init])","since":"","deprecated":false},{"type":"method","name":"WATCHONCE()","signature":"WATCHONCE(path, fn)","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"method","name":"WORKFLOW()","signature":"WORKFLOW(declaration, [tasks], [callback])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammXp6QM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/def/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"DEF","summary":"The configuration options of the library.","markdown":"---\ntitle: DEF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/def/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# DEF\n\n> The configuration options of the library.\n\n`DEF` holds the configuration of the library. Set the options in a script right after the library is loaded, before the first components start. To see how the options fit together, read [Getting started](../../guides/getting-started/).\n\n## API\n\n### DEF.ajaxcredentials = false\n\nType: `config`\n\nSends cookies with every request.\n\nExample: Example\n```js\nDEF.ajaxcredentials = true;\nconsole.log(DEF.ajaxcredentials); // true\n```\n\n### DEF.ajaxcredentialshtml = false\n\nType: `config`\n\nAlso sends cookies with requests for `.html` files when `DEF.ajaxcredentials` is on.\n\nExample: Example\n```js\nconsole.log(DEF.ajaxcredentialshtml); // false\n```\n\n### DEF.ajaxerrors = false\n\nType: `config`\n\nHandles error responses as regular responses.\n\nWith `true`, the event `error` is not emitted and the Promise of a request is not rejected.\n\nExample: Example\n```js\nDEF.ajaxerrors = true;\nON('request', opt => opt.throw('Failed', 500));\nAJAX('GET /api/', function(response, err) {\n\tconsole.log(response, err); // Failed 500\n});\n```\n\n### DEF.api = undefined\n\nType: `config`\n\nThe default endpoint of [DAPI()](../globals/#dapi) and [TAPI()](../globals/#tapi).\n\nA URL, or a function that receives the name and the data and returns the value for `API()`.\n\nExample: Example\n```js\nDEF.api = '/api/';\nconsole.log(DEF.api); // /api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nA prefix of relative request URLs.\n\nA string, or a function that receives the URL and returns a new one.\n\nExample: Example\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nThe value of the marker `~CDN~` in imported content.\n\nExample: Example\n```js\nDEF.cdn = '//cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nThe loaded code lists by name.\n\nExample: Example\n```js\nCL_INIT('roles', next => next(['admin']), true);\nconsole.log(DEF.cl.roles); // [\"admin\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nThe main color of the application.\n\nExample: Example\n```js\nconsole.log(DEF.color); // #4285F4\n```\n\n### DEF.csrf = undefined\n\nType: `config`\n\nA token sent in the header `x-csrf-token`.\n\nRequests for `.html` files do not send it.\n\nExample: Example\n```js\nDEF.csrf = 'abc';\nON('request', function(opt) {\n\tconsole.log(opt.headers['x-csrf-token']); // abc\n\topt.respond({});\n});\nAJAX('POST /api/', {}, NOOP);\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nFunctions that format numbers as currencies.\n\nExample: Example\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log((5).currency('eur')); // 5.00 EUR\n```\n\n### DEF.currency = undefined\n\nType: `config`\n\nThe default currency of `Number.currency()`.\n\nExample: Example\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currency = 'eur';\nconsole.log((5).currency()); // 5.00 EUR\n```\n\n### DEF.customelements = false\n\nType: `config`\n\nRegisters every component as its own element, `<ui-name>`.\n\nSet it before declaring components.\n\nExample: Example\n```js\nDEF.customelements = true;\nCOMPONENT('hello', function(self) {\n\tself.make = () => self.element.text('Hi');\n});\nconsole.log(customElements.get('ui-hello') != null); // true\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nThe default format of `Date.format()`.\n\nExample: Example\n```js\nconsole.log(new Date(2024, 0, 15).format()); // 2024-01-15\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormats dates in UTC.\n\nExample: Example\n```js\nconsole.log(DEF.dateformatutc); // false\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nThe decimal separator of formatted numbers.\n\nExample: Example\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.delay = 555\n\nType: `config`\n\nThe delay in milliseconds before a request with the flag `sync` is tried again.\n\nExample: Example\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEF.delaybinder = 200\n\nType: `config`\n\nThe delay in milliseconds of delayed data bindings.\n\nExample: Example\n```js\nconsole.log(DEF.delaybinder); // 200\n```\n\n### DEF.delaykeypress = 200\n\nType: `config`\n\nThe delay in milliseconds after a key press in an input.\n\nExample: Example\n```js\nconsole.log(DEF.delaykeypress); // 200\n```\n\n### DEF.delaypref = 1000\n\nType: `config`\n\nThe delay in milliseconds before [PREF](../pref/) is saved.\n\nExample: Example\n```js\nconsole.log(DEF.delaypref); // 1000\n```\n\n### DEF.delayrepeat = 2000\n\nType: `config`\n\nThe delay in milliseconds before a request with the flag `repeat` is sent again.\n\nExample: Example\n```js\nconsole.log(DEF.delayrepeat); // 2000\n```\n\n### DEF.delaywatcher = 555\n\nType: `config`\n\nThe interval in milliseconds of the checks that wait for a value.\n\nExample: Example\n```js\nconsole.log(DEF.delaywatcher); // 555\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 limits of the display sizes in pixels.\n\nExample: Example\n```js\nconsole.log(DEF.devices.sm); // {\"min\":768,\"max\":992}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nThe translations used by [TRANSLATE()](../globals/#translate).\n\nExample: Example\n```js\nLOCALIZE('hello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nThe text used for an empty value in data bindings.\n\nExample: Example\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.environment = { ts, date, time }\n\nType: `config`\n\nThe variables of [ENV()](../globals/#env).\n\nExample: Example\n```js\nconsole.log(DEF.environment.date); // yyyy-MM-dd\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nThe URL of components that are not declared on the page.\n\n`{0}` is the name of the component. An empty value turns the download off.\n\nExample: Example\n```js\nDEF.fallback = '';\nconsole.log(DEF.fallback === ''); // true\n```\n\n### DEF.fallbackcache = ''\n\nType: `config`\n\nHow long downloaded components are cached.\n\nExample: Example\n```js\nDEF.fallbackcache = '1 day';\nconsole.log(DEF.fallbackcache); // 1 day\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nThe headers of every request.\n\nExample: Example\n```js\nDEF.headers['X-App'] = 'shop';\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-App']); // shop\n\topt.respond({});\n});\nAJAX('GET /api/', NOOP);\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nThe prefix of icon names in `component.icon()`.\n\nExample: Example\n```js\nconsole.log(DEF.iconprefix); // ti ti-\n```\n\n### DEF.importcache = 'session'\n\nType: `config`\n\nHow long content from `<ui-import>` is cached.\n\nExample: Example\n```js\nconsole.log(DEF.importcache); // session\n```\n\n### DEF.jsoncompress = false\n\nType: `config`\n\nThe default value of the `compress` argument of [STRINGIFY()](../globals/#stringify).\n\nExample: Example\n```js\nDEF.jsoncompress = true;\nconsole.log(STRINGIFY({ a: 1, b: '' })); // {\"a\":1}\n```\n\n### DEF.jsonconverter = { 'text json': fn }\n\nType: `config`\n\nThe converters of request responses.\n\nExample: Example\n```js\nconsole.log(typeof(DEF.jsonconverter['text json'])); // function\n```\n\n### DEF.jsondate = true\n\nType: `config`\n\nConverts ISO dates to `Date` objects when JSON is parsed.\n\nExample: Example\n```js\nDEF.jsondate = false;\nconsole.log(typeof(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d)); // string\n```\n\n### DEF.keypress = true\n\nType: `config`\n\nMakes inputs react while the user types.\n\nExample: Example\n```js\nconsole.log(DEF.keypress); // true\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nThe language added to the URL of every request.\n\nExample: Example\n```js\nDEF.language = 'sk';\nconsole.log(DEF.language); // sk\n```\n\n### DEF.languagehtml = undefined\n\nType: `config`\n\nThe language added to the URL of `.html` requests only.\n\nExample: Example\n```js\nDEF.languagehtml = 'sk';\nconsole.log(DEF.languagehtml); // sk\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nThe name of the query argument with the language.\n\nExample: Example\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nThe prefix of the keys in the browser storage.\n\nExample: Example\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.makeurl = null\n\nType: `config`\n\nA function that changes the URL of every request.\n\nExample: Example\n```js\nDEF.makeurl = url => url + '?v=2';\nconsole.log(typeof(DEF.makeurl)); // function\n```\n\n### DEF.monitor = false\n\nType: `config`\n\nCollects usage counters in [M.performance](../m/#performance).\n\nExample: Example\n```js\nDEF.monitor = true;\nSET('a', 1);\nconsole.log(M.performance.set.count > 0); // true\n```\n\n### DEF.pathcl = 'DEF.cl.'\n\nType: `config`\n\nThe path behind the prefix `#`.\n\nExample: Example\n```js\nconsole.log(DEF.pathcl); // DEF.cl.\n```\n\n### DEF.pathcommon = 'common.'\n\nType: `config`\n\nThe path behind the prefix `*`.\n\nExample: Example\n```js\nSET('*title', 'Hello');\nconsole.log(GET('common.title')); // Hello\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nThe CSS prefix passed to component declarations.\n\nExample: Example\n```js\nconsole.log(DEF.prefixcsscomponents); // ui-\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nThe CSS prefix of the classes of the library.\n\nExample: Example\n```js\nconsole.log(DEF.prefixcsslibrary); // ui-\n```\n\n### DEF.prefixcssmacros = 'm-'\n\nType: `config`\n\nThe CSS prefix passed to macro declarations.\n\nExample: Example\n```js\nconsole.log(DEF.prefixcssmacros); // m-\n```\n\n### DEF.regexp = { int, float, date, pluralize, format }\n\nType: `config`\n\nThe regular expressions of the string and date helpers.\n\nExample: Example\n```js\nconsole.log(DEF.regexp.int instanceof RegExp); // true\n```\n\n### DEF.repeatfocus = true\n\nType: `config`\n\nPauses [REPEAT()](../globals/#repeat) while the page is in the background.\n\nExample: Example\n```js\nconsole.log(DEF.repeatfocus); // true\n```\n\n### DEF.root = ''\n\nType: `config`\n\nA prefix of relative URLs that has priority over `DEF.baseurl`.\n\nA string, or a function that receives the URL and returns a new one.\n\nExample: Example\n```js\nDEF.root = '/shop';\nconsole.log('/users/'.ROOT()); // /shop/users/\n```\n\n### DEF.scope = window\n\nType: `config`\n\nThe object in which paths are stored.\n\nExample: Example\n```js\nconsole.log(DEF.scope === window); // true\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnimates custom scrollbars at the end of the content.\n\nExample: Example\n```js\nconsole.log(DEF.scrollbaranimate); // true\n```\n\n### DEF.secret = function\n\nType: `config`\n\nSets the key that encrypts the data of requests.\n\nCall it as `DEF.secret(key, [validator], [html])`. `validator` is a function that receives the request options and decides whether to encrypt them. With `true` as `html`, responses for `.html` files are also decrypted. The function removes itself after the first call.\n\nExample: Example\n```js\nDEF.secret('my-key');\nconsole.log(DEF.secret === undefined); // true\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nThe thousands separator of formatted numbers.\n\nExample: Example\n```js\nconsole.log((1500).format(0)); // 1 500\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nThe default time format in `DEF.environment`.\n\nExample: Example\n```js\nconsole.log(DEF.timeformat); // HH:mm\n```\n\n### DEF.validators = { url, phone, email }\n\nType: `config`\n\nThe regular expressions of `String.isURL()`, `String.isPhone()` and `String.isEmail()`.\n\nExample: Example\n```js\nconsole.log(DEF.validators.email.test('a@b.com')); // true\n```\n\n### DEF.version = ''\n\nType: `config`\n\nThe version added to the URL of every request.\n\nExample: Example\n```js\nDEF.version = '1.2';\nconsole.log(DEF.version); // 1.2\n```\n\n### DEF.versioncomponents = ''\n\nType: `config`\n\nThe version of components used without a version.\n\nExample: Example\n```js\nconsole.log(DEF.versioncomponents === ''); // true\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nThe version added to the URL of `.html` requests only.\n\nExample: Example\n```js\nDEF.versionhtml = '1.2';\nconsole.log(DEF.versionhtml); // 1.2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nThe name of the query argument with the version.\n\nExample: Example\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.webcomponentsonly = undefined\n\nType: `config`\n\nWith `true`, the page is searched only for the `<ui-*>` elements.\n\nExample: Example\n```js\nDEF.webcomponentsonly = true;\nconsole.log(DEF.webcomponentsonly); // true\n```\n","entries":[{"type":"config","name":"DEF.ajaxcredentials","signature":"DEF.ajaxcredentials = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxcredentialshtml","signature":"DEF.ajaxcredentialshtml = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxerrors","signature":"DEF.ajaxerrors = false","since":"","deprecated":false},{"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.csrf","signature":"DEF.csrf = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.customelements","signature":"DEF.customelements = false","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.delay","signature":"DEF.delay = 555","since":"","deprecated":false},{"type":"config","name":"DEF.delaybinder","signature":"DEF.delaybinder = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaykeypress","signature":"DEF.delaykeypress = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaypref","signature":"DEF.delaypref = 1000","since":"","deprecated":false},{"type":"config","name":"DEF.delayrepeat","signature":"DEF.delayrepeat = 2000","since":"","deprecated":false},{"type":"config","name":"DEF.delaywatcher","signature":"DEF.delaywatcher = 555","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.environment","signature":"DEF.environment = { ts, date, time }","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.fallbackcache","signature":"DEF.fallbackcache = ''","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.importcache","signature":"DEF.importcache = 'session'","since":"","deprecated":false},{"type":"config","name":"DEF.jsoncompress","signature":"DEF.jsoncompress = false","since":"","deprecated":false},{"type":"config","name":"DEF.jsonconverter","signature":"DEF.jsonconverter = { 'text json': fn }","since":"","deprecated":false},{"type":"config","name":"DEF.jsondate","signature":"DEF.jsondate = true","since":"","deprecated":false},{"type":"config","name":"DEF.keypress","signature":"DEF.keypress = true","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagehtml","signature":"DEF.languagehtml = 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.makeurl","signature":"DEF.makeurl = null","since":"","deprecated":false},{"type":"config","name":"DEF.monitor","signature":"DEF.monitor = false","since":"","deprecated":false},{"type":"config","name":"DEF.pathcl","signature":"DEF.pathcl = 'DEF.cl.'","since":"","deprecated":false},{"type":"config","name":"DEF.pathcommon","signature":"DEF.pathcommon = 'common.'","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.prefixcssmacros","signature":"DEF.prefixcssmacros = 'm-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format }","since":"","deprecated":false},{"type":"config","name":"DEF.repeatfocus","signature":"DEF.repeatfocus = true","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scope","signature":"DEF.scope = window","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.secret","signature":"DEF.secret = function","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.validators","signature":"DEF.validators = { url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = ''","since":"","deprecated":false},{"type":"config","name":"DEF.versioncomponents","signature":"DEF.versioncomponents = ''","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.webcomponentsonly","signature":"DEF.webcomponentsonly = undefined","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammXp6QM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/def/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"DEF","summary":"Die Konfigurationsoptionen der Bibliothek.","markdown":"---\ntitle: DEF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/def/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# DEF\n\n> Die Konfigurationsoptionen der Bibliothek.\n\n`DEF` enthält die Konfiguration der Bibliothek. Setze die Optionen in einem Skript direkt nach dem Laden der Bibliothek, bevor die ersten Komponenten starten. Wie die Optionen zusammenspielen, erfährst du unter [Erste Schritte](../../guides/getting-started/).\n\n## API\n\n### DEF.ajaxcredentials = false\n\nType: `config`\n\nSendet Cookies mit jeder Anfrage.\n\nExample: Beispiel\n```js\nDEF.ajaxcredentials = true;\nconsole.log(DEF.ajaxcredentials); // true\n```\n\n### DEF.ajaxcredentialshtml = false\n\nType: `config`\n\nSendet Cookies auch bei Anfragen nach `.html`-Dateien, wenn `DEF.ajaxcredentials` aktiv ist.\n\nExample: Beispiel\n```js\nconsole.log(DEF.ajaxcredentialshtml); // false\n```\n\n### DEF.ajaxerrors = false\n\nType: `config`\n\nBehandelt Fehlerantworten wie normale Antworten.\n\nMit `true` wird das Event `error` nicht ausgelöst und das Promise einer Anfrage nicht abgelehnt.\n\nExample: Beispiel\n```js\nDEF.ajaxerrors = true;\nON('request', opt => opt.throw('Failed', 500));\nAJAX('GET /api/', function(response, err) {\n\tconsole.log(response, err); // Failed 500\n});\n```\n\n### DEF.api = undefined\n\nType: `config`\n\nDer Standard-Endpunkt von [DAPI()](../globals/#dapi) und [TAPI()](../globals/#tapi).\n\nEine URL oder eine Funktion, die den Namen und die Daten erhält und den Wert für `API()` zurückgibt.\n\nExample: Beispiel\n```js\nDEF.api = '/api/';\nconsole.log(DEF.api); // /api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nEin Präfix für relative Anfrage-URLs.\n\nEin String oder eine Funktion, die die URL erhält und eine neue zurückgibt.\n\nExample: Beispiel\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nDer Wert der Markierung `~CDN~` in importierten Inhalten.\n\nExample: Beispiel\n```js\nDEF.cdn = '//cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nDie geladenen Codelisten nach Namen.\n\nExample: Beispiel\n```js\nCL_INIT('roles', next => next(['admin']), true);\nconsole.log(DEF.cl.roles); // [\"admin\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nDie Hauptfarbe der Anwendung.\n\nExample: Beispiel\n```js\nconsole.log(DEF.color); // #4285F4\n```\n\n### DEF.csrf = undefined\n\nType: `config`\n\nEin Token, das im Header `x-csrf-token` gesendet wird.\n\nAnfragen nach `.html`-Dateien senden es nicht.\n\nExample: Beispiel\n```js\nDEF.csrf = 'abc';\nON('request', function(opt) {\n\tconsole.log(opt.headers['x-csrf-token']); // abc\n\topt.respond({});\n});\nAJAX('POST /api/', {}, NOOP);\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nFunktionen, die Zahlen als Währungen formatieren.\n\nExample: Beispiel\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log((5).currency('eur')); // 5.00 EUR\n```\n\n### DEF.currency = undefined\n\nType: `config`\n\nDie Standardwährung von `Number.currency()`.\n\nExample: Beispiel\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currency = 'eur';\nconsole.log((5).currency()); // 5.00 EUR\n```\n\n### DEF.customelements = false\n\nType: `config`\n\nRegistriert jede Komponente als eigenes Element, `<ui-name>`.\n\nSetze die Option, bevor du Komponenten deklarierst.\n\nExample: Beispiel\n```js\nDEF.customelements = true;\nCOMPONENT('hello', function(self) {\n\tself.make = () => self.element.text('Hi');\n});\nconsole.log(customElements.get('ui-hello') != null); // true\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nDas Standardformat von `Date.format()`.\n\nExample: Beispiel\n```js\nconsole.log(new Date(2024, 0, 15).format()); // 2024-01-15\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormatiert Datumsangaben in UTC.\n\nExample: Beispiel\n```js\nconsole.log(DEF.dateformatutc); // false\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nDas Dezimaltrennzeichen formatierter Zahlen.\n\nExample: Beispiel\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.delay = 555\n\nType: `config`\n\nDie Verzögerung in Millisekunden, bevor eine Anfrage mit dem Flag `sync` erneut versucht wird.\n\nExample: Beispiel\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEF.delaybinder = 200\n\nType: `config`\n\nDie Verzögerung verzögerter Datenbindungen in Millisekunden.\n\nExample: Beispiel\n```js\nconsole.log(DEF.delaybinder); // 200\n```\n\n### DEF.delaykeypress = 200\n\nType: `config`\n\nDie Verzögerung in Millisekunden nach einem Tastendruck in einem Eingabefeld.\n\nExample: Beispiel\n```js\nconsole.log(DEF.delaykeypress); // 200\n```\n\n### DEF.delaypref = 1000\n\nType: `config`\n\nDie Verzögerung in Millisekunden, bevor [PREF](../pref/) gespeichert wird.\n\nExample: Beispiel\n```js\nconsole.log(DEF.delaypref); // 1000\n```\n\n### DEF.delayrepeat = 2000\n\nType: `config`\n\nDie Verzögerung in Millisekunden, bevor eine Anfrage mit dem Flag `repeat` erneut gesendet wird.\n\nExample: Beispiel\n```js\nconsole.log(DEF.delayrepeat); // 2000\n```\n\n### DEF.delaywatcher = 555\n\nType: `config`\n\nDas Intervall in Millisekunden für die Prüfungen, die auf einen Wert warten.\n\nExample: Beispiel\n```js\nconsole.log(DEF.delaywatcher); // 555\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 Grenzwerte der Anzeigegrößen in Pixeln.\n\nExample: Beispiel\n```js\nconsole.log(DEF.devices.sm); // {\"min\":768,\"max\":992}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nDie von [TRANSLATE()](../globals/#translate) verwendeten Übersetzungen.\n\nExample: Beispiel\n```js\nLOCALIZE('hello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nDer Text, der in Datenbindungen für einen leeren Wert verwendet wird.\n\nExample: Beispiel\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.environment = { ts, date, time }\n\nType: `config`\n\nDie Variablen von [ENV()](../globals/#env).\n\nExample: Beispiel\n```js\nconsole.log(DEF.environment.date); // yyyy-MM-dd\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nDie URL von Komponenten, die auf der Seite nicht deklariert sind.\n\n`{0}` ist der Name der Komponente. Ein leerer Wert schaltet den Download ab.\n\nExample: Beispiel\n```js\nDEF.fallback = '';\nconsole.log(DEF.fallback === ''); // true\n```\n\n### DEF.fallbackcache = ''\n\nType: `config`\n\nWie lange heruntergeladene Komponenten im Cache bleiben.\n\nExample: Beispiel\n```js\nDEF.fallbackcache = '1 day';\nconsole.log(DEF.fallbackcache); // 1 day\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nDie Header jeder Anfrage.\n\nExample: Beispiel\n```js\nDEF.headers['X-App'] = 'shop';\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-App']); // shop\n\topt.respond({});\n});\nAJAX('GET /api/', NOOP);\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nDas Präfix von Icon-Namen in `component.icon()`.\n\nExample: Beispiel\n```js\nconsole.log(DEF.iconprefix); // ti ti-\n```\n\n### DEF.importcache = 'session'\n\nType: `config`\n\nWie lange Inhalte aus `<ui-import>` im Cache bleiben.\n\nExample: Beispiel\n```js\nconsole.log(DEF.importcache); // session\n```\n\n### DEF.jsoncompress = false\n\nType: `config`\n\nDer Standardwert des Arguments `compress` von [STRINGIFY()](../globals/#stringify).\n\nExample: Beispiel\n```js\nDEF.jsoncompress = true;\nconsole.log(STRINGIFY({ a: 1, b: '' })); // {\"a\":1}\n```\n\n### DEF.jsonconverter = { 'text json': fn }\n\nType: `config`\n\nDie Konverter für Antworten auf Anfragen.\n\nExample: Beispiel\n```js\nconsole.log(typeof(DEF.jsonconverter['text json'])); // function\n```\n\n### DEF.jsondate = true\n\nType: `config`\n\nWandelt beim Parsen von JSON ISO-Datumsangaben in `Date`-Objekte um.\n\nExample: Beispiel\n```js\nDEF.jsondate = false;\nconsole.log(typeof(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d)); // string\n```\n\n### DEF.keypress = true\n\nType: `config`\n\nLässt Eingabefelder reagieren, während der Benutzer tippt.\n\nExample: Beispiel\n```js\nconsole.log(DEF.keypress); // true\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nDie Sprache, die der URL jeder Anfrage hinzugefügt wird.\n\nExample: Beispiel\n```js\nDEF.language = 'sk';\nconsole.log(DEF.language); // sk\n```\n\n### DEF.languagehtml = undefined\n\nType: `config`\n\nDie Sprache, die nur der URL von `.html`-Anfragen hinzugefügt wird.\n\nExample: Beispiel\n```js\nDEF.languagehtml = 'sk';\nconsole.log(DEF.languagehtml); // sk\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nDer Name des Query-Arguments mit der Sprache.\n\nExample: Beispiel\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nDas Präfix der Schlüssel im Browser-Speicher.\n\nExample: Beispiel\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.makeurl = null\n\nType: `config`\n\nEine Funktion, die die URL jeder Anfrage ändert.\n\nExample: Beispiel\n```js\nDEF.makeurl = url => url + '?v=2';\nconsole.log(typeof(DEF.makeurl)); // function\n```\n\n### DEF.monitor = false\n\nType: `config`\n\nSammelt Nutzungszähler in [M.performance](../m/#performance).\n\nExample: Beispiel\n```js\nDEF.monitor = true;\nSET('a', 1);\nconsole.log(M.performance.set.count > 0); // true\n```\n\n### DEF.pathcl = 'DEF.cl.'\n\nType: `config`\n\nDer Path hinter dem Präfix `#`.\n\nExample: Beispiel\n```js\nconsole.log(DEF.pathcl); // DEF.cl.\n```\n\n### DEF.pathcommon = 'common.'\n\nType: `config`\n\nDer Path hinter dem Präfix `*`.\n\nExample: Beispiel\n```js\nSET('*title', 'Hello');\nconsole.log(GET('common.title')); // Hello\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nDas CSS-Präfix, das an Komponentendeklarationen übergeben wird.\n\nExample: Beispiel\n```js\nconsole.log(DEF.prefixcsscomponents); // ui-\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nDas CSS-Präfix der Klassen der Bibliothek.\n\nExample: Beispiel\n```js\nconsole.log(DEF.prefixcsslibrary); // ui-\n```\n\n### DEF.prefixcssmacros = 'm-'\n\nType: `config`\n\nDas CSS-Präfix, das an Macro-Deklarationen übergeben wird.\n\nExample: Beispiel\n```js\nconsole.log(DEF.prefixcssmacros); // m-\n```\n\n### DEF.regexp = { int, float, date, pluralize, format }\n\nType: `config`\n\nDie regulären Ausdrücke der String- und Datums-Helper.\n\nExample: Beispiel\n```js\nconsole.log(DEF.regexp.int instanceof RegExp); // true\n```\n\n### DEF.repeatfocus = true\n\nType: `config`\n\nPausiert [REPEAT()](../globals/#repeat), solange die Seite im Hintergrund ist.\n\nExample: Beispiel\n```js\nconsole.log(DEF.repeatfocus); // true\n```\n\n### DEF.root = ''\n\nType: `config`\n\nEin Präfix für relative URLs, das Vorrang vor `DEF.baseurl` hat.\n\nEin String oder eine Funktion, die die URL erhält und eine neue zurückgibt.\n\nExample: Beispiel\n```js\nDEF.root = '/shop';\nconsole.log('/users/'.ROOT()); // /shop/users/\n```\n\n### DEF.scope = window\n\nType: `config`\n\nDas Objekt, in dem Paths gespeichert werden.\n\nExample: Beispiel\n```js\nconsole.log(DEF.scope === window); // true\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnimiert benutzerdefinierte Scrollbars am Ende des Inhalts.\n\nExample: Beispiel\n```js\nconsole.log(DEF.scrollbaranimate); // true\n```\n\n### DEF.secret = function\n\nType: `config`\n\nLegt den Schlüssel fest, der die Daten von Anfragen verschlüsselt.\n\nRufe die Funktion als `DEF.secret(key, [validator], [html])` auf. `validator` ist eine Funktion, die die Optionen der Anfrage erhält und entscheidet, ob sie verschlüsselt werden. Mit `true` als `html` werden auch Antworten für `.html`-Dateien entschlüsselt. Die Funktion entfernt sich nach dem ersten Aufruf selbst.\n\nExample: Beispiel\n```js\nDEF.secret('my-key');\nconsole.log(DEF.secret === undefined); // true\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nDas Tausendertrennzeichen formatierter Zahlen.\n\nExample: Beispiel\n```js\nconsole.log((1500).format(0)); // 1 500\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nDas Standard-Zeitformat in `DEF.environment`.\n\nExample: Beispiel\n```js\nconsole.log(DEF.timeformat); // HH:mm\n```\n\n### DEF.validators = { url, phone, email }\n\nType: `config`\n\nDie regulären Ausdrücke von `String.isURL()`, `String.isPhone()` und `String.isEmail()`.\n\nExample: Beispiel\n```js\nconsole.log(DEF.validators.email.test('a@b.com')); // true\n```\n\n### DEF.version = ''\n\nType: `config`\n\nDie Version, die der URL jeder Anfrage hinzugefügt wird.\n\nExample: Beispiel\n```js\nDEF.version = '1.2';\nconsole.log(DEF.version); // 1.2\n```\n\n### DEF.versioncomponents = ''\n\nType: `config`\n\nDie Version von Komponenten, die ohne Version verwendet werden.\n\nExample: Beispiel\n```js\nconsole.log(DEF.versioncomponents === ''); // true\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nDie Version, die nur der URL von `.html`-Anfragen hinzugefügt wird.\n\nExample: Beispiel\n```js\nDEF.versionhtml = '1.2';\nconsole.log(DEF.versionhtml); // 1.2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nDer Name des Query-Arguments mit der Version.\n\nExample: Beispiel\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.webcomponentsonly = undefined\n\nType: `config`\n\nMit `true` wird die Seite nur nach den `<ui-*>`-Elementen durchsucht.\n\nExample: Beispiel\n```js\nDEF.webcomponentsonly = true;\nconsole.log(DEF.webcomponentsonly); // true\n```\n","entries":[{"type":"config","name":"DEF.ajaxcredentials","signature":"DEF.ajaxcredentials = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxcredentialshtml","signature":"DEF.ajaxcredentialshtml = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxerrors","signature":"DEF.ajaxerrors = false","since":"","deprecated":false},{"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.csrf","signature":"DEF.csrf = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.customelements","signature":"DEF.customelements = false","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.delay","signature":"DEF.delay = 555","since":"","deprecated":false},{"type":"config","name":"DEF.delaybinder","signature":"DEF.delaybinder = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaykeypress","signature":"DEF.delaykeypress = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaypref","signature":"DEF.delaypref = 1000","since":"","deprecated":false},{"type":"config","name":"DEF.delayrepeat","signature":"DEF.delayrepeat = 2000","since":"","deprecated":false},{"type":"config","name":"DEF.delaywatcher","signature":"DEF.delaywatcher = 555","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.environment","signature":"DEF.environment = { ts, date, time }","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.fallbackcache","signature":"DEF.fallbackcache = ''","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.importcache","signature":"DEF.importcache = 'session'","since":"","deprecated":false},{"type":"config","name":"DEF.jsoncompress","signature":"DEF.jsoncompress = false","since":"","deprecated":false},{"type":"config","name":"DEF.jsonconverter","signature":"DEF.jsonconverter = { 'text json': fn }","since":"","deprecated":false},{"type":"config","name":"DEF.jsondate","signature":"DEF.jsondate = true","since":"","deprecated":false},{"type":"config","name":"DEF.keypress","signature":"DEF.keypress = true","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagehtml","signature":"DEF.languagehtml = 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.makeurl","signature":"DEF.makeurl = null","since":"","deprecated":false},{"type":"config","name":"DEF.monitor","signature":"DEF.monitor = false","since":"","deprecated":false},{"type":"config","name":"DEF.pathcl","signature":"DEF.pathcl = 'DEF.cl.'","since":"","deprecated":false},{"type":"config","name":"DEF.pathcommon","signature":"DEF.pathcommon = 'common.'","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.prefixcssmacros","signature":"DEF.prefixcssmacros = 'm-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format }","since":"","deprecated":false},{"type":"config","name":"DEF.repeatfocus","signature":"DEF.repeatfocus = true","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scope","signature":"DEF.scope = window","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.secret","signature":"DEF.secret = function","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.validators","signature":"DEF.validators = { url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = ''","since":"","deprecated":false},{"type":"config","name":"DEF.versioncomponents","signature":"DEF.versioncomponents = ''","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.webcomponentsonly","signature":"DEF.webcomponentsonly = undefined","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammXp6QM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/def/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"DEF","summary":"Las opciones de configuración de la biblioteca.","markdown":"---\ntitle: DEF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/def/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# DEF\n\n> Las opciones de configuración de la biblioteca.\n\n`DEF` contiene la configuración de la biblioteca. Define las opciones en un script justo después de cargar la biblioteca, antes de que se inicien los primeros componentes. Para ver cómo encajan las opciones entre sí, lee [Primeros pasos](../../guides/getting-started/).\n\n## API\n\n### DEF.ajaxcredentials = false\n\nType: `config`\n\nEnvía las cookies con cada petición.\n\nExample: Ejemplo\n```js\nDEF.ajaxcredentials = true;\nconsole.log(DEF.ajaxcredentials); // true\n```\n\n### DEF.ajaxcredentialshtml = false\n\nType: `config`\n\nTambién envía las cookies con las peticiones de archivos `.html` cuando `DEF.ajaxcredentials` está activado.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.ajaxcredentialshtml); // false\n```\n\n### DEF.ajaxerrors = false\n\nType: `config`\n\nTrata las respuestas de error como respuestas normales.\n\nCon `true`, no se emite el evento `error` y la Promise de una petición no se rechaza.\n\nExample: Ejemplo\n```js\nDEF.ajaxerrors = true;\nON('request', opt => opt.throw('Failed', 500));\nAJAX('GET /api/', function(response, err) {\n\tconsole.log(response, err); // Failed 500\n});\n```\n\n### DEF.api = undefined\n\nType: `config`\n\nEl endpoint predeterminado de [DAPI()](../globals/#dapi) y [TAPI()](../globals/#tapi).\n\nUna URL, o una función que recibe el nombre y los datos y devuelve el valor para `API()`.\n\nExample: Ejemplo\n```js\nDEF.api = '/api/';\nconsole.log(DEF.api); // /api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nUn prefijo de las URL relativas de las peticiones.\n\nUna cadena, o una función que recibe la URL y devuelve una nueva.\n\nExample: Ejemplo\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nEl valor del marcador `~CDN~` en el contenido importado.\n\nExample: Ejemplo\n```js\nDEF.cdn = '//cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nLas listas de códigos cargadas, por nombre.\n\nExample: Ejemplo\n```js\nCL_INIT('roles', next => next(['admin']), true);\nconsole.log(DEF.cl.roles); // [\"admin\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nEl color principal de la aplicación.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.color); // #4285F4\n```\n\n### DEF.csrf = undefined\n\nType: `config`\n\nUn token que se envía en la cabecera `x-csrf-token`.\n\nLas peticiones de archivos `.html` no lo envían.\n\nExample: Ejemplo\n```js\nDEF.csrf = 'abc';\nON('request', function(opt) {\n\tconsole.log(opt.headers['x-csrf-token']); // abc\n\topt.respond({});\n});\nAJAX('POST /api/', {}, NOOP);\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nFunciones que dan formato de moneda a los números.\n\nExample: Ejemplo\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log((5).currency('eur')); // 5.00 EUR\n```\n\n### DEF.currency = undefined\n\nType: `config`\n\nLa moneda predeterminada de `Number.currency()`.\n\nExample: Ejemplo\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currency = 'eur';\nconsole.log((5).currency()); // 5.00 EUR\n```\n\n### DEF.customelements = false\n\nType: `config`\n\nRegistra cada componente como su propio elemento, `<ui-name>`.\n\nDefínelo antes de declarar los componentes.\n\nExample: Ejemplo\n```js\nDEF.customelements = true;\nCOMPONENT('hello', function(self) {\n\tself.make = () => self.element.text('Hi');\n});\nconsole.log(customElements.get('ui-hello') != null); // true\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nEl formato predeterminado de `Date.format()`.\n\nExample: Ejemplo\n```js\nconsole.log(new Date(2024, 0, 15).format()); // 2024-01-15\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nDa formato a las fechas en UTC.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.dateformatutc); // false\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nEl separador decimal de los números con formato.\n\nExample: Ejemplo\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.delay = 555\n\nType: `config`\n\nEl retraso en milisegundos antes de volver a intentar una petición con el flag `sync`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEF.delaybinder = 200\n\nType: `config`\n\nEl retraso en milisegundos de los enlaces de datos retrasados.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.delaybinder); // 200\n```\n\n### DEF.delaykeypress = 200\n\nType: `config`\n\nEl retraso en milisegundos después de pulsar una tecla en un campo.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.delaykeypress); // 200\n```\n\n### DEF.delaypref = 1000\n\nType: `config`\n\nEl retraso en milisegundos antes de guardar [PREF](../pref/).\n\nExample: Ejemplo\n```js\nconsole.log(DEF.delaypref); // 1000\n```\n\n### DEF.delayrepeat = 2000\n\nType: `config`\n\nEl retraso en milisegundos antes de volver a enviar una petición con el flag `repeat`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.delayrepeat); // 2000\n```\n\n### DEF.delaywatcher = 555\n\nType: `config`\n\nEl intervalo en milisegundos de las comprobaciones que esperan un valor.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.delaywatcher); // 555\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 límites de los tamaños de pantalla en píxeles.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.devices.sm); // {\"min\":768,\"max\":992}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nLas traducciones que usa [TRANSLATE()](../globals/#translate).\n\nExample: Ejemplo\n```js\nLOCALIZE('hello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nEl texto que se usa para un valor vacío en los enlaces de datos.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.environment = { ts, date, time }\n\nType: `config`\n\nLas variables de [ENV()](../globals/#env).\n\nExample: Ejemplo\n```js\nconsole.log(DEF.environment.date); // yyyy-MM-dd\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nLa URL de los componentes que no están declarados en la página.\n\n`{0}` es el nombre del componente. Un valor vacío desactiva la descarga.\n\nExample: Ejemplo\n```js\nDEF.fallback = '';\nconsole.log(DEF.fallback === ''); // true\n```\n\n### DEF.fallbackcache = ''\n\nType: `config`\n\nCuánto tiempo se guardan en caché los componentes descargados.\n\nExample: Ejemplo\n```js\nDEF.fallbackcache = '1 day';\nconsole.log(DEF.fallbackcache); // 1 day\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nLas cabeceras de cada petición.\n\nExample: Ejemplo\n```js\nDEF.headers['X-App'] = 'shop';\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-App']); // shop\n\topt.respond({});\n});\nAJAX('GET /api/', NOOP);\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nEl prefijo de los nombres de iconos en `component.icon()`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.iconprefix); // ti ti-\n```\n\n### DEF.importcache = 'session'\n\nType: `config`\n\nCuánto tiempo se guarda en caché el contenido de `<ui-import>`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.importcache); // session\n```\n\n### DEF.jsoncompress = false\n\nType: `config`\n\nEl valor predeterminado del argumento `compress` de [STRINGIFY()](../globals/#stringify).\n\nExample: Ejemplo\n```js\nDEF.jsoncompress = true;\nconsole.log(STRINGIFY({ a: 1, b: '' })); // {\"a\":1}\n```\n\n### DEF.jsonconverter = { 'text json': fn }\n\nType: `config`\n\nLos conversores de las respuestas de las peticiones.\n\nExample: Ejemplo\n```js\nconsole.log(typeof(DEF.jsonconverter['text json'])); // function\n```\n\n### DEF.jsondate = true\n\nType: `config`\n\nConvierte las fechas ISO en objetos `Date` al analizar JSON.\n\nExample: Ejemplo\n```js\nDEF.jsondate = false;\nconsole.log(typeof(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d)); // string\n```\n\n### DEF.keypress = true\n\nType: `config`\n\nHace que los campos reaccionen mientras el usuario escribe.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.keypress); // true\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nEl idioma que se añade a la URL de cada petición.\n\nExample: Ejemplo\n```js\nDEF.language = 'sk';\nconsole.log(DEF.language); // sk\n```\n\n### DEF.languagehtml = undefined\n\nType: `config`\n\nEl idioma que se añade solo a la URL de las peticiones `.html`.\n\nExample: Ejemplo\n```js\nDEF.languagehtml = 'sk';\nconsole.log(DEF.languagehtml); // sk\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nEl nombre del argumento de consulta con el idioma.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nEl prefijo de las claves en el almacenamiento del navegador.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.makeurl = null\n\nType: `config`\n\nUna función que modifica la URL de cada petición.\n\nExample: Ejemplo\n```js\nDEF.makeurl = url => url + '?v=2';\nconsole.log(typeof(DEF.makeurl)); // function\n```\n\n### DEF.monitor = false\n\nType: `config`\n\nRecopila contadores de uso en [M.performance](../m/#performance).\n\nExample: Ejemplo\n```js\nDEF.monitor = true;\nSET('a', 1);\nconsole.log(M.performance.set.count > 0); // true\n```\n\n### DEF.pathcl = 'DEF.cl.'\n\nType: `config`\n\nEl path que hay detrás del prefijo `#`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.pathcl); // DEF.cl.\n```\n\n### DEF.pathcommon = 'common.'\n\nType: `config`\n\nEl path que hay detrás del prefijo `*`.\n\nExample: Ejemplo\n```js\nSET('*title', 'Hello');\nconsole.log(GET('common.title')); // Hello\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nEl prefijo CSS que se pasa a las declaraciones de componentes.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.prefixcsscomponents); // ui-\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nEl prefijo CSS de las clases de la biblioteca.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.prefixcsslibrary); // ui-\n```\n\n### DEF.prefixcssmacros = 'm-'\n\nType: `config`\n\nEl prefijo CSS que se pasa a las declaraciones de macros.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.prefixcssmacros); // m-\n```\n\n### DEF.regexp = { int, float, date, pluralize, format }\n\nType: `config`\n\nLas expresiones regulares de los helpers de cadenas y fechas.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.regexp.int instanceof RegExp); // true\n```\n\n### DEF.repeatfocus = true\n\nType: `config`\n\nPausa [REPEAT()](../globals/#repeat) mientras la página está en segundo plano.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.repeatfocus); // true\n```\n\n### DEF.root = ''\n\nType: `config`\n\nUn prefijo de las URL relativas que tiene prioridad sobre `DEF.baseurl`.\n\nUna cadena, o una función que recibe la URL y devuelve una nueva.\n\nExample: Ejemplo\n```js\nDEF.root = '/shop';\nconsole.log('/users/'.ROOT()); // /shop/users/\n```\n\n### DEF.scope = window\n\nType: `config`\n\nEl objeto en el que se guardan los paths.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.scope === window); // true\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnima las barras de desplazamiento personalizadas al final del contenido.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.scrollbaranimate); // true\n```\n\n### DEF.secret = function\n\nType: `config`\n\nDefine la clave que cifra los datos de las peticiones.\n\nLlámala como `DEF.secret(key, [validator], [html])`. `validator` es una función que recibe las opciones de la petición y decide si se cifran. Con `true` en `html`, también se descifran las respuestas de archivos `.html`. La función se elimina a sí misma después de la primera llamada.\n\nExample: Ejemplo\n```js\nDEF.secret('my-key');\nconsole.log(DEF.secret === undefined); // true\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nEl separador de miles de los números con formato.\n\nExample: Ejemplo\n```js\nconsole.log((1500).format(0)); // 1 500\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nEl formato de hora predeterminado en `DEF.environment`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.timeformat); // HH:mm\n```\n\n### DEF.validators = { url, phone, email }\n\nType: `config`\n\nLas expresiones regulares de `String.isURL()`, `String.isPhone()` y `String.isEmail()`.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.validators.email.test('a@b.com')); // true\n```\n\n### DEF.version = ''\n\nType: `config`\n\nLa versión que se añade a la URL de cada petición.\n\nExample: Ejemplo\n```js\nDEF.version = '1.2';\nconsole.log(DEF.version); // 1.2\n```\n\n### DEF.versioncomponents = ''\n\nType: `config`\n\nLa versión de los componentes que se usan sin versión.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.versioncomponents === ''); // true\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nLa versión que se añade solo a la URL de las peticiones `.html`.\n\nExample: Ejemplo\n```js\nDEF.versionhtml = '1.2';\nconsole.log(DEF.versionhtml); // 1.2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nEl nombre del argumento de consulta con la versión.\n\nExample: Ejemplo\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.webcomponentsonly = undefined\n\nType: `config`\n\nCon `true`, en la página solo se buscan los elementos `<ui-*>`.\n\nExample: Ejemplo\n```js\nDEF.webcomponentsonly = true;\nconsole.log(DEF.webcomponentsonly); // true\n```\n","entries":[{"type":"config","name":"DEF.ajaxcredentials","signature":"DEF.ajaxcredentials = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxcredentialshtml","signature":"DEF.ajaxcredentialshtml = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxerrors","signature":"DEF.ajaxerrors = false","since":"","deprecated":false},{"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.csrf","signature":"DEF.csrf = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.customelements","signature":"DEF.customelements = false","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.delay","signature":"DEF.delay = 555","since":"","deprecated":false},{"type":"config","name":"DEF.delaybinder","signature":"DEF.delaybinder = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaykeypress","signature":"DEF.delaykeypress = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaypref","signature":"DEF.delaypref = 1000","since":"","deprecated":false},{"type":"config","name":"DEF.delayrepeat","signature":"DEF.delayrepeat = 2000","since":"","deprecated":false},{"type":"config","name":"DEF.delaywatcher","signature":"DEF.delaywatcher = 555","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.environment","signature":"DEF.environment = { ts, date, time }","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.fallbackcache","signature":"DEF.fallbackcache = ''","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.importcache","signature":"DEF.importcache = 'session'","since":"","deprecated":false},{"type":"config","name":"DEF.jsoncompress","signature":"DEF.jsoncompress = false","since":"","deprecated":false},{"type":"config","name":"DEF.jsonconverter","signature":"DEF.jsonconverter = { 'text json': fn }","since":"","deprecated":false},{"type":"config","name":"DEF.jsondate","signature":"DEF.jsondate = true","since":"","deprecated":false},{"type":"config","name":"DEF.keypress","signature":"DEF.keypress = true","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagehtml","signature":"DEF.languagehtml = 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.makeurl","signature":"DEF.makeurl = null","since":"","deprecated":false},{"type":"config","name":"DEF.monitor","signature":"DEF.monitor = false","since":"","deprecated":false},{"type":"config","name":"DEF.pathcl","signature":"DEF.pathcl = 'DEF.cl.'","since":"","deprecated":false},{"type":"config","name":"DEF.pathcommon","signature":"DEF.pathcommon = 'common.'","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.prefixcssmacros","signature":"DEF.prefixcssmacros = 'm-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format }","since":"","deprecated":false},{"type":"config","name":"DEF.repeatfocus","signature":"DEF.repeatfocus = true","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scope","signature":"DEF.scope = window","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.secret","signature":"DEF.secret = function","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.validators","signature":"DEF.validators = { url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = ''","since":"","deprecated":false},{"type":"config","name":"DEF.versioncomponents","signature":"DEF.versioncomponents = ''","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.webcomponentsonly","signature":"DEF.webcomponentsonly = undefined","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammXp6QM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/def/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"DEF","summary":"Les options de configuration de la bibliothèque.","markdown":"---\ntitle: DEF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/def/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# DEF\n\n> Les options de configuration de la bibliothèque.\n\n`DEF` contient la configuration de la bibliothèque. Définis les options dans un script juste après le chargement de la bibliothèque, avant le démarrage des premiers composants. Pour voir comment les options s'articulent, lis [Premiers pas](../../guides/getting-started/).\n\n## API\n\n### DEF.ajaxcredentials = false\n\nType: `config`\n\nEnvoie les cookies avec chaque requête.\n\nExample: Exemple\n```js\nDEF.ajaxcredentials = true;\nconsole.log(DEF.ajaxcredentials); // true\n```\n\n### DEF.ajaxcredentialshtml = false\n\nType: `config`\n\nEnvoie aussi les cookies avec les requêtes de fichiers `.html` quand `DEF.ajaxcredentials` est activé.\n\nExample: Exemple\n```js\nconsole.log(DEF.ajaxcredentialshtml); // false\n```\n\n### DEF.ajaxerrors = false\n\nType: `config`\n\nTraite les réponses d'erreur comme des réponses normales.\n\nAvec `true`, l'événement `error` n'est pas émis et la Promise d'une requête n'est pas rejetée.\n\nExample: Exemple\n```js\nDEF.ajaxerrors = true;\nON('request', opt => opt.throw('Failed', 500));\nAJAX('GET /api/', function(response, err) {\n\tconsole.log(response, err); // Failed 500\n});\n```\n\n### DEF.api = undefined\n\nType: `config`\n\nLe point de terminaison par défaut de [DAPI()](../globals/#dapi) et de [TAPI()](../globals/#tapi).\n\nUne URL, ou une fonction qui reçoit le nom et les données et renvoie la valeur pour `API()`.\n\nExample: Exemple\n```js\nDEF.api = '/api/';\nconsole.log(DEF.api); // /api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nUn préfixe des URL de requête relatives.\n\nUne chaîne, ou une fonction qui reçoit l'URL et en renvoie une nouvelle.\n\nExample: Exemple\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nLa valeur du marqueur `~CDN~` dans le contenu importé.\n\nExample: Exemple\n```js\nDEF.cdn = '//cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nLes listes de codes chargées, classées par nom.\n\nExample: Exemple\n```js\nCL_INIT('roles', next => next(['admin']), true);\nconsole.log(DEF.cl.roles); // [\"admin\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nLa couleur principale de l'application.\n\nExample: Exemple\n```js\nconsole.log(DEF.color); // #4285F4\n```\n\n### DEF.csrf = undefined\n\nType: `config`\n\nUn jeton envoyé dans l'en-tête `x-csrf-token`.\n\nLes requêtes de fichiers `.html` ne l'envoient pas.\n\nExample: Exemple\n```js\nDEF.csrf = 'abc';\nON('request', function(opt) {\n\tconsole.log(opt.headers['x-csrf-token']); // abc\n\topt.respond({});\n});\nAJAX('POST /api/', {}, NOOP);\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nLes fonctions qui formatent les nombres en devises.\n\nExample: Exemple\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log((5).currency('eur')); // 5.00 EUR\n```\n\n### DEF.currency = undefined\n\nType: `config`\n\nLa devise par défaut de `Number.currency()`.\n\nExample: Exemple\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currency = 'eur';\nconsole.log((5).currency()); // 5.00 EUR\n```\n\n### DEF.customelements = false\n\nType: `config`\n\nEnregistre chaque composant comme son propre élément, `<ui-name>`.\n\nDéfinis-le avant de déclarer les composants.\n\nExample: Exemple\n```js\nDEF.customelements = true;\nCOMPONENT('hello', function(self) {\n\tself.make = () => self.element.text('Hi');\n});\nconsole.log(customElements.get('ui-hello') != null); // true\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nLe format par défaut de `Date.format()`.\n\nExample: Exemple\n```js\nconsole.log(new Date(2024, 0, 15).format()); // 2024-01-15\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormate les dates en UTC.\n\nExample: Exemple\n```js\nconsole.log(DEF.dateformatutc); // false\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nLe séparateur décimal des nombres formatés.\n\nExample: Exemple\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.delay = 555\n\nType: `config`\n\nLe délai en millisecondes avant une nouvelle tentative d'une requête portant le flag `sync`.\n\nExample: Exemple\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEF.delaybinder = 200\n\nType: `config`\n\nLe délai en millisecondes des liaisons de données différées.\n\nExample: Exemple\n```js\nconsole.log(DEF.delaybinder); // 200\n```\n\n### DEF.delaykeypress = 200\n\nType: `config`\n\nLe délai en millisecondes après une frappe dans un champ de saisie.\n\nExample: Exemple\n```js\nconsole.log(DEF.delaykeypress); // 200\n```\n\n### DEF.delaypref = 1000\n\nType: `config`\n\nLe délai en millisecondes avant l'enregistrement de [PREF](../pref/).\n\nExample: Exemple\n```js\nconsole.log(DEF.delaypref); // 1000\n```\n\n### DEF.delayrepeat = 2000\n\nType: `config`\n\nLe délai en millisecondes avant le renvoi d'une requête portant le flag `repeat`.\n\nExample: Exemple\n```js\nconsole.log(DEF.delayrepeat); // 2000\n```\n\n### DEF.delaywatcher = 555\n\nType: `config`\n\nL'intervalle en millisecondes des vérifications qui attendent une valeur.\n\nExample: Exemple\n```js\nconsole.log(DEF.delaywatcher); // 555\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 limites des tailles d'affichage en pixels.\n\nExample: Exemple\n```js\nconsole.log(DEF.devices.sm); // {\"min\":768,\"max\":992}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nLes traductions utilisées par [TRANSLATE()](../globals/#translate).\n\nExample: Exemple\n```js\nLOCALIZE('hello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nLe texte utilisé pour une valeur vide dans les liaisons de données.\n\nExample: Exemple\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.environment = { ts, date, time }\n\nType: `config`\n\nLes variables de [ENV()](../globals/#env).\n\nExample: Exemple\n```js\nconsole.log(DEF.environment.date); // yyyy-MM-dd\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nL'URL des composants qui ne sont pas déclarés sur la page.\n\n`{0}` est le nom du composant. Une valeur vide désactive le téléchargement.\n\nExample: Exemple\n```js\nDEF.fallback = '';\nconsole.log(DEF.fallback === ''); // true\n```\n\n### DEF.fallbackcache = ''\n\nType: `config`\n\nLa durée de mise en cache des composants téléchargés.\n\nExample: Exemple\n```js\nDEF.fallbackcache = '1 day';\nconsole.log(DEF.fallbackcache); // 1 day\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nLes en-têtes de chaque requête.\n\nExample: Exemple\n```js\nDEF.headers['X-App'] = 'shop';\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-App']); // shop\n\topt.respond({});\n});\nAJAX('GET /api/', NOOP);\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nLe préfixe des noms d'icônes dans `component.icon()`.\n\nExample: Exemple\n```js\nconsole.log(DEF.iconprefix); // ti ti-\n```\n\n### DEF.importcache = 'session'\n\nType: `config`\n\nLa durée de mise en cache du contenu de `<ui-import>`.\n\nExample: Exemple\n```js\nconsole.log(DEF.importcache); // session\n```\n\n### DEF.jsoncompress = false\n\nType: `config`\n\nLa valeur par défaut de l'argument `compress` de [STRINGIFY()](../globals/#stringify).\n\nExample: Exemple\n```js\nDEF.jsoncompress = true;\nconsole.log(STRINGIFY({ a: 1, b: '' })); // {\"a\":1}\n```\n\n### DEF.jsonconverter = { 'text json': fn }\n\nType: `config`\n\nLes convertisseurs des réponses aux requêtes.\n\nExample: Exemple\n```js\nconsole.log(typeof(DEF.jsonconverter['text json'])); // function\n```\n\n### DEF.jsondate = true\n\nType: `config`\n\nConvertit les dates ISO en objets `Date` lors de l'analyse du JSON.\n\nExample: Exemple\n```js\nDEF.jsondate = false;\nconsole.log(typeof(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d)); // string\n```\n\n### DEF.keypress = true\n\nType: `config`\n\nFait réagir les champs de saisie pendant la frappe de l'utilisateur.\n\nExample: Exemple\n```js\nconsole.log(DEF.keypress); // true\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nLa langue ajoutée à l'URL de chaque requête.\n\nExample: Exemple\n```js\nDEF.language = 'sk';\nconsole.log(DEF.language); // sk\n```\n\n### DEF.languagehtml = undefined\n\nType: `config`\n\nLa langue ajoutée à l'URL des requêtes `.html` uniquement.\n\nExample: Exemple\n```js\nDEF.languagehtml = 'sk';\nconsole.log(DEF.languagehtml); // sk\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nLe nom du paramètre de requête contenant la langue.\n\nExample: Exemple\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nLe préfixe des clés dans le stockage du navigateur.\n\nExample: Exemple\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.makeurl = null\n\nType: `config`\n\nUne fonction qui modifie l'URL de chaque requête.\n\nExample: Exemple\n```js\nDEF.makeurl = url => url + '?v=2';\nconsole.log(typeof(DEF.makeurl)); // function\n```\n\n### DEF.monitor = false\n\nType: `config`\n\nCollecte des compteurs d'utilisation dans [M.performance](../m/#performance).\n\nExample: Exemple\n```js\nDEF.monitor = true;\nSET('a', 1);\nconsole.log(M.performance.set.count > 0); // true\n```\n\n### DEF.pathcl = 'DEF.cl.'\n\nType: `config`\n\nLe path derrière le préfixe `#`.\n\nExample: Exemple\n```js\nconsole.log(DEF.pathcl); // DEF.cl.\n```\n\n### DEF.pathcommon = 'common.'\n\nType: `config`\n\nLe path derrière le préfixe `*`.\n\nExample: Exemple\n```js\nSET('*title', 'Hello');\nconsole.log(GET('common.title')); // Hello\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nLe préfixe CSS passé aux déclarations de composants.\n\nExample: Exemple\n```js\nconsole.log(DEF.prefixcsscomponents); // ui-\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nLe préfixe CSS des classes de la bibliothèque.\n\nExample: Exemple\n```js\nconsole.log(DEF.prefixcsslibrary); // ui-\n```\n\n### DEF.prefixcssmacros = 'm-'\n\nType: `config`\n\nLe préfixe CSS passé aux déclarations de macros.\n\nExample: Exemple\n```js\nconsole.log(DEF.prefixcssmacros); // m-\n```\n\n### DEF.regexp = { int, float, date, pluralize, format }\n\nType: `config`\n\nLes expressions régulières des helpers de chaînes et de dates.\n\nExample: Exemple\n```js\nconsole.log(DEF.regexp.int instanceof RegExp); // true\n```\n\n### DEF.repeatfocus = true\n\nType: `config`\n\nMet [REPEAT()](../globals/#repeat) en pause tant que la page est en arrière-plan.\n\nExample: Exemple\n```js\nconsole.log(DEF.repeatfocus); // true\n```\n\n### DEF.root = ''\n\nType: `config`\n\nUn préfixe des URL relatives, prioritaire sur `DEF.baseurl`.\n\nUne chaîne, ou une fonction qui reçoit l'URL et en renvoie une nouvelle.\n\nExample: Exemple\n```js\nDEF.root = '/shop';\nconsole.log('/users/'.ROOT()); // /shop/users/\n```\n\n### DEF.scope = window\n\nType: `config`\n\nL'objet dans lequel les paths sont stockés.\n\nExample: Exemple\n```js\nconsole.log(DEF.scope === window); // true\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnime les barres de défilement personnalisées à la fin du contenu.\n\nExample: Exemple\n```js\nconsole.log(DEF.scrollbaranimate); // true\n```\n\n### DEF.secret = function\n\nType: `config`\n\nDéfinit la clé qui chiffre les données des requêtes.\n\nAppelle-la sous la forme `DEF.secret(key, [validator], [html])`. `validator` est une fonction qui reçoit les options de la requête et décide de les chiffrer ou non. Avec `true` pour `html`, les réponses des fichiers `.html` sont aussi déchiffrées. La fonction se supprime elle-même après le premier appel.\n\nExample: Exemple\n```js\nDEF.secret('my-key');\nconsole.log(DEF.secret === undefined); // true\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nLe séparateur des milliers des nombres formatés.\n\nExample: Exemple\n```js\nconsole.log((1500).format(0)); // 1 500\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nLe format d'heure par défaut dans `DEF.environment`.\n\nExample: Exemple\n```js\nconsole.log(DEF.timeformat); // HH:mm\n```\n\n### DEF.validators = { url, phone, email }\n\nType: `config`\n\nLes expressions régulières de `String.isURL()`, `String.isPhone()` et `String.isEmail()`.\n\nExample: Exemple\n```js\nconsole.log(DEF.validators.email.test('a@b.com')); // true\n```\n\n### DEF.version = ''\n\nType: `config`\n\nLa version ajoutée à l'URL de chaque requête.\n\nExample: Exemple\n```js\nDEF.version = '1.2';\nconsole.log(DEF.version); // 1.2\n```\n\n### DEF.versioncomponents = ''\n\nType: `config`\n\nLa version des composants utilisés sans version.\n\nExample: Exemple\n```js\nconsole.log(DEF.versioncomponents === ''); // true\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nLa version ajoutée à l'URL des requêtes `.html` uniquement.\n\nExample: Exemple\n```js\nDEF.versionhtml = '1.2';\nconsole.log(DEF.versionhtml); // 1.2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nLe nom du paramètre de requête contenant la version.\n\nExample: Exemple\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.webcomponentsonly = undefined\n\nType: `config`\n\nAvec `true`, la recherche sur la page se limite aux éléments `<ui-*>`.\n\nExample: Exemple\n```js\nDEF.webcomponentsonly = true;\nconsole.log(DEF.webcomponentsonly); // true\n```\n","entries":[{"type":"config","name":"DEF.ajaxcredentials","signature":"DEF.ajaxcredentials = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxcredentialshtml","signature":"DEF.ajaxcredentialshtml = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxerrors","signature":"DEF.ajaxerrors = false","since":"","deprecated":false},{"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.csrf","signature":"DEF.csrf = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.customelements","signature":"DEF.customelements = false","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.delay","signature":"DEF.delay = 555","since":"","deprecated":false},{"type":"config","name":"DEF.delaybinder","signature":"DEF.delaybinder = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaykeypress","signature":"DEF.delaykeypress = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaypref","signature":"DEF.delaypref = 1000","since":"","deprecated":false},{"type":"config","name":"DEF.delayrepeat","signature":"DEF.delayrepeat = 2000","since":"","deprecated":false},{"type":"config","name":"DEF.delaywatcher","signature":"DEF.delaywatcher = 555","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.environment","signature":"DEF.environment = { ts, date, time }","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.fallbackcache","signature":"DEF.fallbackcache = ''","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.importcache","signature":"DEF.importcache = 'session'","since":"","deprecated":false},{"type":"config","name":"DEF.jsoncompress","signature":"DEF.jsoncompress = false","since":"","deprecated":false},{"type":"config","name":"DEF.jsonconverter","signature":"DEF.jsonconverter = { 'text json': fn }","since":"","deprecated":false},{"type":"config","name":"DEF.jsondate","signature":"DEF.jsondate = true","since":"","deprecated":false},{"type":"config","name":"DEF.keypress","signature":"DEF.keypress = true","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagehtml","signature":"DEF.languagehtml = 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.makeurl","signature":"DEF.makeurl = null","since":"","deprecated":false},{"type":"config","name":"DEF.monitor","signature":"DEF.monitor = false","since":"","deprecated":false},{"type":"config","name":"DEF.pathcl","signature":"DEF.pathcl = 'DEF.cl.'","since":"","deprecated":false},{"type":"config","name":"DEF.pathcommon","signature":"DEF.pathcommon = 'common.'","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.prefixcssmacros","signature":"DEF.prefixcssmacros = 'm-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format }","since":"","deprecated":false},{"type":"config","name":"DEF.repeatfocus","signature":"DEF.repeatfocus = true","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scope","signature":"DEF.scope = window","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.secret","signature":"DEF.secret = function","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.validators","signature":"DEF.validators = { url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = ''","since":"","deprecated":false},{"type":"config","name":"DEF.versioncomponents","signature":"DEF.versioncomponents = ''","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.webcomponentsonly","signature":"DEF.webcomponentsonly = undefined","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammXp6QM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/def/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"DEF","summary":"Le opzioni di configurazione della libreria.","markdown":"---\ntitle: DEF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/def/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# DEF\n\n> Le opzioni di configurazione della libreria.\n\n`DEF` contiene la configurazione della libreria. Imposta le opzioni in uno script subito dopo il caricamento della libreria, prima dell'avvio dei primi componenti. Per vedere come si combinano le opzioni, leggi [Per iniziare](../../guides/getting-started/).\n\n## API\n\n### DEF.ajaxcredentials = false\n\nType: `config`\n\nInvia i cookie con ogni richiesta.\n\nExample: Esempio\n```js\nDEF.ajaxcredentials = true;\nconsole.log(DEF.ajaxcredentials); // true\n```\n\n### DEF.ajaxcredentialshtml = false\n\nType: `config`\n\nInvia i cookie anche con le richieste di file `.html` quando `DEF.ajaxcredentials` è attivo.\n\nExample: Esempio\n```js\nconsole.log(DEF.ajaxcredentialshtml); // false\n```\n\n### DEF.ajaxerrors = false\n\nType: `config`\n\nGestisce le risposte di errore come risposte normali.\n\nCon `true`, l'evento `error` non viene emesso e la Promise di una richiesta non viene rifiutata.\n\nExample: Esempio\n```js\nDEF.ajaxerrors = true;\nON('request', opt => opt.throw('Failed', 500));\nAJAX('GET /api/', function(response, err) {\n\tconsole.log(response, err); // Failed 500\n});\n```\n\n### DEF.api = undefined\n\nType: `config`\n\nL'endpoint predefinito di [DAPI()](../globals/#dapi) e [TAPI()](../globals/#tapi).\n\nUn URL, oppure una funzione che riceve il nome e i dati e restituisce il valore per `API()`.\n\nExample: Esempio\n```js\nDEF.api = '/api/';\nconsole.log(DEF.api); // /api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nUn prefisso degli URL relativi delle richieste.\n\nUna stringa, oppure una funzione che riceve l'URL e ne restituisce uno nuovo.\n\nExample: Esempio\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nIl valore del marcatore `~CDN~` nei contenuti importati.\n\nExample: Esempio\n```js\nDEF.cdn = '//cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nGli elenchi di codici caricati, per nome.\n\nExample: Esempio\n```js\nCL_INIT('roles', next => next(['admin']), true);\nconsole.log(DEF.cl.roles); // [\"admin\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nIl colore principale dell'applicazione.\n\nExample: Esempio\n```js\nconsole.log(DEF.color); // #4285F4\n```\n\n### DEF.csrf = undefined\n\nType: `config`\n\nUn token inviato nell'intestazione `x-csrf-token`.\n\nLe richieste di file `.html` non lo inviano.\n\nExample: Esempio\n```js\nDEF.csrf = 'abc';\nON('request', function(opt) {\n\tconsole.log(opt.headers['x-csrf-token']); // abc\n\topt.respond({});\n});\nAJAX('POST /api/', {}, NOOP);\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nLe funzioni che formattano i numeri come valute.\n\nExample: Esempio\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log((5).currency('eur')); // 5.00 EUR\n```\n\n### DEF.currency = undefined\n\nType: `config`\n\nLa valuta predefinita di `Number.currency()`.\n\nExample: Esempio\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currency = 'eur';\nconsole.log((5).currency()); // 5.00 EUR\n```\n\n### DEF.customelements = false\n\nType: `config`\n\nRegistra ogni componente come elemento a sé stante, `<ui-name>`.\n\nImpostala prima di dichiarare i componenti.\n\nExample: Esempio\n```js\nDEF.customelements = true;\nCOMPONENT('hello', function(self) {\n\tself.make = () => self.element.text('Hi');\n});\nconsole.log(customElements.get('ui-hello') != null); // true\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nIl formato predefinito di `Date.format()`.\n\nExample: Esempio\n```js\nconsole.log(new Date(2024, 0, 15).format()); // 2024-01-15\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormatta le date in UTC.\n\nExample: Esempio\n```js\nconsole.log(DEF.dateformatutc); // false\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nIl separatore decimale dei numeri formattati.\n\nExample: Esempio\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.delay = 555\n\nType: `config`\n\nIl ritardo in millisecondi prima che una richiesta con il flag `sync` venga ritentata.\n\nExample: Esempio\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEF.delaybinder = 200\n\nType: `config`\n\nIl ritardo in millisecondi delle associazioni dei dati ritardate.\n\nExample: Esempio\n```js\nconsole.log(DEF.delaybinder); // 200\n```\n\n### DEF.delaykeypress = 200\n\nType: `config`\n\nIl ritardo in millisecondi dopo la pressione di un tasto in un campo di input.\n\nExample: Esempio\n```js\nconsole.log(DEF.delaykeypress); // 200\n```\n\n### DEF.delaypref = 1000\n\nType: `config`\n\nIl ritardo in millisecondi prima del salvataggio di [PREF](../pref/).\n\nExample: Esempio\n```js\nconsole.log(DEF.delaypref); // 1000\n```\n\n### DEF.delayrepeat = 2000\n\nType: `config`\n\nIl ritardo in millisecondi prima che una richiesta con il flag `repeat` venga inviata di nuovo.\n\nExample: Esempio\n```js\nconsole.log(DEF.delayrepeat); // 2000\n```\n\n### DEF.delaywatcher = 555\n\nType: `config`\n\nL'intervallo in millisecondi dei controlli che attendono un valore.\n\nExample: Esempio\n```js\nconsole.log(DEF.delaywatcher); // 555\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\nI limiti delle dimensioni di visualizzazione, in pixel.\n\nExample: Esempio\n```js\nconsole.log(DEF.devices.sm); // {\"min\":768,\"max\":992}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nLe traduzioni usate da [TRANSLATE()](../globals/#translate).\n\nExample: Esempio\n```js\nLOCALIZE('hello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nIl testo usato per un valore vuoto nelle associazioni dei dati.\n\nExample: Esempio\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.environment = { ts, date, time }\n\nType: `config`\n\nLe variabili di [ENV()](../globals/#env).\n\nExample: Esempio\n```js\nconsole.log(DEF.environment.date); // yyyy-MM-dd\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nL'URL dei componenti non dichiarati nella pagina.\n\n`{0}` è il nome del componente. Un valore vuoto disattiva il download.\n\nExample: Esempio\n```js\nDEF.fallback = '';\nconsole.log(DEF.fallback === ''); // true\n```\n\n### DEF.fallbackcache = ''\n\nType: `config`\n\nPer quanto tempo i componenti scaricati restano nella cache.\n\nExample: Esempio\n```js\nDEF.fallbackcache = '1 day';\nconsole.log(DEF.fallbackcache); // 1 day\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nLe intestazioni di ogni richiesta.\n\nExample: Esempio\n```js\nDEF.headers['X-App'] = 'shop';\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-App']); // shop\n\topt.respond({});\n});\nAJAX('GET /api/', NOOP);\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nIl prefisso dei nomi delle icone in `component.icon()`.\n\nExample: Esempio\n```js\nconsole.log(DEF.iconprefix); // ti ti-\n```\n\n### DEF.importcache = 'session'\n\nType: `config`\n\nPer quanto tempo i contenuti di `<ui-import>` restano nella cache.\n\nExample: Esempio\n```js\nconsole.log(DEF.importcache); // session\n```\n\n### DEF.jsoncompress = false\n\nType: `config`\n\nIl valore predefinito dell'argomento `compress` di [STRINGIFY()](../globals/#stringify).\n\nExample: Esempio\n```js\nDEF.jsoncompress = true;\nconsole.log(STRINGIFY({ a: 1, b: '' })); // {\"a\":1}\n```\n\n### DEF.jsonconverter = { 'text json': fn }\n\nType: `config`\n\nI convertitori delle risposte alle richieste.\n\nExample: Esempio\n```js\nconsole.log(typeof(DEF.jsonconverter['text json'])); // function\n```\n\n### DEF.jsondate = true\n\nType: `config`\n\nConverte le date ISO in oggetti `Date` durante l'analisi del JSON.\n\nExample: Esempio\n```js\nDEF.jsondate = false;\nconsole.log(typeof(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d)); // string\n```\n\n### DEF.keypress = true\n\nType: `config`\n\nFa reagire i campi di input mentre l'utente digita.\n\nExample: Esempio\n```js\nconsole.log(DEF.keypress); // true\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nLa lingua aggiunta all'URL di ogni richiesta.\n\nExample: Esempio\n```js\nDEF.language = 'sk';\nconsole.log(DEF.language); // sk\n```\n\n### DEF.languagehtml = undefined\n\nType: `config`\n\nLa lingua aggiunta all'URL delle sole richieste `.html`.\n\nExample: Esempio\n```js\nDEF.languagehtml = 'sk';\nconsole.log(DEF.languagehtml); // sk\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nIl nome dell'argomento di query con la lingua.\n\nExample: Esempio\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nIl prefisso delle chiavi nell'archiviazione del browser.\n\nExample: Esempio\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.makeurl = null\n\nType: `config`\n\nUna funzione che modifica l'URL di ogni richiesta.\n\nExample: Esempio\n```js\nDEF.makeurl = url => url + '?v=2';\nconsole.log(typeof(DEF.makeurl)); // function\n```\n\n### DEF.monitor = false\n\nType: `config`\n\nRaccoglie i contatori di utilizzo in [M.performance](../m/#performance).\n\nExample: Esempio\n```js\nDEF.monitor = true;\nSET('a', 1);\nconsole.log(M.performance.set.count > 0); // true\n```\n\n### DEF.pathcl = 'DEF.cl.'\n\nType: `config`\n\nIl path associato al prefisso `#`.\n\nExample: Esempio\n```js\nconsole.log(DEF.pathcl); // DEF.cl.\n```\n\n### DEF.pathcommon = 'common.'\n\nType: `config`\n\nIl path associato al prefisso `*`.\n\nExample: Esempio\n```js\nSET('*title', 'Hello');\nconsole.log(GET('common.title')); // Hello\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nIl prefisso CSS passato alle dichiarazioni dei componenti.\n\nExample: Esempio\n```js\nconsole.log(DEF.prefixcsscomponents); // ui-\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nIl prefisso CSS delle classi della libreria.\n\nExample: Esempio\n```js\nconsole.log(DEF.prefixcsslibrary); // ui-\n```\n\n### DEF.prefixcssmacros = 'm-'\n\nType: `config`\n\nIl prefisso CSS passato alle dichiarazioni delle macro.\n\nExample: Esempio\n```js\nconsole.log(DEF.prefixcssmacros); // m-\n```\n\n### DEF.regexp = { int, float, date, pluralize, format }\n\nType: `config`\n\nLe espressioni regolari degli helper per stringhe e date.\n\nExample: Esempio\n```js\nconsole.log(DEF.regexp.int instanceof RegExp); // true\n```\n\n### DEF.repeatfocus = true\n\nType: `config`\n\nMette in pausa [REPEAT()](../globals/#repeat) mentre la pagina è in background.\n\nExample: Esempio\n```js\nconsole.log(DEF.repeatfocus); // true\n```\n\n### DEF.root = ''\n\nType: `config`\n\nUn prefisso degli URL relativi che ha la precedenza su `DEF.baseurl`.\n\nUna stringa, oppure una funzione che riceve l'URL e ne restituisce uno nuovo.\n\nExample: Esempio\n```js\nDEF.root = '/shop';\nconsole.log('/users/'.ROOT()); // /shop/users/\n```\n\n### DEF.scope = window\n\nType: `config`\n\nL'oggetto in cui vengono memorizzati i path.\n\nExample: Esempio\n```js\nconsole.log(DEF.scope === window); // true\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnima le barre di scorrimento personalizzate alla fine del contenuto.\n\nExample: Esempio\n```js\nconsole.log(DEF.scrollbaranimate); // true\n```\n\n### DEF.secret = function\n\nType: `config`\n\nImposta la chiave che cifra i dati delle richieste.\n\nChiamala come `DEF.secret(key, [validator], [html])`. `validator` è una funzione che riceve le opzioni della richiesta e decide se cifrarle. Con `true` come `html`, vengono decifrate anche le risposte per i file `.html`. La funzione si rimuove da sola dopo la prima chiamata.\n\nExample: Esempio\n```js\nDEF.secret('my-key');\nconsole.log(DEF.secret === undefined); // true\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nIl separatore delle migliaia dei numeri formattati.\n\nExample: Esempio\n```js\nconsole.log((1500).format(0)); // 1 500\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nIl formato predefinito dell'ora in `DEF.environment`.\n\nExample: Esempio\n```js\nconsole.log(DEF.timeformat); // HH:mm\n```\n\n### DEF.validators = { url, phone, email }\n\nType: `config`\n\nLe espressioni regolari di `String.isURL()`, `String.isPhone()` e `String.isEmail()`.\n\nExample: Esempio\n```js\nconsole.log(DEF.validators.email.test('a@b.com')); // true\n```\n\n### DEF.version = ''\n\nType: `config`\n\nLa versione aggiunta all'URL di ogni richiesta.\n\nExample: Esempio\n```js\nDEF.version = '1.2';\nconsole.log(DEF.version); // 1.2\n```\n\n### DEF.versioncomponents = ''\n\nType: `config`\n\nLa versione dei componenti usati senza una versione.\n\nExample: Esempio\n```js\nconsole.log(DEF.versioncomponents === ''); // true\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nLa versione aggiunta all'URL delle sole richieste `.html`.\n\nExample: Esempio\n```js\nDEF.versionhtml = '1.2';\nconsole.log(DEF.versionhtml); // 1.2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nIl nome dell'argomento di query con la versione.\n\nExample: Esempio\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.webcomponentsonly = undefined\n\nType: `config`\n\nCon `true`, nella pagina vengono cercati solo gli elementi `<ui-*>`.\n\nExample: Esempio\n```js\nDEF.webcomponentsonly = true;\nconsole.log(DEF.webcomponentsonly); // true\n```\n","entries":[{"type":"config","name":"DEF.ajaxcredentials","signature":"DEF.ajaxcredentials = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxcredentialshtml","signature":"DEF.ajaxcredentialshtml = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxerrors","signature":"DEF.ajaxerrors = false","since":"","deprecated":false},{"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.csrf","signature":"DEF.csrf = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.customelements","signature":"DEF.customelements = false","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.delay","signature":"DEF.delay = 555","since":"","deprecated":false},{"type":"config","name":"DEF.delaybinder","signature":"DEF.delaybinder = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaykeypress","signature":"DEF.delaykeypress = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaypref","signature":"DEF.delaypref = 1000","since":"","deprecated":false},{"type":"config","name":"DEF.delayrepeat","signature":"DEF.delayrepeat = 2000","since":"","deprecated":false},{"type":"config","name":"DEF.delaywatcher","signature":"DEF.delaywatcher = 555","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.environment","signature":"DEF.environment = { ts, date, time }","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.fallbackcache","signature":"DEF.fallbackcache = ''","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.importcache","signature":"DEF.importcache = 'session'","since":"","deprecated":false},{"type":"config","name":"DEF.jsoncompress","signature":"DEF.jsoncompress = false","since":"","deprecated":false},{"type":"config","name":"DEF.jsonconverter","signature":"DEF.jsonconverter = { 'text json': fn }","since":"","deprecated":false},{"type":"config","name":"DEF.jsondate","signature":"DEF.jsondate = true","since":"","deprecated":false},{"type":"config","name":"DEF.keypress","signature":"DEF.keypress = true","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagehtml","signature":"DEF.languagehtml = 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.makeurl","signature":"DEF.makeurl = null","since":"","deprecated":false},{"type":"config","name":"DEF.monitor","signature":"DEF.monitor = false","since":"","deprecated":false},{"type":"config","name":"DEF.pathcl","signature":"DEF.pathcl = 'DEF.cl.'","since":"","deprecated":false},{"type":"config","name":"DEF.pathcommon","signature":"DEF.pathcommon = 'common.'","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.prefixcssmacros","signature":"DEF.prefixcssmacros = 'm-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format }","since":"","deprecated":false},{"type":"config","name":"DEF.repeatfocus","signature":"DEF.repeatfocus = true","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scope","signature":"DEF.scope = window","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.secret","signature":"DEF.secret = function","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.validators","signature":"DEF.validators = { url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = ''","since":"","deprecated":false},{"type":"config","name":"DEF.versioncomponents","signature":"DEF.versioncomponents = ''","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.webcomponentsonly","signature":"DEF.webcomponentsonly = undefined","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammXp6QM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/def/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"DEF","summary":"Konfiguračné možnosti knižnice.","markdown":"---\ntitle: DEF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/def/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# DEF\n\n> Konfiguračné možnosti knižnice.\n\n`DEF` obsahuje konfiguráciu knižnice. Možnosti nastav v skripte hneď po načítaní knižnice, pred štartom prvých komponentov. Ak chceš vidieť, ako možnosti spolu súvisia, prečítaj si [Začíname](../../guides/getting-started/).\n\n## API\n\n### DEF.ajaxcredentials = false\n\nType: `config`\n\nOdosiela cookies s každou požiadavkou.\n\nExample: Príklad\n```js\nDEF.ajaxcredentials = true;\nconsole.log(DEF.ajaxcredentials); // true\n```\n\n### DEF.ajaxcredentialshtml = false\n\nType: `config`\n\nOdosiela cookies aj s požiadavkami na súbory `.html`, keď je zapnuté `DEF.ajaxcredentials`.\n\nExample: Príklad\n```js\nconsole.log(DEF.ajaxcredentialshtml); // false\n```\n\n### DEF.ajaxerrors = false\n\nType: `config`\n\nSpracúva chybové odpovede ako bežné odpovede.\n\nS hodnotou `true` sa udalosť `error` nevyšle a Promise požiadavky sa nezamietne.\n\nExample: Príklad\n```js\nDEF.ajaxerrors = true;\nON('request', opt => opt.throw('Failed', 500));\nAJAX('GET /api/', function(response, err) {\n\tconsole.log(response, err); // Failed 500\n});\n```\n\n### DEF.api = undefined\n\nType: `config`\n\nPredvolený koncový bod pre [DAPI()](../globals/#dapi) a [TAPI()](../globals/#tapi).\n\nURL alebo funkcia, ktorá dostane názov a dáta a vráti hodnotu pre `API()`.\n\nExample: Príklad\n```js\nDEF.api = '/api/';\nconsole.log(DEF.api); // /api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nPredpona relatívnych URL požiadaviek.\n\nReťazec alebo funkcia, ktorá dostane URL a vráti novú.\n\nExample: Príklad\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nHodnota značky `~CDN~` v importovanom obsahu.\n\nExample: Príklad\n```js\nDEF.cdn = '//cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/a.js')); // //cdn.example.com/a.js\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nNačítané zoznamy kódov podľa názvu.\n\nExample: Príklad\n```js\nCL_INIT('roles', next => next(['admin']), true);\nconsole.log(DEF.cl.roles); // [\"admin\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nHlavná farba aplikácie.\n\nExample: Príklad\n```js\nconsole.log(DEF.color); // #4285F4\n```\n\n### DEF.csrf = undefined\n\nType: `config`\n\nToken odosielaný v hlavičke `x-csrf-token`.\n\nPožiadavky na súbory `.html` ho neodosielajú.\n\nExample: Príklad\n```js\nDEF.csrf = 'abc';\nON('request', function(opt) {\n\tconsole.log(opt.headers['x-csrf-token']); // abc\n\topt.respond({});\n});\nAJAX('POST /api/', {}, NOOP);\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nFunkcie, ktoré formátujú čísla ako meny.\n\nExample: Príklad\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log((5).currency('eur')); // 5.00 EUR\n```\n\n### DEF.currency = undefined\n\nType: `config`\n\nPredvolená mena `Number.currency()`.\n\nExample: Príklad\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currency = 'eur';\nconsole.log((5).currency()); // 5.00 EUR\n```\n\n### DEF.customelements = false\n\nType: `config`\n\nZaregistruje každý komponent ako vlastný element `<ui-name>`.\n\nNastav to pred deklaráciou komponentov.\n\nExample: Príklad\n```js\nDEF.customelements = true;\nCOMPONENT('hello', function(self) {\n\tself.make = () => self.element.text('Hi');\n});\nconsole.log(customElements.get('ui-hello') != null); // true\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nPredvolený formát `Date.format()`.\n\nExample: Príklad\n```js\nconsole.log(new Date(2024, 0, 15).format()); // 2024-01-15\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormátuje dátumy v UTC.\n\nExample: Príklad\n```js\nconsole.log(DEF.dateformatutc); // false\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nDesatinný oddeľovač formátovaných čísel.\n\nExample: Príklad\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.delay = 555\n\nType: `config`\n\nOneskorenie v milisekundách pred opätovným pokusom o požiadavku s flagom `sync`.\n\nExample: Príklad\n```js\nconsole.log(DEF.delay); // 555\n```\n\n### DEF.delaybinder = 200\n\nType: `config`\n\nOneskorenie oneskorených dátových väzieb v milisekundách.\n\nExample: Príklad\n```js\nconsole.log(DEF.delaybinder); // 200\n```\n\n### DEF.delaykeypress = 200\n\nType: `config`\n\nOneskorenie v milisekundách po stlačení klávesu vo vstupe.\n\nExample: Príklad\n```js\nconsole.log(DEF.delaykeypress); // 200\n```\n\n### DEF.delaypref = 1000\n\nType: `config`\n\nOneskorenie v milisekundách pred uložením [PREF](../pref/).\n\nExample: Príklad\n```js\nconsole.log(DEF.delaypref); // 1000\n```\n\n### DEF.delayrepeat = 2000\n\nType: `config`\n\nOneskorenie v milisekundách pred opätovným odoslaním požiadavky s flagom `repeat`.\n\nExample: Príklad\n```js\nconsole.log(DEF.delayrepeat); // 2000\n```\n\n### DEF.delaywatcher = 555\n\nType: `config`\n\nInterval kontrol čakajúcich na hodnotu v milisekundách.\n\nExample: Príklad\n```js\nconsole.log(DEF.delaywatcher); // 555\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\nLimity veľkostí zobrazenia v pixeloch.\n\nExample: Príklad\n```js\nconsole.log(DEF.devices.sm); // {\"min\":768,\"max\":992}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nPreklady, ktoré používa [TRANSLATE()](../globals/#translate).\n\nExample: Príklad\n```js\nLOCALIZE('hello : Ahoj');\nconsole.log(DEF.dictionary.hello); // Ahoj\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nText použitý pre prázdnu hodnotu v dátových väzbách.\n\nExample: Príklad\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.environment = { ts, date, time }\n\nType: `config`\n\nPremenné [ENV()](../globals/#env).\n\nExample: Príklad\n```js\nconsole.log(DEF.environment.date); // yyyy-MM-dd\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nURL komponentov, ktoré nie sú na stránke deklarované.\n\n`{0}` je názov komponentu. Prázdna hodnota sťahovanie vypne.\n\nExample: Príklad\n```js\nDEF.fallback = '';\nconsole.log(DEF.fallback === ''); // true\n```\n\n### DEF.fallbackcache = ''\n\nType: `config`\n\nAko dlho sa stiahnuté komponenty uchovávajú v cache.\n\nExample: Príklad\n```js\nDEF.fallbackcache = '1 day';\nconsole.log(DEF.fallbackcache); // 1 day\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nHlavičky každej požiadavky.\n\nExample: Príklad\n```js\nDEF.headers['X-App'] = 'shop';\nON('request', function(opt) {\n\tconsole.log(opt.headers['X-App']); // shop\n\topt.respond({});\n});\nAJAX('GET /api/', NOOP);\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nPredpona názvov ikon v `component.icon()`.\n\nExample: Príklad\n```js\nconsole.log(DEF.iconprefix); // ti ti-\n```\n\n### DEF.importcache = 'session'\n\nType: `config`\n\nAko dlho sa obsah z `<ui-import>` uchováva v cache.\n\nExample: Príklad\n```js\nconsole.log(DEF.importcache); // session\n```\n\n### DEF.jsoncompress = false\n\nType: `config`\n\nPredvolená hodnota argumentu `compress` funkcie [STRINGIFY()](../globals/#stringify).\n\nExample: Príklad\n```js\nDEF.jsoncompress = true;\nconsole.log(STRINGIFY({ a: 1, b: '' })); // {\"a\":1}\n```\n\n### DEF.jsonconverter = { 'text json': fn }\n\nType: `config`\n\nPrevodníky odpovedí na požiadavky.\n\nExample: Príklad\n```js\nconsole.log(typeof(DEF.jsonconverter['text json'])); // function\n```\n\n### DEF.jsondate = true\n\nType: `config`\n\nPri spracovaní JSON prevedie dátumy ISO na objekty `Date`.\n\nExample: Príklad\n```js\nDEF.jsondate = false;\nconsole.log(typeof(PARSE('{\"d\":\"2024-01-01T10:00:00.000Z\"}').d)); // string\n```\n\n### DEF.keypress = true\n\nType: `config`\n\nZaistí, že vstupy reagujú už počas písania.\n\nExample: Príklad\n```js\nconsole.log(DEF.keypress); // true\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nJazyk pridaný do URL každej požiadavky.\n\nExample: Príklad\n```js\nDEF.language = 'sk';\nconsole.log(DEF.language); // sk\n```\n\n### DEF.languagehtml = undefined\n\nType: `config`\n\nJazyk pridaný iba do URL požiadaviek na `.html`.\n\nExample: Príklad\n```js\nDEF.languagehtml = 'sk';\nconsole.log(DEF.languagehtml); // sk\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nNázov argumentu dotazu s jazykom.\n\nExample: Príklad\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nPredpona kľúčov v úložisku prehliadača.\n\nExample: Príklad\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.makeurl = null\n\nType: `config`\n\nFunkcia, ktorá mení URL každej požiadavky.\n\nExample: Príklad\n```js\nDEF.makeurl = url => url + '?v=2';\nconsole.log(typeof(DEF.makeurl)); // function\n```\n\n### DEF.monitor = false\n\nType: `config`\n\nZbiera počítadlá používania v [M.performance](../m/#performance).\n\nExample: Príklad\n```js\nDEF.monitor = true;\nSET('a', 1);\nconsole.log(M.performance.set.count > 0); // true\n```\n\n### DEF.pathcl = 'DEF.cl.'\n\nType: `config`\n\nPath, ktorý sa skrýva za predponou `#`.\n\nExample: Príklad\n```js\nconsole.log(DEF.pathcl); // DEF.cl.\n```\n\n### DEF.pathcommon = 'common.'\n\nType: `config`\n\nPath, ktorý sa skrýva za predponou `*`.\n\nExample: Príklad\n```js\nSET('*title', 'Hello');\nconsole.log(GET('common.title')); // Hello\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nPredpona CSS odovzdávaná deklaráciám komponentov.\n\nExample: Príklad\n```js\nconsole.log(DEF.prefixcsscomponents); // ui-\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nPredpona CSS tried knižnice.\n\nExample: Príklad\n```js\nconsole.log(DEF.prefixcsslibrary); // ui-\n```\n\n### DEF.prefixcssmacros = 'm-'\n\nType: `config`\n\nPredpona CSS odovzdávaná deklaráciám macro.\n\nExample: Príklad\n```js\nconsole.log(DEF.prefixcssmacros); // m-\n```\n\n### DEF.regexp = { int, float, date, pluralize, format }\n\nType: `config`\n\nRegulárne výrazy helperov pre reťazce a dátumy.\n\nExample: Príklad\n```js\nconsole.log(DEF.regexp.int instanceof RegExp); // true\n```\n\n### DEF.repeatfocus = true\n\nType: `config`\n\nPozastaví [REPEAT()](../globals/#repeat), kým je stránka na pozadí.\n\nExample: Príklad\n```js\nconsole.log(DEF.repeatfocus); // true\n```\n\n### DEF.root = ''\n\nType: `config`\n\nPredpona relatívnych URL, ktorá má prednosť pred `DEF.baseurl`.\n\nReťazec alebo funkcia, ktorá dostane URL a vráti novú.\n\nExample: Príklad\n```js\nDEF.root = '/shop';\nconsole.log('/users/'.ROOT()); // /shop/users/\n```\n\n### DEF.scope = window\n\nType: `config`\n\nObjekt, v ktorom sú uložené paths.\n\nExample: Príklad\n```js\nconsole.log(DEF.scope === window); // true\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnimuje vlastné posuvníky na konci obsahu.\n\nExample: Príklad\n```js\nconsole.log(DEF.scrollbaranimate); // true\n```\n\n### DEF.secret = function\n\nType: `config`\n\nNastaví kľúč, ktorý šifruje dáta požiadaviek.\n\nVolaj ju ako `DEF.secret(key, [validator], [html])`. `validator` je funkcia, ktorá dostane možnosti požiadavky a rozhodne, či sa majú šifrovať. S hodnotou `true` v `html` sa dešifrujú aj odpovede na súbory `.html`. Funkcia sa po prvom volaní sama odstráni.\n\nExample: Príklad\n```js\nDEF.secret('my-key');\nconsole.log(DEF.secret === undefined); // true\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nOddeľovač tisícov formátovaných čísel.\n\nExample: Príklad\n```js\nconsole.log((1500).format(0)); // 1 500\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nPredvolený formát času v `DEF.environment`.\n\nExample: Príklad\n```js\nconsole.log(DEF.timeformat); // HH:mm\n```\n\n### DEF.validators = { url, phone, email }\n\nType: `config`\n\nRegulárne výrazy pre `String.isURL()`, `String.isPhone()` a `String.isEmail()`.\n\nExample: Príklad\n```js\nconsole.log(DEF.validators.email.test('a@b.com')); // true\n```\n\n### DEF.version = ''\n\nType: `config`\n\nVerzia pridaná do URL každej požiadavky.\n\nExample: Príklad\n```js\nDEF.version = '1.2';\nconsole.log(DEF.version); // 1.2\n```\n\n### DEF.versioncomponents = ''\n\nType: `config`\n\nVerzia komponentov používaných bez verzie.\n\nExample: Príklad\n```js\nconsole.log(DEF.versioncomponents === ''); // true\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nVerzia pridaná iba do URL požiadaviek na `.html`.\n\nExample: Príklad\n```js\nDEF.versionhtml = '1.2';\nconsole.log(DEF.versionhtml); // 1.2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nNázov argumentu dotazu s verziou.\n\nExample: Príklad\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.webcomponentsonly = undefined\n\nType: `config`\n\nS hodnotou `true` sa na stránke vyhľadávajú iba elementy `<ui-*>`.\n\nExample: Príklad\n```js\nDEF.webcomponentsonly = true;\nconsole.log(DEF.webcomponentsonly); // true\n```\n","entries":[{"type":"config","name":"DEF.ajaxcredentials","signature":"DEF.ajaxcredentials = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxcredentialshtml","signature":"DEF.ajaxcredentialshtml = false","since":"","deprecated":false},{"type":"config","name":"DEF.ajaxerrors","signature":"DEF.ajaxerrors = false","since":"","deprecated":false},{"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.csrf","signature":"DEF.csrf = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.customelements","signature":"DEF.customelements = false","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.delay","signature":"DEF.delay = 555","since":"","deprecated":false},{"type":"config","name":"DEF.delaybinder","signature":"DEF.delaybinder = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaykeypress","signature":"DEF.delaykeypress = 200","since":"","deprecated":false},{"type":"config","name":"DEF.delaypref","signature":"DEF.delaypref = 1000","since":"","deprecated":false},{"type":"config","name":"DEF.delayrepeat","signature":"DEF.delayrepeat = 2000","since":"","deprecated":false},{"type":"config","name":"DEF.delaywatcher","signature":"DEF.delaywatcher = 555","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.environment","signature":"DEF.environment = { ts, date, time }","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.fallbackcache","signature":"DEF.fallbackcache = ''","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.importcache","signature":"DEF.importcache = 'session'","since":"","deprecated":false},{"type":"config","name":"DEF.jsoncompress","signature":"DEF.jsoncompress = false","since":"","deprecated":false},{"type":"config","name":"DEF.jsonconverter","signature":"DEF.jsonconverter = { 'text json': fn }","since":"","deprecated":false},{"type":"config","name":"DEF.jsondate","signature":"DEF.jsondate = true","since":"","deprecated":false},{"type":"config","name":"DEF.keypress","signature":"DEF.keypress = true","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagehtml","signature":"DEF.languagehtml = 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.makeurl","signature":"DEF.makeurl = null","since":"","deprecated":false},{"type":"config","name":"DEF.monitor","signature":"DEF.monitor = false","since":"","deprecated":false},{"type":"config","name":"DEF.pathcl","signature":"DEF.pathcl = 'DEF.cl.'","since":"","deprecated":false},{"type":"config","name":"DEF.pathcommon","signature":"DEF.pathcommon = 'common.'","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.prefixcssmacros","signature":"DEF.prefixcssmacros = 'm-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format }","since":"","deprecated":false},{"type":"config","name":"DEF.repeatfocus","signature":"DEF.repeatfocus = true","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scope","signature":"DEF.scope = window","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.secret","signature":"DEF.secret = function","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.validators","signature":"DEF.validators = { url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = ''","since":"","deprecated":false},{"type":"config","name":"DEF.versioncomponents","signature":"DEF.versioncomponents = ''","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.webcomponentsonly","signature":"DEF.webcomponentsonly = undefined","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammgd7uj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/main/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"MAIN","summary":"The main object of the library and its names.","markdown":"---\ntitle: MAIN\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/main/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# MAIN\n\n> The main object of the library and its names.\n\n`MAIN` is the object that holds the state of the library. It is available under several names, and its members are described in [M](../m/). For the concepts behind it, read [Introduction](../../guides/introduction/).\n\n## API\n\n### MAIN\n\nType: `property`\n\nThe main object of the library.\n\nAll its members are described in [M](../m/).\n\nExample: Read the version\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### M\n\nType: `property`\n\nA short name of `MAIN`.\n\nExample: The same object\n```js\nconsole.log(M === MAIN); // true\n```\n\n### jComponent\n\nType: `property`\n\nAnother name of `MAIN`.\n\nExample: The same object\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### $.components\n\nType: `property`\n\nThe same object in the jQuery namespace.\n\nExample: The same object\n```js\nconsole.log($.components === MAIN); // true\n```\n","entries":[{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammgd7uj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/main/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"MAIN","summary":"Das Hauptobjekt der Bibliothek und seine Namen.","markdown":"---\ntitle: MAIN\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/main/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# MAIN\n\n> Das Hauptobjekt der Bibliothek und seine Namen.\n\n`MAIN` ist das Objekt, das den Zustand der Bibliothek enthält. Es ist unter mehreren Namen verfügbar, und seine Member sind unter [M](../m/) beschrieben. Die Konzepte dahinter erklärt die [Einführung](../../guides/introduction/).\n\n## API\n\n### MAIN\n\nType: `property`\n\nDas Hauptobjekt der Bibliothek.\n\nAlle seine Member sind unter [M](../m/) beschrieben.\n\nExample: Version lesen\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### M\n\nType: `property`\n\nEin Kurzname für `MAIN`.\n\nExample: Dasselbe Objekt\n```js\nconsole.log(M === MAIN); // true\n```\n\n### jComponent\n\nType: `property`\n\nEin anderer Name für `MAIN`.\n\nExample: Dasselbe Objekt\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### $.components\n\nType: `property`\n\nDasselbe Objekt im jQuery-Namespace.\n\nExample: Dasselbe Objekt\n```js\nconsole.log($.components === MAIN); // true\n```\n","entries":[{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammgd7uj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/main/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"MAIN","summary":"El objeto principal de la biblioteca y sus nombres.","markdown":"---\ntitle: MAIN\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/main/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# MAIN\n\n> El objeto principal de la biblioteca y sus nombres.\n\n`MAIN` es el objeto que contiene el estado de la biblioteca. Está disponible con varios nombres, y sus miembros se describen en [M](../m/). Para conocer los conceptos en los que se basa, lee [Introducción](../../guides/introduction/).\n\n## API\n\n### MAIN\n\nType: `property`\n\nEl objeto principal de la biblioteca.\n\nTodos sus miembros se describen en [M](../m/).\n\nExample: Leer la versión\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### M\n\nType: `property`\n\nUn nombre corto de `MAIN`.\n\nExample: El mismo objeto\n```js\nconsole.log(M === MAIN); // true\n```\n\n### jComponent\n\nType: `property`\n\nOtro nombre de `MAIN`.\n\nExample: El mismo objeto\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### $.components\n\nType: `property`\n\nEl mismo objeto en el espacio de nombres de jQuery.\n\nExample: El mismo objeto\n```js\nconsole.log($.components === MAIN); // true\n```\n","entries":[{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammgd7uj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/main/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"MAIN","summary":"L'objet principal de la bibliothèque et ses noms.","markdown":"---\ntitle: MAIN\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/main/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# MAIN\n\n> L'objet principal de la bibliothèque et ses noms.\n\n`MAIN` est l'objet qui contient l'état de la bibliothèque. Il est disponible sous plusieurs noms, et ses membres sont décrits dans [M](../m/). Pour les concepts sous-jacents, lis [Introduction](../../guides/introduction/).\n\n## API\n\n### MAIN\n\nType: `property`\n\nL'objet principal de la bibliothèque.\n\nTous ses membres sont décrits dans [M](../m/).\n\nExample: Lire la version\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### M\n\nType: `property`\n\nUn nom court de `MAIN`.\n\nExample: Le même objet\n```js\nconsole.log(M === MAIN); // true\n```\n\n### jComponent\n\nType: `property`\n\nUn autre nom de `MAIN`.\n\nExample: Le même objet\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### $.components\n\nType: `property`\n\nLe même objet dans l'espace de noms jQuery.\n\nExample: Le même objet\n```js\nconsole.log($.components === MAIN); // true\n```\n","entries":[{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammgd7uj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/main/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"MAIN","summary":"L'oggetto principale della libreria e i suoi nomi.","markdown":"---\ntitle: MAIN\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/main/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# MAIN\n\n> L'oggetto principale della libreria e i suoi nomi.\n\n`MAIN` è l'oggetto che contiene lo stato della libreria. È disponibile con diversi nomi e i suoi membri sono descritti in [M](../m/). Per i concetti alla base, leggi [Introduzione](../../guides/introduction/).\n\n## API\n\n### MAIN\n\nType: `property`\n\nL'oggetto principale della libreria.\n\nTutti i suoi membri sono descritti in [M](../m/).\n\nExample: Leggi la versione\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### M\n\nType: `property`\n\nUn nome breve di `MAIN`.\n\nExample: Lo stesso oggetto\n```js\nconsole.log(M === MAIN); // true\n```\n\n### jComponent\n\nType: `property`\n\nUn altro nome di `MAIN`.\n\nExample: Lo stesso oggetto\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### $.components\n\nType: `property`\n\nLo stesso oggetto nello spazio dei nomi di jQuery.\n\nExample: Lo stesso oggetto\n```js\nconsole.log($.components === MAIN); // true\n```\n","entries":[{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammgd7uj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/main/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"MAIN","summary":"Hlavný objekt knižnice a jeho názvy.","markdown":"---\ntitle: MAIN\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/main/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# MAIN\n\n> Hlavný objekt knižnice a jeho názvy.\n\n`MAIN` je objekt, ktorý uchováva stav knižnice. Je dostupný pod viacerými názvami a jeho členov popisuje [M](../m/). Základné pojmy nájdeš v časti [Úvod](../../guides/introduction/).\n\n## API\n\n### MAIN\n\nType: `property`\n\nHlavný objekt knižnice.\n\nVšetkých jeho členov popisuje [M](../m/).\n\nExample: Prečítaj verziu\n```js\nconsole.log(MAIN.version); // 19.194\n```\n\n### M\n\nType: `property`\n\nKrátky názov pre `MAIN`.\n\nExample: Ten istý objekt\n```js\nconsole.log(M === MAIN); // true\n```\n\n### jComponent\n\nType: `property`\n\nIný názov pre `MAIN`.\n\nExample: Ten istý objekt\n```js\nconsole.log(jComponent === MAIN); // true\n```\n\n### $.components\n\nType: `property`\n\nTen istý objekt v mennom priestore jQuery.\n\nExample: Ten istý objekt\n```js\nconsole.log($.components === MAIN); // true\n```\n","entries":[{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammeu5oj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/m/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"M","summary":"The members of the main object of the library.","markdown":"---\ntitle: M\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/m/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# M\n\n> The members of the main object of the library.\n\n`M` is a short name of [MAIN](../main/). Most applications use the [global functions](../globals/) instead of these members. For the concepts behind them, read [Paths](../../guides/paths/).\n\n## API\n\n### M.binders\n\nType: `property`\n\nAn array of the active data bindings.\n\nExample: Example\n```js\nSET('name', 'Peter');\nsetTimeout(function() {\n\tconsole.log(M.binders.length); // 1\n}, 300);\n```\n\n### M.cl\n\nType: `property`\n\nThe declared code lists by name.\n\nExample: Example\n```js\nCL_INIT('roles', next => next([]));\nconsole.log(Object.keys(M.cl)); // [\"roles\"]\n```\n\n### M.compile([container])\n\nType: `method`\n\nSearches the page for new components and bindings.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limits the search to this element. |\n\nUse [COMPILE()](../globals/#compile) in your code.\n\nExample: Example\n```js\nconsole.log(typeof(M.compile)); // function\n```\n\n### M.components\n\nType: `property`\n\nAn array of the created components.\n\nExample: Example\n```js\nON('ready', function() {\n\tconsole.log(M.components.length); // 2\n});\n```\n\n### M.days\n\nType: `property`\n\nThe same array as [DAYS](../globals/#days).\n\nExample: Example\n```js\nconsole.log(M.days === DAYS); // true\n```\n\n### M.default(path, [delay], [component], [reset])\n\nType: `method`\n\nRestores the default values of the components on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `delay` | `Number` | no |  | A delay in milliseconds. |\n| `component` | `Component` | no |  | Limits the change to one component. |\n| `reset` | `Boolean` | no | `true` | With `false`, the state is kept. |\n\nUse [DEFAULT()](../globals/#default) in your code.\n\nExample: Example\n```js\nconsole.log(typeof(M.default)); // function\n```\n\n### M.defaults\n\nType: `property`\n\nThe same object as [DEF](../def/).\n\nExample: Example\n```js\nconsole.log(M.defaults === DEF); // true\n```\n\n### M.each(fn, [path])\n\nType: `method`\n\nCalls a function for each component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(component, index, wildcard)`. |\n| `path` | `String` | no |  | Limits the call to a path. |\n\nReturn `true` from the function to stop.\n\nExample: Example\n```js\nON('ready', function() {\n\tvar paths = [];\n\tM.each(com => paths.push(com.path), 'form.*');\n\tconsole.log(paths.length); // 2\n});\n```\n\n### M.events\n\nType: `property`\n\nThe registered event handlers by event name.\n\nExample: Example\n```js\nON('hello', NOOP);\nconsole.log(M.events.hello.length); // 1\n```\n\n### M.extend(path, value, [type])\n\nType: `method`\n\nMerges fields into an object.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Object` | yes |  | The fields. |\n| `type` | `Number` | no |  | The change type: `1` manual, `2` input, `3` default. |\n\nUse [EXT()](../globals/#ext) for a delayed change.\n\nExample: Example\n```js\nSET('user', { a: 1 });\nM.extend('user', { b: 2 });\nconsole.log(GET('user')); // {\"a\":1,\"b\":2}\n```\n\n### M.inc(path, value, [type])\n\nType: `method`\n\nAdds a number to a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Number` | yes |  | The number. |\n| `type` | `Number` | no |  | The change type: `1` manual, `2` input, `3` default. |\n\nUse [INC()](../globals/#inc) for a delayed change.\n\nExample: Example\n```js\nM.inc('count', 2);\nconsole.log(GET('count')); // 2\n```\n\n### M.loaded\n\nType: `property`\n\n`true` after the stored preferences are loaded.\n\nExample: Example\n```js\nsetTimeout(function() {\n\tconsole.log(M.loaded); // true\n}, 500);\n```\n\n### M.macros\n\nType: `property`\n\nThe declared macros by name.\n\nExample: Example\n```js\nMACRO('upper', NOOP);\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### M.months\n\nType: `property`\n\nThe same array as [MONTHS](../globals/#months).\n\nExample: Example\n```js\nconsole.log(M.months === MONTHS); // true\n```\n\n### M.parse(type, value, [format])\n\nType: `method`\n\nConverts a value with the registered parsers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | The type, for example `number`. |\n| `value` | `Object` | yes |  | The value. |\n| `format` | `String` | no |  | The format passed to the parsers. |\n\nReturns: `Object` The converted value.\n\nExample: Example\n```js\nconsole.log(M.parse('number', '5')); // 5\n```\n\n### M.paths\n\nType: `property`\n\nThe number of watchers and components for each path.\n\nExample: Example\n```js\nWATCH('user.name', NOOP);\nconsole.log(M.paths['user.name']); // 1\n```\n\n### M.performance\n\nType: `property`\n\nUsage counters, collected when `DEF.monitor` is `true`.\n\nExample: Example\n```js\nDEF.monitor = true;\nGET('a');\nconsole.log(M.performance.get.count > 0); // true\n```\n\n### M.plugin([name])\n\nType: `method`\n\nReads or changes the current plugin scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | The new scope. |\n\nReturns: `String` The current scope.\n\nExample: Example\n```js\nM.plugin('users');\nconsole.log(M.plugin()); // users\n```\n\n### M.prototypes(fn)\n\nType: `method`\n\nGives access to the prototypes of the library objects.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(proto)`. |\n\nThe object has the fields `Component`, `Plugin` and `VBinder`.\n\nExample: Example\n```js\nM.prototypes(function(proto) {\n\tproto.Component.hello = () => 'Hello';\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').hello()); // Hello\n});\n```\n\n### M.push(path, value, [type])\n\nType: `method`\n\nAdds a value to an array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Object` | yes |  | The item. |\n| `type` | `Number` | no |  | The change type: `1` manual, `2` input, `3` default. |\n\nUse [PUSH()](../globals/#push) for a delayed change.\n\nExample: Example\n```js\nM.push('list', 1);\nconsole.log(GET('list')); // [1]\n```\n\n### M.scope([name])\n\nType: `method`\n\nThe same function as [M.plugin()](#plugin).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | The new scope. |\n\nReturns: `String` The current scope.\n\nExample: Example\n```js\nconsole.log(M.scope === M.plugin); // true\n```\n\n### M.scrollbars\n\nType: `property`\n\nAn array of the custom scrollbars.\n\nExample: Example\n```js\nconsole.log(M.scrollbars.length); // 0\n```\n\n### M.set(path, value, [type])\n\nType: `method`\n\nWrites a value to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Object` | yes |  | The value. |\n| `type` | `Number` | no |  | The change type: `1` manual, `2` input, `3` default. |\n\nUse [SET()](../globals/#set) for a delayed change.\n\nExample: Example\n```js\nM.set('name', 'Peter');\nconsole.log(GET('name')); // Peter\n```\n\n### M.ua\n\nType: `property`\n\nThe parsed user agent with the fields `os`, `browser` and `device`.\n\nExample: Example\n```js\nconsole.log(Object.keys(M.ua)); // [\"os\",\"browser\",\"device\"]\n```\n\n### M.update(path, [reset], [type])\n\nType: `method`\n\nRefreshes everything bound to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `reset` | `Boolean` | no |  | Resets the state of the components. |\n| `type` | `Number` | no |  | The change type: `1` manual, `2` input, `3` default. |\n\nUse [UPD()](../globals/#upd) for a delayed change.\n\nExample: Example\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nM.update('user.name');\n```\n\n### M.version\n\nType: `property`\n\nThe version of the library.\n\nExample: Example\n```js\nconsole.log(M.version); // 19.194\n```\n","entries":[{"type":"property","name":"M.binders","signature":"M.binders","since":"","deprecated":false},{"type":"property","name":"M.cl","signature":"M.cl","since":"","deprecated":false},{"type":"method","name":"M.compile()","signature":"M.compile([container])","since":"","deprecated":false},{"type":"property","name":"M.components","signature":"M.components","since":"","deprecated":false},{"type":"property","name":"M.days","signature":"M.days","since":"","deprecated":false},{"type":"method","name":"M.default()","signature":"M.default(path, [delay], [component], [reset])","since":"","deprecated":false},{"type":"property","name":"M.defaults","signature":"M.defaults","since":"","deprecated":false},{"type":"method","name":"M.each()","signature":"M.each(fn, [path])","since":"","deprecated":false},{"type":"property","name":"M.events","signature":"M.events","since":"","deprecated":false},{"type":"method","name":"M.extend()","signature":"M.extend(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.inc()","signature":"M.inc(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.loaded","signature":"M.loaded","since":"","deprecated":false},{"type":"property","name":"M.macros","signature":"M.macros","since":"","deprecated":false},{"type":"property","name":"M.months","signature":"M.months","since":"","deprecated":false},{"type":"method","name":"M.parse()","signature":"M.parse(type, value, [format])","since":"","deprecated":false},{"type":"property","name":"M.paths","signature":"M.paths","since":"","deprecated":false},{"type":"property","name":"M.performance","signature":"M.performance","since":"","deprecated":false},{"type":"method","name":"M.plugin()","signature":"M.plugin([name])","since":"","deprecated":false},{"type":"method","name":"M.prototypes()","signature":"M.prototypes(fn)","since":"","deprecated":false},{"type":"method","name":"M.push()","signature":"M.push(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.scope()","signature":"M.scope([name])","since":"","deprecated":false},{"type":"property","name":"M.scrollbars","signature":"M.scrollbars","since":"","deprecated":false},{"type":"method","name":"M.set()","signature":"M.set(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.ua","signature":"M.ua","since":"","deprecated":false},{"type":"method","name":"M.update()","signature":"M.update(path, [reset], [type])","since":"","deprecated":false},{"type":"property","name":"M.version","signature":"M.version","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammeu5oj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/m/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"M","summary":"Die Member des Hauptobjekts der Bibliothek.","markdown":"---\ntitle: M\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/m/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# M\n\n> Die Member des Hauptobjekts der Bibliothek.\n\n`M` ist ein Kurzname für [MAIN](../main/). Die meisten Anwendungen verwenden statt dieser Member die [globalen Funktionen](../globals/). Die Konzepte dahinter erklärt [Paths](../../guides/paths/).\n\n## API\n\n### M.binders\n\nType: `property`\n\nEin Array der aktiven Datenbindungen.\n\nExample: Beispiel\n```js\nSET('name', 'Peter');\nsetTimeout(function() {\n\tconsole.log(M.binders.length); // 1\n}, 300);\n```\n\n### M.cl\n\nType: `property`\n\nDie deklarierten Codelisten nach Namen.\n\nExample: Beispiel\n```js\nCL_INIT('roles', next => next([]));\nconsole.log(Object.keys(M.cl)); // [\"roles\"]\n```\n\n### M.compile([container])\n\nType: `method`\n\nDurchsucht die Seite nach neuen Komponenten und Bindungen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Beschränkt die Suche auf dieses Element. |\n\nVerwende in deinem Code [COMPILE()](../globals/#compile).\n\nExample: Beispiel\n```js\nconsole.log(typeof(M.compile)); // function\n```\n\n### M.components\n\nType: `property`\n\nEin Array der erstellten Komponenten.\n\nExample: Beispiel\n```js\nON('ready', function() {\n\tconsole.log(M.components.length); // 2\n});\n```\n\n### M.days\n\nType: `property`\n\nDasselbe Array wie [DAYS](../globals/#days).\n\nExample: Beispiel\n```js\nconsole.log(M.days === DAYS); // true\n```\n\n### M.default(path, [delay], [component], [reset])\n\nType: `method`\n\nStellt die Standardwerte der Komponenten auf einem Path wieder her.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `delay` | `Number` | no |  | Eine Verzögerung in Millisekunden. |\n| `component` | `Component` | no |  | Beschränkt die Änderung auf eine Komponente. |\n| `reset` | `Boolean` | no | `true` | Mit `false` bleibt der Zustand erhalten. |\n\nVerwende in deinem Code [DEFAULT()](../globals/#default).\n\nExample: Beispiel\n```js\nconsole.log(typeof(M.default)); // function\n```\n\n### M.defaults\n\nType: `property`\n\nDasselbe Objekt wie [DEF](../def/).\n\nExample: Beispiel\n```js\nconsole.log(M.defaults === DEF); // true\n```\n\n### M.each(fn, [path])\n\nType: `method`\n\nRuft für jede Komponente eine Funktion auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(component, index, wildcard)`. |\n| `path` | `String` | no |  | Beschränkt den Aufruf auf einen Path. |\n\nGib in der Funktion `true` zurück, um abzubrechen.\n\nExample: Beispiel\n```js\nON('ready', function() {\n\tvar paths = [];\n\tM.each(com => paths.push(com.path), 'form.*');\n\tconsole.log(paths.length); // 2\n});\n```\n\n### M.events\n\nType: `property`\n\nDie registrierten Event-Handler nach Event-Namen.\n\nExample: Beispiel\n```js\nON('hello', NOOP);\nconsole.log(M.events.hello.length); // 1\n```\n\n### M.extend(path, value, [type])\n\nType: `method`\n\nFührt Felder mit einem Objekt zusammen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Object` | yes |  | Die Felder. |\n| `type` | `Number` | no |  | Der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n\nVerwende [EXT()](../globals/#ext) für eine verzögerte Änderung.\n\nExample: Beispiel\n```js\nSET('user', { a: 1 });\nM.extend('user', { b: 2 });\nconsole.log(GET('user')); // {\"a\":1,\"b\":2}\n```\n\n### M.inc(path, value, [type])\n\nType: `method`\n\nAddiert eine Zahl zu einem Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Number` | yes |  | Die Zahl. |\n| `type` | `Number` | no |  | Der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n\nVerwende [INC()](../globals/#inc) für eine verzögerte Änderung.\n\nExample: Beispiel\n```js\nM.inc('count', 2);\nconsole.log(GET('count')); // 2\n```\n\n### M.loaded\n\nType: `property`\n\n`true`, nachdem die gespeicherten Einstellungen geladen wurden.\n\nExample: Beispiel\n```js\nsetTimeout(function() {\n\tconsole.log(M.loaded); // true\n}, 500);\n```\n\n### M.macros\n\nType: `property`\n\nDie deklarierten Macros nach Namen.\n\nExample: Beispiel\n```js\nMACRO('upper', NOOP);\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### M.months\n\nType: `property`\n\nDasselbe Array wie [MONTHS](../globals/#months).\n\nExample: Beispiel\n```js\nconsole.log(M.months === MONTHS); // true\n```\n\n### M.parse(type, value, [format])\n\nType: `method`\n\nWandelt einen Wert mit den registrierten Parsern um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Der Typ, zum Beispiel `number`. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `format` | `String` | no |  | Das Format, das an die Parser übergeben wird. |\n\nReturns: `Object` Der umgewandelte Wert.\n\nExample: Beispiel\n```js\nconsole.log(M.parse('number', '5')); // 5\n```\n\n### M.paths\n\nType: `property`\n\nDie Anzahl der Watcher und Komponenten für jeden Path.\n\nExample: Beispiel\n```js\nWATCH('user.name', NOOP);\nconsole.log(M.paths['user.name']); // 1\n```\n\n### M.performance\n\nType: `property`\n\nNutzungszähler, die gesammelt werden, wenn `DEF.monitor` den Wert `true` hat.\n\nExample: Beispiel\n```js\nDEF.monitor = true;\nGET('a');\nconsole.log(M.performance.get.count > 0); // true\n```\n\n### M.plugin([name])\n\nType: `method`\n\nLiest oder ändert den aktuellen Plugin-Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Der neue Scope. |\n\nReturns: `String` Der aktuelle Scope.\n\nExample: Beispiel\n```js\nM.plugin('users');\nconsole.log(M.plugin()); // users\n```\n\n### M.prototypes(fn)\n\nType: `method`\n\nGibt Zugriff auf die Prototypen der Objekte der Bibliothek.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(proto)`. |\n\nDas Objekt hat die Felder `Component`, `Plugin` und `VBinder`.\n\nExample: Beispiel\n```js\nM.prototypes(function(proto) {\n\tproto.Component.hello = () => 'Hello';\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').hello()); // Hello\n});\n```\n\n### M.push(path, value, [type])\n\nType: `method`\n\nFügt einem Array einen Wert hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Object` | yes |  | Das Element. |\n| `type` | `Number` | no |  | Der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n\nVerwende [PUSH()](../globals/#push) für eine verzögerte Änderung.\n\nExample: Beispiel\n```js\nM.push('list', 1);\nconsole.log(GET('list')); // [1]\n```\n\n### M.scope([name])\n\nType: `method`\n\nDieselbe Funktion wie [M.plugin()](#plugin).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Der neue Scope. |\n\nReturns: `String` Der aktuelle Scope.\n\nExample: Beispiel\n```js\nconsole.log(M.scope === M.plugin); // true\n```\n\n### M.scrollbars\n\nType: `property`\n\nEin Array der benutzerdefinierten Scrollbars.\n\nExample: Beispiel\n```js\nconsole.log(M.scrollbars.length); // 0\n```\n\n### M.set(path, value, [type])\n\nType: `method`\n\nSchreibt einen Wert in einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `type` | `Number` | no |  | Der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n\nVerwende [SET()](../globals/#set) für eine verzögerte Änderung.\n\nExample: Beispiel\n```js\nM.set('name', 'Peter');\nconsole.log(GET('name')); // Peter\n```\n\n### M.ua\n\nType: `property`\n\nDer geparste User-Agent mit den Feldern `os`, `browser` und `device`.\n\nExample: Beispiel\n```js\nconsole.log(Object.keys(M.ua)); // [\"os\",\"browser\",\"device\"]\n```\n\n### M.update(path, [reset], [type])\n\nType: `method`\n\nAktualisiert alles, was an einen Path gebunden ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `reset` | `Boolean` | no |  | Setzt den Zustand der Komponenten zurück. |\n| `type` | `Number` | no |  | Der Änderungstyp: `1` manuell, `2` Eingabe, `3` Standardwert. |\n\nVerwende [UPD()](../globals/#upd) für eine verzögerte Änderung.\n\nExample: Beispiel\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nM.update('user.name');\n```\n\n### M.version\n\nType: `property`\n\nDie Version der Bibliothek.\n\nExample: Beispiel\n```js\nconsole.log(M.version); // 19.194\n```\n","entries":[{"type":"property","name":"M.binders","signature":"M.binders","since":"","deprecated":false},{"type":"property","name":"M.cl","signature":"M.cl","since":"","deprecated":false},{"type":"method","name":"M.compile()","signature":"M.compile([container])","since":"","deprecated":false},{"type":"property","name":"M.components","signature":"M.components","since":"","deprecated":false},{"type":"property","name":"M.days","signature":"M.days","since":"","deprecated":false},{"type":"method","name":"M.default()","signature":"M.default(path, [delay], [component], [reset])","since":"","deprecated":false},{"type":"property","name":"M.defaults","signature":"M.defaults","since":"","deprecated":false},{"type":"method","name":"M.each()","signature":"M.each(fn, [path])","since":"","deprecated":false},{"type":"property","name":"M.events","signature":"M.events","since":"","deprecated":false},{"type":"method","name":"M.extend()","signature":"M.extend(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.inc()","signature":"M.inc(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.loaded","signature":"M.loaded","since":"","deprecated":false},{"type":"property","name":"M.macros","signature":"M.macros","since":"","deprecated":false},{"type":"property","name":"M.months","signature":"M.months","since":"","deprecated":false},{"type":"method","name":"M.parse()","signature":"M.parse(type, value, [format])","since":"","deprecated":false},{"type":"property","name":"M.paths","signature":"M.paths","since":"","deprecated":false},{"type":"property","name":"M.performance","signature":"M.performance","since":"","deprecated":false},{"type":"method","name":"M.plugin()","signature":"M.plugin([name])","since":"","deprecated":false},{"type":"method","name":"M.prototypes()","signature":"M.prototypes(fn)","since":"","deprecated":false},{"type":"method","name":"M.push()","signature":"M.push(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.scope()","signature":"M.scope([name])","since":"","deprecated":false},{"type":"property","name":"M.scrollbars","signature":"M.scrollbars","since":"","deprecated":false},{"type":"method","name":"M.set()","signature":"M.set(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.ua","signature":"M.ua","since":"","deprecated":false},{"type":"method","name":"M.update()","signature":"M.update(path, [reset], [type])","since":"","deprecated":false},{"type":"property","name":"M.version","signature":"M.version","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammeu5oj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/m/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"M","summary":"Los miembros del objeto principal de la biblioteca.","markdown":"---\ntitle: M\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/m/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# M\n\n> Los miembros del objeto principal de la biblioteca.\n\n`M` es un nombre corto de [MAIN](../main/). La mayoría de las aplicaciones usan las [funciones globales](../globals/) en lugar de estos miembros. Para conocer los conceptos en los que se basan, lee [Paths](../../guides/paths/).\n\n## API\n\n### M.binders\n\nType: `property`\n\nUn array con los enlaces de datos activos.\n\nExample: Ejemplo\n```js\nSET('name', 'Peter');\nsetTimeout(function() {\n\tconsole.log(M.binders.length); // 1\n}, 300);\n```\n\n### M.cl\n\nType: `property`\n\nLas listas de códigos declaradas, por nombre.\n\nExample: Ejemplo\n```js\nCL_INIT('roles', next => next([]));\nconsole.log(Object.keys(M.cl)); // [\"roles\"]\n```\n\n### M.compile([container])\n\nType: `method`\n\nBusca en la página componentes y enlaces nuevos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limita la búsqueda a este elemento. |\n\nUsa [COMPILE()](../globals/#compile) en tu código.\n\nExample: Ejemplo\n```js\nconsole.log(typeof(M.compile)); // function\n```\n\n### M.components\n\nType: `property`\n\nUn array con los componentes creados.\n\nExample: Ejemplo\n```js\nON('ready', function() {\n\tconsole.log(M.components.length); // 2\n});\n```\n\n### M.days\n\nType: `property`\n\nEl mismo array que [DAYS](../globals/#days).\n\nExample: Ejemplo\n```js\nconsole.log(M.days === DAYS); // true\n```\n\n### M.default(path, [delay], [component], [reset])\n\nType: `method`\n\nRestaura los valores predeterminados de los componentes de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `delay` | `Number` | no |  | Un retardo en milisegundos. |\n| `component` | `Component` | no |  | Limita el cambio a un componente. |\n| `reset` | `Boolean` | no | `true` | Con `false`, se conserva el estado. |\n\nUsa [DEFAULT()](../globals/#default) en tu código.\n\nExample: Ejemplo\n```js\nconsole.log(typeof(M.default)); // function\n```\n\n### M.defaults\n\nType: `property`\n\nEl mismo objeto que [DEF](../def/).\n\nExample: Ejemplo\n```js\nconsole.log(M.defaults === DEF); // true\n```\n\n### M.each(fn, [path])\n\nType: `method`\n\nLlama a una función para cada componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(component, index, wildcard)`. |\n| `path` | `String` | no |  | Limita la llamada a un path. |\n\nDevuelve `true` desde la función para detenerte.\n\nExample: Ejemplo\n```js\nON('ready', function() {\n\tvar paths = [];\n\tM.each(com => paths.push(com.path), 'form.*');\n\tconsole.log(paths.length); // 2\n});\n```\n\n### M.events\n\nType: `property`\n\nLos manejadores de eventos registrados, por nombre de evento.\n\nExample: Ejemplo\n```js\nON('hello', NOOP);\nconsole.log(M.events.hello.length); // 1\n```\n\n### M.extend(path, value, [type])\n\nType: `method`\n\nFusiona campos en un objeto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Object` | yes |  | Los campos. |\n| `type` | `Number` | no |  | El tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n\nUsa [EXT()](../globals/#ext) para un cambio retrasado.\n\nExample: Ejemplo\n```js\nSET('user', { a: 1 });\nM.extend('user', { b: 2 });\nconsole.log(GET('user')); // {\"a\":1,\"b\":2}\n```\n\n### M.inc(path, value, [type])\n\nType: `method`\n\nSuma un número a un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Number` | yes |  | El número. |\n| `type` | `Number` | no |  | El tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n\nUsa [INC()](../globals/#inc) para un cambio retrasado.\n\nExample: Ejemplo\n```js\nM.inc('count', 2);\nconsole.log(GET('count')); // 2\n```\n\n### M.loaded\n\nType: `property`\n\n`true` después de cargar las preferencias guardadas.\n\nExample: Ejemplo\n```js\nsetTimeout(function() {\n\tconsole.log(M.loaded); // true\n}, 500);\n```\n\n### M.macros\n\nType: `property`\n\nLas macros declaradas, por nombre.\n\nExample: Ejemplo\n```js\nMACRO('upper', NOOP);\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### M.months\n\nType: `property`\n\nEl mismo array que [MONTHS](../globals/#months).\n\nExample: Ejemplo\n```js\nconsole.log(M.months === MONTHS); // true\n```\n\n### M.parse(type, value, [format])\n\nType: `method`\n\nConvierte un valor con los parsers registrados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | El tipo, por ejemplo `number`. |\n| `value` | `Object` | yes |  | El valor. |\n| `format` | `String` | no |  | El formato que se pasa a los parsers. |\n\nReturns: `Object` El valor convertido.\n\nExample: Ejemplo\n```js\nconsole.log(M.parse('number', '5')); // 5\n```\n\n### M.paths\n\nType: `property`\n\nEl número de observadores y componentes de cada path.\n\nExample: Ejemplo\n```js\nWATCH('user.name', NOOP);\nconsole.log(M.paths['user.name']); // 1\n```\n\n### M.performance\n\nType: `property`\n\nContadores de uso, que se recopilan cuando `DEF.monitor` es `true`.\n\nExample: Ejemplo\n```js\nDEF.monitor = true;\nGET('a');\nconsole.log(M.performance.get.count > 0); // true\n```\n\n### M.plugin([name])\n\nType: `method`\n\nLee o cambia el scope de plugin actual.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | El scope nuevo. |\n\nReturns: `String` El scope actual.\n\nExample: Ejemplo\n```js\nM.plugin('users');\nconsole.log(M.plugin()); // users\n```\n\n### M.prototypes(fn)\n\nType: `method`\n\nDa acceso a los prototipos de los objetos de la biblioteca.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(proto)`. |\n\nEl objeto tiene los campos `Component`, `Plugin` y `VBinder`.\n\nExample: Ejemplo\n```js\nM.prototypes(function(proto) {\n\tproto.Component.hello = () => 'Hello';\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').hello()); // Hello\n});\n```\n\n### M.push(path, value, [type])\n\nType: `method`\n\nAñade un valor a un array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Object` | yes |  | El elemento. |\n| `type` | `Number` | no |  | El tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n\nUsa [PUSH()](../globals/#push) para un cambio retrasado.\n\nExample: Ejemplo\n```js\nM.push('list', 1);\nconsole.log(GET('list')); // [1]\n```\n\n### M.scope([name])\n\nType: `method`\n\nLa misma función que [M.plugin()](#plugin).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | El scope nuevo. |\n\nReturns: `String` El scope actual.\n\nExample: Ejemplo\n```js\nconsole.log(M.scope === M.plugin); // true\n```\n\n### M.scrollbars\n\nType: `property`\n\nUn array con las barras de desplazamiento personalizadas.\n\nExample: Ejemplo\n```js\nconsole.log(M.scrollbars.length); // 0\n```\n\n### M.set(path, value, [type])\n\nType: `method`\n\nEscribe un valor en un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Object` | yes |  | El valor. |\n| `type` | `Number` | no |  | El tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n\nUsa [SET()](../globals/#set) para un cambio retrasado.\n\nExample: Ejemplo\n```js\nM.set('name', 'Peter');\nconsole.log(GET('name')); // Peter\n```\n\n### M.ua\n\nType: `property`\n\nEl agente de usuario analizado, con los campos `os`, `browser` y `device`.\n\nExample: Ejemplo\n```js\nconsole.log(Object.keys(M.ua)); // [\"os\",\"browser\",\"device\"]\n```\n\n### M.update(path, [reset], [type])\n\nType: `method`\n\nActualiza todo lo que está enlazado a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `reset` | `Boolean` | no |  | Restablece el estado de los componentes. |\n| `type` | `Number` | no |  | El tipo de cambio: `1` manual, `2` entrada, `3` predeterminado. |\n\nUsa [UPD()](../globals/#upd) para un cambio retrasado.\n\nExample: Ejemplo\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nM.update('user.name');\n```\n\n### M.version\n\nType: `property`\n\nLa versión de la biblioteca.\n\nExample: Ejemplo\n```js\nconsole.log(M.version); // 19.194\n```\n","entries":[{"type":"property","name":"M.binders","signature":"M.binders","since":"","deprecated":false},{"type":"property","name":"M.cl","signature":"M.cl","since":"","deprecated":false},{"type":"method","name":"M.compile()","signature":"M.compile([container])","since":"","deprecated":false},{"type":"property","name":"M.components","signature":"M.components","since":"","deprecated":false},{"type":"property","name":"M.days","signature":"M.days","since":"","deprecated":false},{"type":"method","name":"M.default()","signature":"M.default(path, [delay], [component], [reset])","since":"","deprecated":false},{"type":"property","name":"M.defaults","signature":"M.defaults","since":"","deprecated":false},{"type":"method","name":"M.each()","signature":"M.each(fn, [path])","since":"","deprecated":false},{"type":"property","name":"M.events","signature":"M.events","since":"","deprecated":false},{"type":"method","name":"M.extend()","signature":"M.extend(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.inc()","signature":"M.inc(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.loaded","signature":"M.loaded","since":"","deprecated":false},{"type":"property","name":"M.macros","signature":"M.macros","since":"","deprecated":false},{"type":"property","name":"M.months","signature":"M.months","since":"","deprecated":false},{"type":"method","name":"M.parse()","signature":"M.parse(type, value, [format])","since":"","deprecated":false},{"type":"property","name":"M.paths","signature":"M.paths","since":"","deprecated":false},{"type":"property","name":"M.performance","signature":"M.performance","since":"","deprecated":false},{"type":"method","name":"M.plugin()","signature":"M.plugin([name])","since":"","deprecated":false},{"type":"method","name":"M.prototypes()","signature":"M.prototypes(fn)","since":"","deprecated":false},{"type":"method","name":"M.push()","signature":"M.push(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.scope()","signature":"M.scope([name])","since":"","deprecated":false},{"type":"property","name":"M.scrollbars","signature":"M.scrollbars","since":"","deprecated":false},{"type":"method","name":"M.set()","signature":"M.set(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.ua","signature":"M.ua","since":"","deprecated":false},{"type":"method","name":"M.update()","signature":"M.update(path, [reset], [type])","since":"","deprecated":false},{"type":"property","name":"M.version","signature":"M.version","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammeu5oj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/m/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"M","summary":"Les membres de l'objet principal de la bibliothèque.","markdown":"---\ntitle: M\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/m/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# M\n\n> Les membres de l'objet principal de la bibliothèque.\n\n`M` est un nom court de [MAIN](../main/). La plupart des applications utilisent les [fonctions globales](../globals/) plutôt que ces membres. Pour les concepts sous-jacents, lis [Paths](../../guides/paths/).\n\n## API\n\n### M.binders\n\nType: `property`\n\nUn tableau des liaisons de données actives.\n\nExample: Exemple\n```js\nSET('name', 'Peter');\nsetTimeout(function() {\n\tconsole.log(M.binders.length); // 1\n}, 300);\n```\n\n### M.cl\n\nType: `property`\n\nLes listes de codes déclarées, classées par nom.\n\nExample: Exemple\n```js\nCL_INIT('roles', next => next([]));\nconsole.log(Object.keys(M.cl)); // [\"roles\"]\n```\n\n### M.compile([container])\n\nType: `method`\n\nRecherche sur la page les nouveaux composants et les nouvelles liaisons.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limite la recherche à cet élément. |\n\nUtilise [COMPILE()](../globals/#compile) dans ton code.\n\nExample: Exemple\n```js\nconsole.log(typeof(M.compile)); // function\n```\n\n### M.components\n\nType: `property`\n\nUn tableau des composants créés.\n\nExample: Exemple\n```js\nON('ready', function() {\n\tconsole.log(M.components.length); // 2\n});\n```\n\n### M.days\n\nType: `property`\n\nLe même tableau que [DAYS](../globals/#days).\n\nExample: Exemple\n```js\nconsole.log(M.days === DAYS); // true\n```\n\n### M.default(path, [delay], [component], [reset])\n\nType: `method`\n\nRétablit les valeurs par défaut des composants d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `delay` | `Number` | no |  | Un délai en millisecondes. |\n| `component` | `Component` | no |  | Limite le changement à un seul composant. |\n| `reset` | `Boolean` | no | `true` | Avec `false`, l'état est conservé. |\n\nUtilise [DEFAULT()](../globals/#default) dans ton code.\n\nExample: Exemple\n```js\nconsole.log(typeof(M.default)); // function\n```\n\n### M.defaults\n\nType: `property`\n\nLe même objet que [DEF](../def/).\n\nExample: Exemple\n```js\nconsole.log(M.defaults === DEF); // true\n```\n\n### M.each(fn, [path])\n\nType: `method`\n\nAppelle une fonction pour chaque composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(component, index, wildcard)`. |\n| `path` | `String` | no |  | Limite l'appel à un path. |\n\nRenvoie `true` depuis la fonction pour arrêter.\n\nExample: Exemple\n```js\nON('ready', function() {\n\tvar paths = [];\n\tM.each(com => paths.push(com.path), 'form.*');\n\tconsole.log(paths.length); // 2\n});\n```\n\n### M.events\n\nType: `property`\n\nLes gestionnaires d'événements enregistrés, classés par nom d'événement.\n\nExample: Exemple\n```js\nON('hello', NOOP);\nconsole.log(M.events.hello.length); // 1\n```\n\n### M.extend(path, value, [type])\n\nType: `method`\n\nFusionne des champs dans un objet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Object` | yes |  | Les champs. |\n| `type` | `Number` | no |  | Le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n\nUtilise [EXT()](../globals/#ext) pour un changement différé.\n\nExample: Exemple\n```js\nSET('user', { a: 1 });\nM.extend('user', { b: 2 });\nconsole.log(GET('user')); // {\"a\":1,\"b\":2}\n```\n\n### M.inc(path, value, [type])\n\nType: `method`\n\nAjoute un nombre à une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Number` | yes |  | Le nombre. |\n| `type` | `Number` | no |  | Le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n\nUtilise [INC()](../globals/#inc) pour un changement différé.\n\nExample: Exemple\n```js\nM.inc('count', 2);\nconsole.log(GET('count')); // 2\n```\n\n### M.loaded\n\nType: `property`\n\n`true` une fois les préférences stockées chargées.\n\nExample: Exemple\n```js\nsetTimeout(function() {\n\tconsole.log(M.loaded); // true\n}, 500);\n```\n\n### M.macros\n\nType: `property`\n\nLes macros déclarées, classées par nom.\n\nExample: Exemple\n```js\nMACRO('upper', NOOP);\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### M.months\n\nType: `property`\n\nLe même tableau que [MONTHS](../globals/#months).\n\nExample: Exemple\n```js\nconsole.log(M.months === MONTHS); // true\n```\n\n### M.parse(type, value, [format])\n\nType: `method`\n\nConvertit une valeur avec les parsers enregistrés.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Le type, par exemple `number`. |\n| `value` | `Object` | yes |  | La valeur. |\n| `format` | `String` | no |  | Le format passé aux parsers. |\n\nReturns: `Object` La valeur convertie.\n\nExample: Exemple\n```js\nconsole.log(M.parse('number', '5')); // 5\n```\n\n### M.paths\n\nType: `property`\n\nLe nombre d'observateurs et de composants pour chaque path.\n\nExample: Exemple\n```js\nWATCH('user.name', NOOP);\nconsole.log(M.paths['user.name']); // 1\n```\n\n### M.performance\n\nType: `property`\n\nLes compteurs d'utilisation, collectés quand `DEF.monitor` vaut `true`.\n\nExample: Exemple\n```js\nDEF.monitor = true;\nGET('a');\nconsole.log(M.performance.get.count > 0); // true\n```\n\n### M.plugin([name])\n\nType: `method`\n\nLit ou modifie le scope de plugin actuel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Le nouveau scope. |\n\nReturns: `String` Le scope actuel.\n\nExample: Exemple\n```js\nM.plugin('users');\nconsole.log(M.plugin()); // users\n```\n\n### M.prototypes(fn)\n\nType: `method`\n\nDonne accès aux prototypes des objets de la bibliothèque.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(proto)`. |\n\nL'objet possède les champs `Component`, `Plugin` et `VBinder`.\n\nExample: Exemple\n```js\nM.prototypes(function(proto) {\n\tproto.Component.hello = () => 'Hello';\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').hello()); // Hello\n});\n```\n\n### M.push(path, value, [type])\n\nType: `method`\n\nAjoute une valeur à un tableau.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Object` | yes |  | L'élément. |\n| `type` | `Number` | no |  | Le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n\nUtilise [PUSH()](../globals/#push) pour un changement différé.\n\nExample: Exemple\n```js\nM.push('list', 1);\nconsole.log(GET('list')); // [1]\n```\n\n### M.scope([name])\n\nType: `method`\n\nLa même fonction que [M.plugin()](#plugin).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Le nouveau scope. |\n\nReturns: `String` Le scope actuel.\n\nExample: Exemple\n```js\nconsole.log(M.scope === M.plugin); // true\n```\n\n### M.scrollbars\n\nType: `property`\n\nUn tableau des barres de défilement personnalisées.\n\nExample: Exemple\n```js\nconsole.log(M.scrollbars.length); // 0\n```\n\n### M.set(path, value, [type])\n\nType: `method`\n\nÉcrit une valeur dans un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Object` | yes |  | La valeur. |\n| `type` | `Number` | no |  | Le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n\nUtilise [SET()](../globals/#set) pour un changement différé.\n\nExample: Exemple\n```js\nM.set('name', 'Peter');\nconsole.log(GET('name')); // Peter\n```\n\n### M.ua\n\nType: `property`\n\nLe user agent analysé, avec les champs `os`, `browser` et `device`.\n\nExample: Exemple\n```js\nconsole.log(Object.keys(M.ua)); // [\"os\",\"browser\",\"device\"]\n```\n\n### M.update(path, [reset], [type])\n\nType: `method`\n\nActualise tout ce qui est lié à un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `reset` | `Boolean` | no |  | Réinitialise l'état des composants. |\n| `type` | `Number` | no |  | Le type de changement : `1` manuel, `2` saisie, `3` valeur par défaut. |\n\nUtilise [UPD()](../globals/#upd) pour un changement différé.\n\nExample: Exemple\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nM.update('user.name');\n```\n\n### M.version\n\nType: `property`\n\nLa version de la bibliothèque.\n\nExample: Exemple\n```js\nconsole.log(M.version); // 19.194\n```\n","entries":[{"type":"property","name":"M.binders","signature":"M.binders","since":"","deprecated":false},{"type":"property","name":"M.cl","signature":"M.cl","since":"","deprecated":false},{"type":"method","name":"M.compile()","signature":"M.compile([container])","since":"","deprecated":false},{"type":"property","name":"M.components","signature":"M.components","since":"","deprecated":false},{"type":"property","name":"M.days","signature":"M.days","since":"","deprecated":false},{"type":"method","name":"M.default()","signature":"M.default(path, [delay], [component], [reset])","since":"","deprecated":false},{"type":"property","name":"M.defaults","signature":"M.defaults","since":"","deprecated":false},{"type":"method","name":"M.each()","signature":"M.each(fn, [path])","since":"","deprecated":false},{"type":"property","name":"M.events","signature":"M.events","since":"","deprecated":false},{"type":"method","name":"M.extend()","signature":"M.extend(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.inc()","signature":"M.inc(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.loaded","signature":"M.loaded","since":"","deprecated":false},{"type":"property","name":"M.macros","signature":"M.macros","since":"","deprecated":false},{"type":"property","name":"M.months","signature":"M.months","since":"","deprecated":false},{"type":"method","name":"M.parse()","signature":"M.parse(type, value, [format])","since":"","deprecated":false},{"type":"property","name":"M.paths","signature":"M.paths","since":"","deprecated":false},{"type":"property","name":"M.performance","signature":"M.performance","since":"","deprecated":false},{"type":"method","name":"M.plugin()","signature":"M.plugin([name])","since":"","deprecated":false},{"type":"method","name":"M.prototypes()","signature":"M.prototypes(fn)","since":"","deprecated":false},{"type":"method","name":"M.push()","signature":"M.push(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.scope()","signature":"M.scope([name])","since":"","deprecated":false},{"type":"property","name":"M.scrollbars","signature":"M.scrollbars","since":"","deprecated":false},{"type":"method","name":"M.set()","signature":"M.set(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.ua","signature":"M.ua","since":"","deprecated":false},{"type":"method","name":"M.update()","signature":"M.update(path, [reset], [type])","since":"","deprecated":false},{"type":"property","name":"M.version","signature":"M.version","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammeu5oj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/m/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"M","summary":"I membri dell'oggetto principale della libreria.","markdown":"---\ntitle: M\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/m/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# M\n\n> I membri dell'oggetto principale della libreria.\n\n`M` è un nome breve di [MAIN](../main/). La maggior parte delle applicazioni usa le [funzioni globali](../globals/) al posto di questi membri. Per i concetti alla base, leggi [Path](../../guides/paths/).\n\n## API\n\n### M.binders\n\nType: `property`\n\nUn array delle associazioni dei dati attive.\n\nExample: Esempio\n```js\nSET('name', 'Peter');\nsetTimeout(function() {\n\tconsole.log(M.binders.length); // 1\n}, 300);\n```\n\n### M.cl\n\nType: `property`\n\nGli elenchi di codici dichiarati, per nome.\n\nExample: Esempio\n```js\nCL_INIT('roles', next => next([]));\nconsole.log(Object.keys(M.cl)); // [\"roles\"]\n```\n\n### M.compile([container])\n\nType: `method`\n\nCerca nella pagina nuovi componenti e nuove associazioni.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Limita la ricerca a questo elemento. |\n\nNel tuo codice usa [COMPILE()](../globals/#compile).\n\nExample: Esempio\n```js\nconsole.log(typeof(M.compile)); // function\n```\n\n### M.components\n\nType: `property`\n\nUn array dei componenti creati.\n\nExample: Esempio\n```js\nON('ready', function() {\n\tconsole.log(M.components.length); // 2\n});\n```\n\n### M.days\n\nType: `property`\n\nLo stesso array di [DAYS](../globals/#days).\n\nExample: Esempio\n```js\nconsole.log(M.days === DAYS); // true\n```\n\n### M.default(path, [delay], [component], [reset])\n\nType: `method`\n\nRipristina i valori predefiniti dei componenti su un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `delay` | `Number` | no |  | Un ritardo in millisecondi. |\n| `component` | `Component` | no |  | Limita la modifica a un solo componente. |\n| `reset` | `Boolean` | no | `true` | Con `false`, lo stato viene mantenuto. |\n\nNel tuo codice usa [DEFAULT()](../globals/#default).\n\nExample: Esempio\n```js\nconsole.log(typeof(M.default)); // function\n```\n\n### M.defaults\n\nType: `property`\n\nLo stesso oggetto di [DEF](../def/).\n\nExample: Esempio\n```js\nconsole.log(M.defaults === DEF); // true\n```\n\n### M.each(fn, [path])\n\nType: `method`\n\nChiama una funzione per ogni componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(component, index, wildcard)`. |\n| `path` | `String` | no |  | Limita la chiamata a un path. |\n\nRestituisci `true` dalla funzione per interrompere.\n\nExample: Esempio\n```js\nON('ready', function() {\n\tvar paths = [];\n\tM.each(com => paths.push(com.path), 'form.*');\n\tconsole.log(paths.length); // 2\n});\n```\n\n### M.events\n\nType: `property`\n\nI gestori di eventi registrati, per nome dell'evento.\n\nExample: Esempio\n```js\nON('hello', NOOP);\nconsole.log(M.events.hello.length); // 1\n```\n\n### M.extend(path, value, [type])\n\nType: `method`\n\nUnisce i campi a un oggetto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Object` | yes |  | I campi. |\n| `type` | `Number` | no |  | Il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n\nUsa [EXT()](../globals/#ext) per una modifica ritardata.\n\nExample: Esempio\n```js\nSET('user', { a: 1 });\nM.extend('user', { b: 2 });\nconsole.log(GET('user')); // {\"a\":1,\"b\":2}\n```\n\n### M.inc(path, value, [type])\n\nType: `method`\n\nAggiunge un numero a un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Number` | yes |  | Il numero. |\n| `type` | `Number` | no |  | Il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n\nUsa [INC()](../globals/#inc) per una modifica ritardata.\n\nExample: Esempio\n```js\nM.inc('count', 2);\nconsole.log(GET('count')); // 2\n```\n\n### M.loaded\n\nType: `property`\n\n`true` dopo il caricamento delle preferenze memorizzate.\n\nExample: Esempio\n```js\nsetTimeout(function() {\n\tconsole.log(M.loaded); // true\n}, 500);\n```\n\n### M.macros\n\nType: `property`\n\nLe macro dichiarate, per nome.\n\nExample: Esempio\n```js\nMACRO('upper', NOOP);\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### M.months\n\nType: `property`\n\nLo stesso array di [MONTHS](../globals/#months).\n\nExample: Esempio\n```js\nconsole.log(M.months === MONTHS); // true\n```\n\n### M.parse(type, value, [format])\n\nType: `method`\n\nConverte un valore con i parser registrati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Il tipo, ad esempio `number`. |\n| `value` | `Object` | yes |  | Il valore. |\n| `format` | `String` | no |  | Il formato passato ai parser. |\n\nReturns: `Object` Il valore convertito.\n\nExample: Esempio\n```js\nconsole.log(M.parse('number', '5')); // 5\n```\n\n### M.paths\n\nType: `property`\n\nIl numero di osservatori e componenti per ogni path.\n\nExample: Esempio\n```js\nWATCH('user.name', NOOP);\nconsole.log(M.paths['user.name']); // 1\n```\n\n### M.performance\n\nType: `property`\n\nI contatori di utilizzo, raccolti quando `DEF.monitor` è `true`.\n\nExample: Esempio\n```js\nDEF.monitor = true;\nGET('a');\nconsole.log(M.performance.get.count > 0); // true\n```\n\n### M.plugin([name])\n\nType: `method`\n\nLegge o modifica lo scope corrente del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Il nuovo scope. |\n\nReturns: `String` Lo scope corrente.\n\nExample: Esempio\n```js\nM.plugin('users');\nconsole.log(M.plugin()); // users\n```\n\n### M.prototypes(fn)\n\nType: `method`\n\nDà accesso ai prototipi degli oggetti della libreria.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(proto)`. |\n\nL'oggetto ha i campi `Component`, `Plugin` e `VBinder`.\n\nExample: Esempio\n```js\nM.prototypes(function(proto) {\n\tproto.Component.hello = () => 'Hello';\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').hello()); // Hello\n});\n```\n\n### M.push(path, value, [type])\n\nType: `method`\n\nAggiunge un valore a un array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Object` | yes |  | L'elemento. |\n| `type` | `Number` | no |  | Il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n\nUsa [PUSH()](../globals/#push) per una modifica ritardata.\n\nExample: Esempio\n```js\nM.push('list', 1);\nconsole.log(GET('list')); // [1]\n```\n\n### M.scope([name])\n\nType: `method`\n\nLa stessa funzione di [M.plugin()](#plugin).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Il nuovo scope. |\n\nReturns: `String` Lo scope corrente.\n\nExample: Esempio\n```js\nconsole.log(M.scope === M.plugin); // true\n```\n\n### M.scrollbars\n\nType: `property`\n\nUn array delle barre di scorrimento personalizzate.\n\nExample: Esempio\n```js\nconsole.log(M.scrollbars.length); // 0\n```\n\n### M.set(path, value, [type])\n\nType: `method`\n\nScrive un valore in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Object` | yes |  | Il valore. |\n| `type` | `Number` | no |  | Il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n\nUsa [SET()](../globals/#set) per una modifica ritardata.\n\nExample: Esempio\n```js\nM.set('name', 'Peter');\nconsole.log(GET('name')); // Peter\n```\n\n### M.ua\n\nType: `property`\n\nLo user agent analizzato, con i campi `os`, `browser` e `device`.\n\nExample: Esempio\n```js\nconsole.log(Object.keys(M.ua)); // [\"os\",\"browser\",\"device\"]\n```\n\n### M.update(path, [reset], [type])\n\nType: `method`\n\nAggiorna tutto ciò che è associato a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `reset` | `Boolean` | no |  | Reimposta lo stato dei componenti. |\n| `type` | `Number` | no |  | Il tipo di modifica: `1` manuale, `2` input, `3` predefinito. |\n\nUsa [UPD()](../globals/#upd) per una modifica ritardata.\n\nExample: Esempio\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nM.update('user.name');\n```\n\n### M.version\n\nType: `property`\n\nLa versione della libreria.\n\nExample: Esempio\n```js\nconsole.log(M.version); // 19.194\n```\n","entries":[{"type":"property","name":"M.binders","signature":"M.binders","since":"","deprecated":false},{"type":"property","name":"M.cl","signature":"M.cl","since":"","deprecated":false},{"type":"method","name":"M.compile()","signature":"M.compile([container])","since":"","deprecated":false},{"type":"property","name":"M.components","signature":"M.components","since":"","deprecated":false},{"type":"property","name":"M.days","signature":"M.days","since":"","deprecated":false},{"type":"method","name":"M.default()","signature":"M.default(path, [delay], [component], [reset])","since":"","deprecated":false},{"type":"property","name":"M.defaults","signature":"M.defaults","since":"","deprecated":false},{"type":"method","name":"M.each()","signature":"M.each(fn, [path])","since":"","deprecated":false},{"type":"property","name":"M.events","signature":"M.events","since":"","deprecated":false},{"type":"method","name":"M.extend()","signature":"M.extend(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.inc()","signature":"M.inc(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.loaded","signature":"M.loaded","since":"","deprecated":false},{"type":"property","name":"M.macros","signature":"M.macros","since":"","deprecated":false},{"type":"property","name":"M.months","signature":"M.months","since":"","deprecated":false},{"type":"method","name":"M.parse()","signature":"M.parse(type, value, [format])","since":"","deprecated":false},{"type":"property","name":"M.paths","signature":"M.paths","since":"","deprecated":false},{"type":"property","name":"M.performance","signature":"M.performance","since":"","deprecated":false},{"type":"method","name":"M.plugin()","signature":"M.plugin([name])","since":"","deprecated":false},{"type":"method","name":"M.prototypes()","signature":"M.prototypes(fn)","since":"","deprecated":false},{"type":"method","name":"M.push()","signature":"M.push(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.scope()","signature":"M.scope([name])","since":"","deprecated":false},{"type":"property","name":"M.scrollbars","signature":"M.scrollbars","since":"","deprecated":false},{"type":"method","name":"M.set()","signature":"M.set(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.ua","signature":"M.ua","since":"","deprecated":false},{"type":"method","name":"M.update()","signature":"M.update(path, [reset], [type])","since":"","deprecated":false},{"type":"property","name":"M.version","signature":"M.version","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammeu5oj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/m/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"M","summary":"Členovia hlavného objektu knižnice.","markdown":"---\ntitle: M\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/m/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# M\n\n> Členovia hlavného objektu knižnice.\n\n`M` je krátky názov pre [MAIN](../main/). Väčšina aplikácií namiesto týchto členov používa [globálne funkcie](../globals/). Základné pojmy nájdeš v časti [Paths](../../guides/paths/).\n\n## API\n\n### M.binders\n\nType: `property`\n\nPole aktívnych dátových väzieb.\n\nExample: Príklad\n```js\nSET('name', 'Peter');\nsetTimeout(function() {\n\tconsole.log(M.binders.length); // 1\n}, 300);\n```\n\n### M.cl\n\nType: `property`\n\nDeklarované zoznamy kódov podľa názvu.\n\nExample: Príklad\n```js\nCL_INIT('roles', next => next([]));\nconsole.log(Object.keys(M.cl)); // [\"roles\"]\n```\n\n### M.compile([container])\n\nType: `method`\n\nVyhľadá na stránke nové komponenty a väzby.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `Element|jQuery` | no |  | Obmedzí vyhľadávanie na tento element. |\n\nVo svojom kóde použi [COMPILE()](../globals/#compile).\n\nExample: Príklad\n```js\nconsole.log(typeof(M.compile)); // function\n```\n\n### M.components\n\nType: `property`\n\nPole vytvorených komponentov.\n\nExample: Príklad\n```js\nON('ready', function() {\n\tconsole.log(M.components.length); // 2\n});\n```\n\n### M.days\n\nType: `property`\n\nTo isté pole ako [DAYS](../globals/#days).\n\nExample: Príklad\n```js\nconsole.log(M.days === DAYS); // true\n```\n\n### M.default(path, [delay], [component], [reset])\n\nType: `method`\n\nObnoví predvolené hodnoty komponentov na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n| `component` | `Component` | no |  | Obmedzí zmenu na jeden komponent. |\n| `reset` | `Boolean` | no | `true` | S hodnotou `false` sa stav zachová. |\n\nVo svojom kóde použi [DEFAULT()](../globals/#default).\n\nExample: Príklad\n```js\nconsole.log(typeof(M.default)); // function\n```\n\n### M.defaults\n\nType: `property`\n\nTen istý objekt ako [DEF](../def/).\n\nExample: Príklad\n```js\nconsole.log(M.defaults === DEF); // true\n```\n\n### M.each(fn, [path])\n\nType: `method`\n\nZavolá funkciu pre každý komponent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(component, index, wildcard)`. |\n| `path` | `String` | no |  | Obmedzí volanie na path. |\n\nAk chceš skončiť, vráť z funkcie `true`.\n\nExample: Príklad\n```js\nON('ready', function() {\n\tvar paths = [];\n\tM.each(com => paths.push(com.path), 'form.*');\n\tconsole.log(paths.length); // 2\n});\n```\n\n### M.events\n\nType: `property`\n\nZaregistrované obslužné funkcie udalostí podľa názvu udalosti.\n\nExample: Príklad\n```js\nON('hello', NOOP);\nconsole.log(M.events.hello.length); // 1\n```\n\n### M.extend(path, value, [type])\n\nType: `method`\n\nZlúči polia do objektu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Object` | yes |  | Polia. |\n| `type` | `Number` | no |  | Typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n\nNa oneskorenú zmenu použi [EXT()](../globals/#ext).\n\nExample: Príklad\n```js\nSET('user', { a: 1 });\nM.extend('user', { b: 2 });\nconsole.log(GET('user')); // {\"a\":1,\"b\":2}\n```\n\n### M.inc(path, value, [type])\n\nType: `method`\n\nPripočíta číslo k hodnote.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Number` | yes |  | Číslo. |\n| `type` | `Number` | no |  | Typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n\nNa oneskorenú zmenu použi [INC()](../globals/#inc).\n\nExample: Príklad\n```js\nM.inc('count', 2);\nconsole.log(GET('count')); // 2\n```\n\n### M.loaded\n\nType: `property`\n\n`true` po načítaní uložených preferencií.\n\nExample: Príklad\n```js\nsetTimeout(function() {\n\tconsole.log(M.loaded); // true\n}, 500);\n```\n\n### M.macros\n\nType: `property`\n\nDeklarované macros podľa názvu.\n\nExample: Príklad\n```js\nMACRO('upper', NOOP);\nconsole.log(typeof(M.macros.upper)); // function\n```\n\n### M.months\n\nType: `property`\n\nTo isté pole ako [MONTHS](../globals/#months).\n\nExample: Príklad\n```js\nconsole.log(M.months === MONTHS); // true\n```\n\n### M.parse(type, value, [format])\n\nType: `method`\n\nPrevedie hodnotu pomocou zaregistrovaných parserov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Typ, napríklad `number`. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `format` | `String` | no |  | Formát odovzdaný parserom. |\n\nReturns: `Object` Prevedená hodnota.\n\nExample: Príklad\n```js\nconsole.log(M.parse('number', '5')); // 5\n```\n\n### M.paths\n\nType: `property`\n\nPočet sledovačov a komponentov pre každý path.\n\nExample: Príklad\n```js\nWATCH('user.name', NOOP);\nconsole.log(M.paths['user.name']); // 1\n```\n\n### M.performance\n\nType: `property`\n\nPočítadlá používania, ktoré sa zbierajú, keď má `DEF.monitor` hodnotu `true`.\n\nExample: Príklad\n```js\nDEF.monitor = true;\nGET('a');\nconsole.log(M.performance.get.count > 0); // true\n```\n\n### M.plugin([name])\n\nType: `method`\n\nPrečíta alebo zmení aktuálny scope pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Nový scope. |\n\nReturns: `String` Aktuálny scope.\n\nExample: Príklad\n```js\nM.plugin('users');\nconsole.log(M.plugin()); // users\n```\n\n### M.prototypes(fn)\n\nType: `method`\n\nSprístupní prototypy objektov knižnice.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | `function(proto)`. |\n\nObjekt má polia `Component`, `Plugin` a `VBinder`.\n\nExample: Príklad\n```js\nM.prototypes(function(proto) {\n\tproto.Component.hello = () => 'Hello';\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').hello()); // Hello\n});\n```\n\n### M.push(path, value, [type])\n\nType: `method`\n\nPridá hodnotu do poľa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Object` | yes |  | Položka. |\n| `type` | `Number` | no |  | Typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n\nNa oneskorenú zmenu použi [PUSH()](../globals/#push).\n\nExample: Príklad\n```js\nM.push('list', 1);\nconsole.log(GET('list')); // [1]\n```\n\n### M.scope([name])\n\nType: `method`\n\nRovnaká funkcia ako [M.plugin()](#plugin).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Nový scope. |\n\nReturns: `String` Aktuálny scope.\n\nExample: Príklad\n```js\nconsole.log(M.scope === M.plugin); // true\n```\n\n### M.scrollbars\n\nType: `property`\n\nPole vlastných posuvníkov.\n\nExample: Príklad\n```js\nconsole.log(M.scrollbars.length); // 0\n```\n\n### M.set(path, value, [type])\n\nType: `method`\n\nZapíše hodnotu do path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `type` | `Number` | no |  | Typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n\nNa oneskorenú zmenu použi [SET()](../globals/#set).\n\nExample: Príklad\n```js\nM.set('name', 'Peter');\nconsole.log(GET('name')); // Peter\n```\n\n### M.ua\n\nType: `property`\n\nSpracovaný user agent s poľami `os`, `browser` a `device`.\n\nExample: Príklad\n```js\nconsole.log(Object.keys(M.ua)); // [\"os\",\"browser\",\"device\"]\n```\n\n### M.update(path, [reset], [type])\n\nType: `method`\n\nObnoví všetko, čo je naviazané na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `reset` | `Boolean` | no |  | Vynuluje stav komponentov. |\n| `type` | `Number` | no |  | Typ zmeny: `1` ručná, `2` vstup, `3` predvolená. |\n\nNa oneskorenú zmenu použi [UPD()](../globals/#upd).\n\nExample: Príklad\n```js\nSET('user', { name: 'Peter' });\nWATCH('user.name', function(path, value) {\n\tconsole.log(value); // Anna\n});\nGET('user').name = 'Anna';\nM.update('user.name');\n```\n\n### M.version\n\nType: `property`\n\nVerzia knižnice.\n\nExample: Príklad\n```js\nconsole.log(M.version); // 19.194\n```\n","entries":[{"type":"property","name":"M.binders","signature":"M.binders","since":"","deprecated":false},{"type":"property","name":"M.cl","signature":"M.cl","since":"","deprecated":false},{"type":"method","name":"M.compile()","signature":"M.compile([container])","since":"","deprecated":false},{"type":"property","name":"M.components","signature":"M.components","since":"","deprecated":false},{"type":"property","name":"M.days","signature":"M.days","since":"","deprecated":false},{"type":"method","name":"M.default()","signature":"M.default(path, [delay], [component], [reset])","since":"","deprecated":false},{"type":"property","name":"M.defaults","signature":"M.defaults","since":"","deprecated":false},{"type":"method","name":"M.each()","signature":"M.each(fn, [path])","since":"","deprecated":false},{"type":"property","name":"M.events","signature":"M.events","since":"","deprecated":false},{"type":"method","name":"M.extend()","signature":"M.extend(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.inc()","signature":"M.inc(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.loaded","signature":"M.loaded","since":"","deprecated":false},{"type":"property","name":"M.macros","signature":"M.macros","since":"","deprecated":false},{"type":"property","name":"M.months","signature":"M.months","since":"","deprecated":false},{"type":"method","name":"M.parse()","signature":"M.parse(type, value, [format])","since":"","deprecated":false},{"type":"property","name":"M.paths","signature":"M.paths","since":"","deprecated":false},{"type":"property","name":"M.performance","signature":"M.performance","since":"","deprecated":false},{"type":"method","name":"M.plugin()","signature":"M.plugin([name])","since":"","deprecated":false},{"type":"method","name":"M.prototypes()","signature":"M.prototypes(fn)","since":"","deprecated":false},{"type":"method","name":"M.push()","signature":"M.push(path, value, [type])","since":"","deprecated":false},{"type":"method","name":"M.scope()","signature":"M.scope([name])","since":"","deprecated":false},{"type":"property","name":"M.scrollbars","signature":"M.scrollbars","since":"","deprecated":false},{"type":"method","name":"M.set()","signature":"M.set(path, value, [type])","since":"","deprecated":false},{"type":"property","name":"M.ua","signature":"M.ua","since":"","deprecated":false},{"type":"method","name":"M.update()","signature":"M.update(path, [reset], [type])","since":"","deprecated":false},{"type":"property","name":"M.version","signature":"M.version","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammhx9Sj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/pref/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"PREF","summary":"User preferences stored in the browser.","markdown":"---\ntitle: PREF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/pref/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# PREF\n\n> User preferences stored in the browser.\n\n`PREF` stores small values with an expiration in the browser. The values are ready before the first components start. Stored paths can also be read with [GET()](../globals/#get), as explained in [Paths](../../guides/paths/).\n\n## API\n\n### PREF.get(key, [expire])\n\nType: `method`\n\nReads a stored value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The key. |\n| `expire` | `String` | no |  | Stores the value again with this expiration. |\n\nReturns: `Object` The value, or `undefined` when it does not exist or has expired.\n\nA stored value is also available as a property, for example `PREF.theme`.\n\nExample: Read a value\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.get('theme')); // dark\nconsole.log(PREF.theme); // dark\n```\n\n### PREF.set(key, [value], [expire])\n\nType: `method`\n\nStores a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The key. |\n| `value` | `Object` | no |  | The value. |\n| `expire` | `String` | no | `1 month` | For example `1 day`. |\n\nReturns: `Object` The value.\n\nWithout a value, the key is removed. Watchers and components on the path `PREF.key` are notified. The data is saved after `DEF.delaypref` milliseconds. The keys `get`, `set`, `keys`, `load` and `save` are not available as properties.\n\nExample: Store and watch a value\n```js\nWATCH('PREF.theme', function(path, value) {\n\tconsole.log(value); // dark\n});\nPREF.set('theme', 'dark', '1 day');\n```\n\nExample: Remove a value\n```js\nPREF.set('theme', 'dark');\nPREF.set('theme');\nconsole.log(PREF.theme === undefined); // true\n```\n\n### PREF.keys()\n\nType: `method`\n\nLists the stored keys.\n\nReturns: `Array` The keys.\n\nExample: List the keys\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.keys()); // [\"theme\"]\n```\n\n### PREF.load(callback)\n\nType: `method`\n\nReads the stored data when the page starts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | `function(data)`. |\n\nReplace this function to read the data from another place. Pass the data to the callback as an object where each key holds `{ value, expire }`.\n\nExample: Load from your own source\n```js\nPREF.load = function(callback) {\n\tcallback({ theme: { value: 'dark', expire: NOW.add('1 day') } });\n};\nsetTimeout(function() {\n\tconsole.log(PREF.theme); // dark\n}, 500);\n```\n\n### PREF.save(data)\n\nType: `method`\n\nWrites the stored data.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `data` | `Object` | yes |  | The data to save. |\n\nReplace this function to save the data to another place. By default, the data goes to the browser storage under `DEF.localstorage` plus `.pref`.\n\nExample: Save to your own target\n```js\nDEF.delaypref = 50;\nPREF.save = function(data) {\n\tconsole.log(data.theme.value); // dark\n};\nPREF.set('theme', 'dark');\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key, [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.keys()","signature":"PREF.keys()","since":"","deprecated":false},{"type":"method","name":"PREF.load()","signature":"PREF.load(callback)","since":"","deprecated":false},{"type":"method","name":"PREF.save()","signature":"PREF.save(data)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammhx9Sj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/pref/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"PREF","summary":"Im Browser gespeicherte Benutzereinstellungen.","markdown":"---\ntitle: PREF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/pref/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# PREF\n\n> Im Browser gespeicherte Benutzereinstellungen.\n\n`PREF` speichert kleine Werte mit einer Ablaufzeit im Browser. Die Werte stehen bereit, bevor die ersten Komponenten starten. Gespeicherte Paths lassen sich auch mit [GET()](../globals/#get) lesen, wie unter [Paths](../../guides/paths/) erklärt.\n\n## API\n\n### PREF.get(key, [expire])\n\nType: `method`\n\nLiest einen gespeicherten Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Schlüssel. |\n| `expire` | `String` | no |  | Speichert den Wert erneut mit dieser Ablaufzeit. |\n\nReturns: `Object` Der Wert oder `undefined`, wenn er nicht existiert oder abgelaufen ist.\n\nEin gespeicherter Wert ist auch als Eigenschaft verfügbar, zum Beispiel `PREF.theme`.\n\nExample: Wert lesen\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.get('theme')); // dark\nconsole.log(PREF.theme); // dark\n```\n\n### PREF.set(key, [value], [expire])\n\nType: `method`\n\nSpeichert einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Schlüssel. |\n| `value` | `Object` | no |  | Der Wert. |\n| `expire` | `String` | no | `1 month` | Zum Beispiel `1 day`. |\n\nReturns: `Object` Der Wert.\n\nOhne Wert wird der Schlüssel entfernt. Watcher und Komponenten auf dem Path `PREF.key` werden benachrichtigt. Die Daten werden nach `DEF.delaypref` Millisekunden gespeichert. Die Schlüssel `get`, `set`, `keys`, `load` und `save` sind nicht als Eigenschaften verfügbar.\n\nExample: Einen Wert speichern und überwachen\n```js\nWATCH('PREF.theme', function(path, value) {\n\tconsole.log(value); // dark\n});\nPREF.set('theme', 'dark', '1 day');\n```\n\nExample: Einen Wert entfernen\n```js\nPREF.set('theme', 'dark');\nPREF.set('theme');\nconsole.log(PREF.theme === undefined); // true\n```\n\n### PREF.keys()\n\nType: `method`\n\nListet die gespeicherten Schlüssel auf.\n\nReturns: `Array` Die Schlüssel.\n\nExample: Die Schlüssel auflisten\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.keys()); // [\"theme\"]\n```\n\n### PREF.load(callback)\n\nType: `method`\n\nLiest die gespeicherten Daten beim Start der Seite.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | `function(data)`. |\n\nErsetze diese Funktion, um die Daten von einem anderen Ort zu lesen. Übergib die Daten dem Callback als Objekt, in dem jeder Schlüssel `{ value, expire }` enthält.\n\nExample: Aus einer eigenen Quelle laden\n```js\nPREF.load = function(callback) {\n\tcallback({ theme: { value: 'dark', expire: NOW.add('1 day') } });\n};\nsetTimeout(function() {\n\tconsole.log(PREF.theme); // dark\n}, 500);\n```\n\n### PREF.save(data)\n\nType: `method`\n\nSchreibt die gespeicherten Daten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `data` | `Object` | yes |  | Die Daten, die gespeichert werden. |\n\nErsetze diese Funktion, um die Daten an einem anderen Ort zu speichern. Standardmäßig kommen die Daten unter `DEF.localstorage` plus `.pref` in den Browser-Speicher.\n\nExample: In einem eigenen Ziel speichern\n```js\nDEF.delaypref = 50;\nPREF.save = function(data) {\n\tconsole.log(data.theme.value); // dark\n};\nPREF.set('theme', 'dark');\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key, [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.keys()","signature":"PREF.keys()","since":"","deprecated":false},{"type":"method","name":"PREF.load()","signature":"PREF.load(callback)","since":"","deprecated":false},{"type":"method","name":"PREF.save()","signature":"PREF.save(data)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammhx9Sj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/pref/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"PREF","summary":"Preferencias de usuario guardadas en el navegador.","markdown":"---\ntitle: PREF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/pref/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# PREF\n\n> Preferencias de usuario guardadas en el navegador.\n\n`PREF` guarda en el navegador valores pequeños con una caducidad. Los valores están listos antes de que se inicien los primeros componentes. Los paths guardados también se pueden leer con [GET()](../globals/#get), como se explica en [Paths](../../guides/paths/).\n\n## API\n\n### PREF.get(key, [expire])\n\nType: `method`\n\nLee un valor guardado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clave. |\n| `expire` | `String` | no |  | Vuelve a guardar el valor con esta caducidad. |\n\nReturns: `Object` El valor, o `undefined` cuando no existe o ha caducado.\n\nUn valor guardado también está disponible como propiedad, por ejemplo `PREF.theme`.\n\nExample: Leer un valor\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.get('theme')); // dark\nconsole.log(PREF.theme); // dark\n```\n\n### PREF.set(key, [value], [expire])\n\nType: `method`\n\nGuarda un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clave. |\n| `value` | `Object` | no |  | El valor. |\n| `expire` | `String` | no | `1 month` | Por ejemplo, `1 day`. |\n\nReturns: `Object` El valor.\n\nSin valor, la clave se elimina. Se notifica a los observadores y componentes del path `PREF.key`. Los datos se guardan después de `DEF.delaypref` milisegundos. Las claves `get`, `set`, `keys`, `load` y `save` no están disponibles como propiedades.\n\nExample: Guardar y observar un valor\n```js\nWATCH('PREF.theme', function(path, value) {\n\tconsole.log(value); // dark\n});\nPREF.set('theme', 'dark', '1 day');\n```\n\nExample: Eliminar un valor\n```js\nPREF.set('theme', 'dark');\nPREF.set('theme');\nconsole.log(PREF.theme === undefined); // true\n```\n\n### PREF.keys()\n\nType: `method`\n\nEnumera las claves guardadas.\n\nReturns: `Array` Las claves.\n\nExample: Enumerar las claves\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.keys()); // [\"theme\"]\n```\n\n### PREF.load(callback)\n\nType: `method`\n\nLee los datos guardados cuando se inicia la página.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | `function(data)`. |\n\nSustituye esta función para leer los datos desde otro lugar. Pasa los datos al callback como un objeto en el que cada clave contiene `{ value, expire }`.\n\nExample: Cargar desde tu propio origen\n```js\nPREF.load = function(callback) {\n\tcallback({ theme: { value: 'dark', expire: NOW.add('1 day') } });\n};\nsetTimeout(function() {\n\tconsole.log(PREF.theme); // dark\n}, 500);\n```\n\n### PREF.save(data)\n\nType: `method`\n\nEscribe los datos guardados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `data` | `Object` | yes |  | Los datos que se guardan. |\n\nSustituye esta función para guardar los datos en otro lugar. Por defecto, los datos van al almacenamiento del navegador con la clave `DEF.localstorage` seguida de `.pref`.\n\nExample: Guardar en tu propio destino\n```js\nDEF.delaypref = 50;\nPREF.save = function(data) {\n\tconsole.log(data.theme.value); // dark\n};\nPREF.set('theme', 'dark');\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key, [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.keys()","signature":"PREF.keys()","since":"","deprecated":false},{"type":"method","name":"PREF.load()","signature":"PREF.load(callback)","since":"","deprecated":false},{"type":"method","name":"PREF.save()","signature":"PREF.save(data)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammhx9Sj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/pref/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"PREF","summary":"Les préférences utilisateur stockées dans le navigateur.","markdown":"---\ntitle: PREF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/pref/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# PREF\n\n> Les préférences utilisateur stockées dans le navigateur.\n\n`PREF` stocke de petites valeurs avec une expiration dans le navigateur. Les valeurs sont prêtes avant le démarrage des premiers composants. Les paths stockés peuvent aussi être lus avec [GET()](../globals/#get), comme l'explique [Paths](../../guides/paths/).\n\n## API\n\n### PREF.get(key, [expire])\n\nType: `method`\n\nLit une valeur stockée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé. |\n| `expire` | `String` | no |  | Stocke de nouveau la valeur avec cette expiration. |\n\nReturns: `Object` La valeur, ou `undefined` quand elle n'existe pas ou qu'elle a expiré.\n\nUne valeur stockée est aussi disponible sous forme de propriété, par exemple `PREF.theme`.\n\nExample: Lire une valeur\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.get('theme')); // dark\nconsole.log(PREF.theme); // dark\n```\n\n### PREF.set(key, [value], [expire])\n\nType: `method`\n\nStocke une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé. |\n| `value` | `Object` | no |  | La valeur. |\n| `expire` | `String` | no | `1 month` | Par exemple `1 day`. |\n\nReturns: `Object` La valeur.\n\nSans valeur, la clé est supprimée. Les observateurs et les composants du path `PREF.key` sont notifiés. Les données sont enregistrées après `DEF.delaypref` millisecondes. Les clés `get`, `set`, `keys`, `load` et `save` ne sont pas disponibles sous forme de propriétés.\n\nExample: Stocker et observer une valeur\n```js\nWATCH('PREF.theme', function(path, value) {\n\tconsole.log(value); // dark\n});\nPREF.set('theme', 'dark', '1 day');\n```\n\nExample: Supprimer une valeur\n```js\nPREF.set('theme', 'dark');\nPREF.set('theme');\nconsole.log(PREF.theme === undefined); // true\n```\n\n### PREF.keys()\n\nType: `method`\n\nListe les clés stockées.\n\nReturns: `Array` Les clés.\n\nExample: Lister les clés\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.keys()); // [\"theme\"]\n```\n\n### PREF.load(callback)\n\nType: `method`\n\nLit les données stockées au démarrage de la page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | `function(data)`. |\n\nRemplace cette fonction pour lire les données depuis un autre endroit. Passe les données au callback sous la forme d'un objet dont chaque clé contient `{ value, expire }`.\n\nExample: Charger depuis ta propre source\n```js\nPREF.load = function(callback) {\n\tcallback({ theme: { value: 'dark', expire: NOW.add('1 day') } });\n};\nsetTimeout(function() {\n\tconsole.log(PREF.theme); // dark\n}, 500);\n```\n\n### PREF.save(data)\n\nType: `method`\n\nÉcrit les données stockées.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `data` | `Object` | yes |  | Les données à enregistrer. |\n\nRemplace cette fonction pour enregistrer les données à un autre endroit. Par défaut, les données vont dans le stockage du navigateur sous `DEF.localstorage` suivi de `.pref`.\n\nExample: Enregistrer vers ta propre cible\n```js\nDEF.delaypref = 50;\nPREF.save = function(data) {\n\tconsole.log(data.theme.value); // dark\n};\nPREF.set('theme', 'dark');\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key, [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.keys()","signature":"PREF.keys()","since":"","deprecated":false},{"type":"method","name":"PREF.load()","signature":"PREF.load(callback)","since":"","deprecated":false},{"type":"method","name":"PREF.save()","signature":"PREF.save(data)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammhx9Sj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/pref/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"PREF","summary":"Le preferenze utente memorizzate nel browser.","markdown":"---\ntitle: PREF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/pref/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# PREF\n\n> Le preferenze utente memorizzate nel browser.\n\n`PREF` memorizza nel browser piccoli valori con una scadenza. I valori sono pronti prima dell'avvio dei primi componenti. I path memorizzati possono essere letti anche con [GET()](../globals/#get), come spiegato in [Path](../../guides/paths/).\n\n## API\n\n### PREF.get(key, [expire])\n\nType: `method`\n\nLegge un valore memorizzato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La chiave. |\n| `expire` | `String` | no |  | Memorizza di nuovo il valore con questa scadenza. |\n\nReturns: `Object` Il valore, oppure `undefined` quando non esiste o è scaduto.\n\nUn valore memorizzato è disponibile anche come proprietà, ad esempio `PREF.theme`.\n\nExample: Leggi un valore\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.get('theme')); // dark\nconsole.log(PREF.theme); // dark\n```\n\n### PREF.set(key, [value], [expire])\n\nType: `method`\n\nMemorizza un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La chiave. |\n| `value` | `Object` | no |  | Il valore. |\n| `expire` | `String` | no | `1 month` | Ad esempio `1 day`. |\n\nReturns: `Object` Il valore.\n\nSenza un valore, la chiave viene rimossa. Gli osservatori e i componenti sul path `PREF.key` vengono notificati. I dati vengono salvati dopo `DEF.delaypref` millisecondi. Le chiavi `get`, `set`, `keys`, `load` e `save` non sono disponibili come proprietà.\n\nExample: Memorizza e osserva un valore\n```js\nWATCH('PREF.theme', function(path, value) {\n\tconsole.log(value); // dark\n});\nPREF.set('theme', 'dark', '1 day');\n```\n\nExample: Rimuovi un valore\n```js\nPREF.set('theme', 'dark');\nPREF.set('theme');\nconsole.log(PREF.theme === undefined); // true\n```\n\n### PREF.keys()\n\nType: `method`\n\nElenca le chiavi memorizzate.\n\nReturns: `Array` Le chiavi.\n\nExample: Elenca le chiavi\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.keys()); // [\"theme\"]\n```\n\n### PREF.load(callback)\n\nType: `method`\n\nLegge i dati memorizzati all'avvio della pagina.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | `function(data)`. |\n\nSostituisci questa funzione per leggere i dati da un'altra posizione. Passa i dati alla callback come oggetto in cui ogni chiave contiene `{ value, expire }`.\n\nExample: Carica da una tua origine\n```js\nPREF.load = function(callback) {\n\tcallback({ theme: { value: 'dark', expire: NOW.add('1 day') } });\n};\nsetTimeout(function() {\n\tconsole.log(PREF.theme); // dark\n}, 500);\n```\n\n### PREF.save(data)\n\nType: `method`\n\nScrive i dati memorizzati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `data` | `Object` | yes |  | I dati da salvare. |\n\nSostituisci questa funzione per salvare i dati in un'altra posizione. Per impostazione predefinita, i dati finiscono nell'archiviazione del browser sotto `DEF.localstorage` seguito da `.pref`.\n\nExample: Salva in una tua destinazione\n```js\nDEF.delaypref = 50;\nPREF.save = function(data) {\n\tconsole.log(data.theme.value); // dark\n};\nPREF.set('theme', 'dark');\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key, [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.keys()","signature":"PREF.keys()","since":"","deprecated":false},{"type":"method","name":"PREF.load()","signature":"PREF.load(callback)","since":"","deprecated":false},{"type":"method","name":"PREF.save()","signature":"PREF.save(data)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammhx9Sj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/pref/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"PREF","summary":"Preferencie používateľa uložené v prehliadači.","markdown":"---\ntitle: PREF\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/pref/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# PREF\n\n> Preferencie používateľa uložené v prehliadači.\n\n`PREF` ukladá v prehliadači malé hodnoty s expiráciou. Hodnoty sú pripravené ešte pred štartom prvých komponentov. Uložené paths môžeš čítať aj pomocou [GET()](../globals/#get), ako vysvetľuje časť [Paths](../../guides/paths/).\n\n## API\n\n### PREF.get(key, [expire])\n\nType: `method`\n\nPrečíta uloženú hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Kľúč. |\n| `expire` | `String` | no |  | Uloží hodnotu znova s touto expiráciou. |\n\nReturns: `Object` Hodnota alebo `undefined`, keď neexistuje alebo jej vypršala platnosť.\n\nUložená hodnota je dostupná aj ako vlastnosť, napríklad `PREF.theme`.\n\nExample: Prečítaj hodnotu\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.get('theme')); // dark\nconsole.log(PREF.theme); // dark\n```\n\n### PREF.set(key, [value], [expire])\n\nType: `method`\n\nUloží hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Kľúč. |\n| `value` | `Object` | no |  | Hodnota. |\n| `expire` | `String` | no | `1 month` | Napríklad `1 day`. |\n\nReturns: `Object` Hodnota.\n\nBez hodnoty sa kľúč odstráni. Sledovače a komponenty na path `PREF.key` dostanú upozornenie. Dáta sa uložia po `DEF.delaypref` milisekundách. Kľúče `get`, `set`, `keys`, `load` a `save` nie sú dostupné ako vlastnosti.\n\nExample: Ulož a sleduj hodnotu\n```js\nWATCH('PREF.theme', function(path, value) {\n\tconsole.log(value); // dark\n});\nPREF.set('theme', 'dark', '1 day');\n```\n\nExample: Odstráň hodnotu\n```js\nPREF.set('theme', 'dark');\nPREF.set('theme');\nconsole.log(PREF.theme === undefined); // true\n```\n\n### PREF.keys()\n\nType: `method`\n\nVypíše uložené kľúče.\n\nReturns: `Array` Kľúče.\n\nExample: Vypíš kľúče\n```js\nPREF.set('theme', 'dark');\nconsole.log(PREF.keys()); // [\"theme\"]\n```\n\n### PREF.load(callback)\n\nType: `method`\n\nPri štarte stránky prečíta uložené dáta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | `function(data)`. |\n\nNahraď túto funkciu, ak chceš čítať dáta z iného miesta. Dáta odovzdaj callbacku ako objekt, v ktorom každý kľúč obsahuje `{ value, expire }`.\n\nExample: Načítaj z vlastného zdroja\n```js\nPREF.load = function(callback) {\n\tcallback({ theme: { value: 'dark', expire: NOW.add('1 day') } });\n};\nsetTimeout(function() {\n\tconsole.log(PREF.theme); // dark\n}, 500);\n```\n\n### PREF.save(data)\n\nType: `method`\n\nZapíše uložené dáta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `data` | `Object` | yes |  | Dáta na uloženie. |\n\nNahraď túto funkciu, ak chceš ukladať dáta na iné miesto. Predvolene idú dáta do úložiska prehliadača pod kľúč `DEF.localstorage` s príponou `.pref`.\n\nExample: Ulož do vlastného cieľa\n```js\nDEF.delaypref = 50;\nPREF.save = function(data) {\n\tconsole.log(data.theme.value); // dark\n};\nPREF.set('theme', 'dark');\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key, [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"PREF.keys()","signature":"PREF.keys()","since":"","deprecated":false},{"type":"method","name":"PREF.load()","signature":"PREF.load(callback)","since":"","deprecated":false},{"type":"method","name":"PREF.save()","signature":"PREF.save(data)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammZP8MM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/events/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Events","summary":"The events that the library emits.","markdown":"---\ntitle: Events\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/events/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Events\n\n> The events that the library emits.\n\nHandle these events with [ON()](../globals/#on) and remove the handlers with [OFF()](../globals/#off). Your own events use the same functions with [EMIT()](../globals/#emit).\n\n## API\n\n### ON('init', function() {})\n\nType: `event`\n\nRuns once when the first components are ready, just before `ready`.\n\nA page without components does not emit this event.\n\nExample: Example\n```js\nON('init', function() {\n\tconsole.log('init'); // init\n});\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nRuns once when the first components are ready.\n\nA handler registered later runs immediately. A page without components does not emit this event.\n\nExample: Example\n```js\nON('ready', function() {\n\tconsole.log('ready'); // ready\n});\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nRuns when a component is ready.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | The component. |\n\nExample: Example\n```js\nON('component', function(com) {\n\tconsole.log(com.path); // data.box\n});\n```\n\n### ON('@name', function(component) {})\n\nType: `event`\n\nRuns when a component with this name is ready.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | The component. |\n\nExample: Example\n```js\nON('@box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### ON('#id', function(component) {})\n\nType: `event`\n\nRuns when a component with this identifier is ready.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | The component. |\n\nExample: Example\n```js\nON('#mybox', function(com) {\n\tconsole.log(com.id); // mybox\n});\n```\n\n### ON('component.compile', function(name, declaration) {})\n\nType: `event`\n\nRuns when a component is declared.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name. |\n| `declaration` | `Object` | yes |  | The declaration. |\n\nExample: Example\n```js\nON('component.compile', function(name) {\n\tconsole.log(name); // hello\n});\nCOMPONENT('hello', NOOP);\n```\n\n### ON('component.destroy', function(name, component) {})\n\nType: `event`\n\nRuns when a component is removed.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name. |\n| `component` | `Component` | yes |  | The component. |\n\nExample: Example\n```js\nON('component.destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('destroy', function(name, component) {})\n\nType: `event`\n\nRuns when a component is removed.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name. |\n| `component` | `Component` | yes |  | The component. |\n\nExample: Example\n```js\nON('destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('lazy', function(name, loading) {})\n\nType: `event`\n\nRuns when a lazy component starts and finishes loading.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name. |\n| `loading` | `Boolean` | yes |  | `true` at the start, `false` at the end. |\n\nExample: Example\n```js\nON('lazy', function(name, loading) {\n\tconsole.log(name, loading); // box true\n});\nsetTimeout(() => SETTER('box', 'hello', 'Peter'), 500);\n```\n\n### ON('binder', function(binder) {})\n\nType: `event`\n\nRuns when a data binding is ready.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | The binding. |\n\nExample: Example\n```js\nON('binder', function(binder) {\n\tconsole.log(binder.path); // user.name\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 plugin. |\n\nExample: Example\n```js\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\nPLUGIN('users', NOOP);\n```\n\n### ON('plugin.destroy', function(plugin) {})\n\nType: `event`\n\nRuns when a plugin is removed.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | The plugin. |\n\nExample: Example\n```js\nON('plugin.destroy', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n// Declaring a plugin again removes the previous one\nsetTimeout(() => PLUGIN('users', NOOP), 300);\nsetTimeout(() => PLUGIN('users', NOOP), 600);\n```\n\n### ON('cmd', function(name, a, b, c, d, e) {})\n\nType: `event`\n\nRuns before a command is sent to components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command. |\n| `a` | `Object` | yes |  | Up to five arguments. |\n\nExample: Example\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nCMD('refresh', 1);\n```\n\n### ON('exec', function(path, a, b, c, d) {})\n\nType: `event`\n\nRuns before [EXEC()](../globals/#exec) calls a function or a plugin method.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The target. |\n| `a` | `Object` | yes |  | Up to four arguments. |\n\nExample: Example\n```js\nON('exec', function(path, value) {\n\tconsole.log(path, value); // app.run 1\n});\nwindow.app = { run: NOOP };\nEXEC('app.run', 1);\n```\n\n### ON('setter', function(selector, method, a, b) {})\n\nType: `event`\n\nRuns before [SETTER()](../globals/#setter) calls components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector. |\n| `method` | `String` | yes |  | The method. |\n| `a` | `Object` | yes |  | The first two arguments, `a` and `b`. |\n\nExample: Example\n```js\nON('setter', function(selector, method, value) {\n\tconsole.log(selector, method, value); // box hello 1\n});\nSETTER('box', 'hello', 1);\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nRuns when an environment variable is written.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name. |\n| `value` | `Object` | yes |  | The value. |\n\nExample: Example\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // api /v1/\n});\nENV('api', '/v1/');\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nRuns after content is imported.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL. For HTML content, it starts with `$import`. |\n| `target` | `jQuery` | yes |  | The target element, or the created `script` or `link` element. |\n\nExample: Example\n```js\nON('import', function(url, target) {\n\tconsole.log(target.length); // 1\n});\nIMPORT('/part.html');\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nRuns before a request is sent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | The request: `url`, `method`, `headers`, `data`, `upload`, `scope` and more. |\n\nSet `options.cancel = true` to stop the request. `options.respond(response, [headers])` answers it without a server, and `options.throw(response, [headers], code)` answers it with an error.\n\nExample: Example\n```js\nON('request', function(options) {\n\tconsole.log(options.method, options.url); // GET /api/\n\toptions.respond({ ok: true });\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('response', function(output) {})\n\nType: `event`\n\nRuns after a response arrives, before the callback of the request.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | The result: `url`, `method`, `status`, `response`, `raw`, `headers`, `error`, `duration` and more. |\n\nSet `output.process = false` to skip the callback of the request.\n\nExample: Example\n```js\nON('response', function(output) {\n\tconsole.log(output.status, output.response.ok); // 200 true\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('error', function(output) {})\n\nType: `event`\n\nRuns when a request fails.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | The result of the request. |\n\nThe event is not emitted when `DEF.ajaxerrors` is `true`.\n\nExample: Example\n```js\nON('error', function(output) {\n\tconsole.log(output.status); // 500\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nRuns when [ERROR()](../globals/#error) finds an error.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | The checked value. |\n\nExample: Example\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid\n});\nERROR([{ error: 'Invalid' }]);\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 runs. |\n\nExample: Example\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nRuns every minute, just before `knockknock`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | The number of runs. |\n\nExample: Example\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nRuns after the size of the window changes.\n\nIt is delayed by 300 milliseconds, and it also runs once when the page starts.\n\nExample: Example\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nRuns when scrolling in a [SCROLLBAR()](../globals/#scrollbar) starts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | The scrolled element. |\n\nExample: Example\n```js\nON('scroll', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nRuns when scrolling in a [SCROLLBAR()](../globals/#scrollbar) stops.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | The scrolled element. |\n\nExample: Example\n```js\nON('scrollidle', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nRuns when the page moves to the background or back.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` when the page is visible. |\n\nExample: Example\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n$(window).trigger('visibilitychange');\n```\n\n### ON('@flag name', function(path, value, type) {})\n\nType: `event`\n\nRuns when a path or a method is used with the custom flag `@name`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Object` | yes |  | The value. |\n| `type` | `Number` | yes |  | The change type. |\n\nExample: Example\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.age 30\n});\nSET('user.age @saved', 30);\n```\n","entries":[{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"@name","signature":"ON('@name', function(component) {})","since":"","deprecated":false},{"type":"event","name":"#id","signature":"ON('#id', function(component) {})","since":"","deprecated":false},{"type":"event","name":"component.compile","signature":"ON('component.compile', function(name, declaration) {})","since":"","deprecated":false},{"type":"event","name":"component.destroy","signature":"ON('component.destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"destroy","signature":"ON('destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"lazy","signature":"ON('lazy', function(name, loading) {})","since":"","deprecated":false},{"type":"event","name":"binder","signature":"ON('binder', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"plugin.destroy","signature":"ON('plugin.destroy', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"cmd","signature":"ON('cmd', function(name, a, b, c, d, e) {})","since":"","deprecated":false},{"type":"event","name":"exec","signature":"ON('exec', function(path, a, b, c, d) {})","since":"","deprecated":false},{"type":"event","name":"setter","signature":"ON('setter', function(selector, method, a, b) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(output) {})","since":"","deprecated":false},{"type":"event","name":"error","signature":"ON('error', function(output) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","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":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false},{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path, value, type) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammZP8MM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/events/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Events","summary":"Die Events, die die Bibliothek auslöst.","markdown":"---\ntitle: Events\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/events/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Events\n\n> Die Events, die die Bibliothek auslöst.\n\nVerarbeite diese Events mit [ON()](../globals/#on) und entferne die Handler mit [OFF()](../globals/#off). Deine eigenen Events verwenden dieselben Funktionen zusammen mit [EMIT()](../globals/#emit).\n\n## API\n\n### ON('init', function() {})\n\nType: `event`\n\nLäuft einmal, wenn die ersten Komponenten bereit sind, direkt vor `ready`.\n\nEine Seite ohne Komponenten löst dieses Event nicht aus.\n\nExample: Beispiel\n```js\nON('init', function() {\n\tconsole.log('init'); // init\n});\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nLäuft einmal, wenn die ersten Komponenten bereit sind.\n\nEin später registrierter Handler läuft sofort. Eine Seite ohne Komponenten löst dieses Event nicht aus.\n\nExample: Beispiel\n```js\nON('ready', function() {\n\tconsole.log('ready'); // ready\n});\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nLäuft, wenn eine Komponente bereit ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Die Komponente. |\n\nExample: Beispiel\n```js\nON('component', function(com) {\n\tconsole.log(com.path); // data.box\n});\n```\n\n### ON('@name', function(component) {})\n\nType: `event`\n\nLäuft, wenn eine Komponente mit diesem Namen bereit ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Die Komponente. |\n\nExample: Beispiel\n```js\nON('@box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### ON('#id', function(component) {})\n\nType: `event`\n\nLäuft, wenn eine Komponente mit dieser Kennung bereit ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Die Komponente. |\n\nExample: Beispiel\n```js\nON('#mybox', function(com) {\n\tconsole.log(com.id); // mybox\n});\n```\n\n### ON('component.compile', function(name, declaration) {})\n\nType: `event`\n\nLäuft, wenn eine Komponente deklariert wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name. |\n| `declaration` | `Object` | yes |  | Die Deklaration. |\n\nExample: Beispiel\n```js\nON('component.compile', function(name) {\n\tconsole.log(name); // hello\n});\nCOMPONENT('hello', NOOP);\n```\n\n### ON('component.destroy', function(name, component) {})\n\nType: `event`\n\nLäuft, wenn eine Komponente entfernt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name. |\n| `component` | `Component` | yes |  | Die Komponente. |\n\nExample: Beispiel\n```js\nON('component.destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('destroy', function(name, component) {})\n\nType: `event`\n\nLäuft, wenn eine Komponente entfernt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name. |\n| `component` | `Component` | yes |  | Die Komponente. |\n\nExample: Beispiel\n```js\nON('destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('lazy', function(name, loading) {})\n\nType: `event`\n\nLäuft, wenn eine Lazy-Komponente zu laden beginnt und fertig geladen ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name. |\n| `loading` | `Boolean` | yes |  | `true` am Anfang, `false` am Ende. |\n\nExample: Beispiel\n```js\nON('lazy', function(name, loading) {\n\tconsole.log(name, loading); // box true\n});\nsetTimeout(() => SETTER('box', 'hello', 'Peter'), 500);\n```\n\n### ON('binder', function(binder) {})\n\nType: `event`\n\nLäuft, wenn eine Datenbindung bereit ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | Die Bindung. |\n\nExample: Beispiel\n```js\nON('binder', function(binder) {\n\tconsole.log(binder.path); // user.name\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 |  | Das Plugin. |\n\nExample: Beispiel\n```js\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\nPLUGIN('users', NOOP);\n```\n\n### ON('plugin.destroy', function(plugin) {})\n\nType: `event`\n\nLäuft, wenn ein Plugin entfernt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | Das Plugin. |\n\nExample: Beispiel\n```js\nON('plugin.destroy', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n// Declaring a plugin again removes the previous one\nsetTimeout(() => PLUGIN('users', NOOP), 300);\nsetTimeout(() => PLUGIN('users', NOOP), 600);\n```\n\n### ON('cmd', function(name, a, b, c, d, e) {})\n\nType: `event`\n\nLäuft, bevor ein Befehl an Komponenten gesendet wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehl. |\n| `a` | `Object` | yes |  | Bis zu fünf Argumente. |\n\nExample: Beispiel\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nCMD('refresh', 1);\n```\n\n### ON('exec', function(path, a, b, c, d) {})\n\nType: `event`\n\nLäuft, bevor [EXEC()](../globals/#exec) eine Funktion oder eine Plugin-Methode aufruft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Das Ziel. |\n| `a` | `Object` | yes |  | Bis zu vier Argumente. |\n\nExample: Beispiel\n```js\nON('exec', function(path, value) {\n\tconsole.log(path, value); // app.run 1\n});\nwindow.app = { run: NOOP };\nEXEC('app.run', 1);\n```\n\n### ON('setter', function(selector, method, a, b) {})\n\nType: `event`\n\nLäuft, bevor [SETTER()](../globals/#setter) Komponenten aufruft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor. |\n| `method` | `String` | yes |  | Die Methode. |\n| `a` | `Object` | yes |  | Die ersten beiden Argumente, `a` und `b`. |\n\nExample: Beispiel\n```js\nON('setter', function(selector, method, value) {\n\tconsole.log(selector, method, value); // box hello 1\n});\nSETTER('box', 'hello', 1);\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nLäuft, wenn eine Umgebungsvariable geschrieben wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name. |\n| `value` | `Object` | yes |  | Der Wert. |\n\nExample: Beispiel\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // api /v1/\n});\nENV('api', '/v1/');\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nLäuft, nachdem Inhalte importiert wurden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL. Bei HTML-Inhalten beginnt sie mit `$import`. |\n| `target` | `jQuery` | yes |  | Das Zielelement oder das erstellte `script`- oder `link`-Element. |\n\nExample: Beispiel\n```js\nON('import', function(url, target) {\n\tconsole.log(target.length); // 1\n});\nIMPORT('/part.html');\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nLäuft, bevor eine Anfrage gesendet wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Die Anfrage: `url`, `method`, `headers`, `data`, `upload`, `scope` und mehr. |\n\nSetze `options.cancel = true`, um die Anfrage zu stoppen. `options.respond(response, [headers])` beantwortet sie ohne Server, und `options.throw(response, [headers], code)` beantwortet sie mit einem Fehler.\n\nExample: Beispiel\n```js\nON('request', function(options) {\n\tconsole.log(options.method, options.url); // GET /api/\n\toptions.respond({ ok: true });\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('response', function(output) {})\n\nType: `event`\n\nLäuft, nachdem eine Antwort eingetroffen ist, vor dem Callback der Anfrage.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Das Ergebnis: `url`, `method`, `status`, `response`, `raw`, `headers`, `error`, `duration` und mehr. |\n\nSetze `output.process = false`, um den Callback der Anfrage zu überspringen.\n\nExample: Beispiel\n```js\nON('response', function(output) {\n\tconsole.log(output.status, output.response.ok); // 200 true\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('error', function(output) {})\n\nType: `event`\n\nLäuft, wenn eine Anfrage fehlschlägt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Das Ergebnis der Anfrage. |\n\nDas Event wird nicht ausgelöst, wenn `DEF.ajaxerrors` den Wert `true` hat.\n\nExample: Beispiel\n```js\nON('error', function(output) {\n\tconsole.log(output.status); // 500\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nLäuft, wenn [ERROR()](../globals/#error) einen Fehler findet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | Der geprüfte Wert. |\n\nExample: Beispiel\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid\n});\nERROR([{ error: 'Invalid' }]);\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 Durchläufe. |\n\nExample: Beispiel\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nLäuft jede Minute, direkt vor `knockknock`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Die Anzahl der Durchläufe. |\n\nExample: Beispiel\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nLäuft, nachdem sich die Größe des Fensters geändert hat.\n\nDas Event ist um 300 Millisekunden verzögert und läuft außerdem einmal beim Start der Seite.\n\nExample: Beispiel\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nLäuft, wenn das Scrollen in einer [SCROLLBAR()](../globals/#scrollbar) beginnt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Das gescrollte Element. |\n\nExample: Beispiel\n```js\nON('scroll', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nLäuft, wenn das Scrollen in einer [SCROLLBAR()](../globals/#scrollbar) endet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Das gescrollte Element. |\n\nExample: Beispiel\n```js\nON('scrollidle', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nLäuft, wenn die Seite in den Hintergrund wechselt oder von dort zurückkehrt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true`, wenn die Seite sichtbar ist. |\n\nExample: Beispiel\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n$(window).trigger('visibilitychange');\n```\n\n### ON('@flag name', function(path, value, type) {})\n\nType: `event`\n\nLäuft, wenn ein Path oder eine Methode mit dem benutzerdefinierten Flag `@name` verwendet wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `type` | `Number` | yes |  | Der Änderungstyp. |\n\nExample: Beispiel\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.age 30\n});\nSET('user.age @saved', 30);\n```\n","entries":[{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"@name","signature":"ON('@name', function(component) {})","since":"","deprecated":false},{"type":"event","name":"#id","signature":"ON('#id', function(component) {})","since":"","deprecated":false},{"type":"event","name":"component.compile","signature":"ON('component.compile', function(name, declaration) {})","since":"","deprecated":false},{"type":"event","name":"component.destroy","signature":"ON('component.destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"destroy","signature":"ON('destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"lazy","signature":"ON('lazy', function(name, loading) {})","since":"","deprecated":false},{"type":"event","name":"binder","signature":"ON('binder', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"plugin.destroy","signature":"ON('plugin.destroy', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"cmd","signature":"ON('cmd', function(name, a, b, c, d, e) {})","since":"","deprecated":false},{"type":"event","name":"exec","signature":"ON('exec', function(path, a, b, c, d) {})","since":"","deprecated":false},{"type":"event","name":"setter","signature":"ON('setter', function(selector, method, a, b) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(output) {})","since":"","deprecated":false},{"type":"event","name":"error","signature":"ON('error', function(output) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","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":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false},{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path, value, type) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammZP8MM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/events/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Eventos","summary":"Los eventos que emite la biblioteca.","markdown":"---\ntitle: Eventos\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/events/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Eventos\n\n> Los eventos que emite la biblioteca.\n\nGestiona estos eventos con [ON()](../globals/#on) y elimina los manejadores con [OFF()](../globals/#off). Tus propios eventos usan las mismas funciones con [EMIT()](../globals/#emit).\n\n## API\n\n### ON('init', function() {})\n\nType: `event`\n\nSe ejecuta una vez cuando los primeros componentes están listos, justo antes de `ready`.\n\nUna página sin componentes no emite este evento.\n\nExample: Ejemplo\n```js\nON('init', function() {\n\tconsole.log('init'); // init\n});\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nSe ejecuta una vez cuando los primeros componentes están listos.\n\nUn manejador registrado más tarde se ejecuta de inmediato. Una página sin componentes no emite este evento.\n\nExample: Ejemplo\n```js\nON('ready', function() {\n\tconsole.log('ready'); // ready\n});\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nSe ejecuta cuando un componente está listo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | El componente. |\n\nExample: Ejemplo\n```js\nON('component', function(com) {\n\tconsole.log(com.path); // data.box\n});\n```\n\n### ON('@name', function(component) {})\n\nType: `event`\n\nSe ejecuta cuando un componente con este nombre está listo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | El componente. |\n\nExample: Ejemplo\n```js\nON('@box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### ON('#id', function(component) {})\n\nType: `event`\n\nSe ejecuta cuando un componente con este identificador está listo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | El componente. |\n\nExample: Ejemplo\n```js\nON('#mybox', function(com) {\n\tconsole.log(com.id); // mybox\n});\n```\n\n### ON('component.compile', function(name, declaration) {})\n\nType: `event`\n\nSe ejecuta cuando se declara un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre. |\n| `declaration` | `Object` | yes |  | La declaración. |\n\nExample: Ejemplo\n```js\nON('component.compile', function(name) {\n\tconsole.log(name); // hello\n});\nCOMPONENT('hello', NOOP);\n```\n\n### ON('component.destroy', function(name, component) {})\n\nType: `event`\n\nSe ejecuta cuando se elimina un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre. |\n| `component` | `Component` | yes |  | El componente. |\n\nExample: Ejemplo\n```js\nON('component.destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('destroy', function(name, component) {})\n\nType: `event`\n\nSe ejecuta cuando se elimina un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre. |\n| `component` | `Component` | yes |  | El componente. |\n\nExample: Ejemplo\n```js\nON('destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('lazy', function(name, loading) {})\n\nType: `event`\n\nSe ejecuta cuando un componente lazy empieza y termina de cargarse.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre. |\n| `loading` | `Boolean` | yes |  | `true` al principio, `false` al final. |\n\nExample: Ejemplo\n```js\nON('lazy', function(name, loading) {\n\tconsole.log(name, loading); // box true\n});\nsetTimeout(() => SETTER('box', 'hello', 'Peter'), 500);\n```\n\n### ON('binder', function(binder) {})\n\nType: `event`\n\nSe ejecuta cuando un enlace de datos está listo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | El enlace. |\n\nExample: Ejemplo\n```js\nON('binder', function(binder) {\n\tconsole.log(binder.path); // user.name\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 |  | El plugin. |\n\nExample: Ejemplo\n```js\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\nPLUGIN('users', NOOP);\n```\n\n### ON('plugin.destroy', function(plugin) {})\n\nType: `event`\n\nSe ejecuta cuando se elimina un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | El plugin. |\n\nExample: Ejemplo\n```js\nON('plugin.destroy', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n// Declaring a plugin again removes the previous one\nsetTimeout(() => PLUGIN('users', NOOP), 300);\nsetTimeout(() => PLUGIN('users', NOOP), 600);\n```\n\n### ON('cmd', function(name, a, b, c, d, e) {})\n\nType: `event`\n\nSe ejecuta antes de enviar un comando a los componentes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El comando. |\n| `a` | `Object` | yes |  | Hasta cinco argumentos. |\n\nExample: Ejemplo\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nCMD('refresh', 1);\n```\n\n### ON('exec', function(path, a, b, c, d) {})\n\nType: `event`\n\nSe ejecuta antes de que [EXEC()](../globals/#exec) llame a una función o a un método de un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El destino. |\n| `a` | `Object` | yes |  | Hasta cuatro argumentos. |\n\nExample: Ejemplo\n```js\nON('exec', function(path, value) {\n\tconsole.log(path, value); // app.run 1\n});\nwindow.app = { run: NOOP };\nEXEC('app.run', 1);\n```\n\n### ON('setter', function(selector, method, a, b) {})\n\nType: `event`\n\nSe ejecuta antes de que [SETTER()](../globals/#setter) llame a los componentes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector. |\n| `method` | `String` | yes |  | El método. |\n| `a` | `Object` | yes |  | Los dos primeros argumentos, `a` y `b`. |\n\nExample: Ejemplo\n```js\nON('setter', function(selector, method, value) {\n\tconsole.log(selector, method, value); // box hello 1\n});\nSETTER('box', 'hello', 1);\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nSe ejecuta cuando se escribe una variable de entorno.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre. |\n| `value` | `Object` | yes |  | El valor. |\n\nExample: Ejemplo\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // api /v1/\n});\nENV('api', '/v1/');\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nSe ejecuta después de importar contenido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL. En el contenido HTML, empieza por `$import`. |\n| `target` | `jQuery` | yes |  | El elemento de destino, o el elemento `script` o `link` creado. |\n\nExample: Ejemplo\n```js\nON('import', function(url, target) {\n\tconsole.log(target.length); // 1\n});\nIMPORT('/part.html');\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nSe ejecuta antes de enviar una petición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La petición: `url`, `method`, `headers`, `data`, `upload`, `scope` y más. |\n\nAsigna `options.cancel = true` para detener la petición. `options.respond(response, [headers])` la responde sin servidor, y `options.throw(response, [headers], code)` la responde con un error.\n\nExample: Ejemplo\n```js\nON('request', function(options) {\n\tconsole.log(options.method, options.url); // GET /api/\n\toptions.respond({ ok: true });\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('response', function(output) {})\n\nType: `event`\n\nSe ejecuta cuando llega una respuesta, antes del callback de la petición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | El resultado: `url`, `method`, `status`, `response`, `raw`, `headers`, `error`, `duration` y más. |\n\nAsigna `output.process = false` para omitir el callback de la petición.\n\nExample: Ejemplo\n```js\nON('response', function(output) {\n\tconsole.log(output.status, output.response.ok); // 200 true\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('error', function(output) {})\n\nType: `event`\n\nSe ejecuta cuando falla una petición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | El resultado de la petición. |\n\nEl evento no se emite cuando `DEF.ajaxerrors` es `true`.\n\nExample: Ejemplo\n```js\nON('error', function(output) {\n\tconsole.log(output.status); // 500\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nSe ejecuta cuando [ERROR()](../globals/#error) encuentra un error.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | El valor comprobado. |\n\nExample: Ejemplo\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid\n});\nERROR([{ error: 'Invalid' }]);\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 ejecuciones. |\n\nExample: Ejemplo\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nSe ejecuta cada minuto, justo antes de `knockknock`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | El número de ejecuciones. |\n\nExample: Ejemplo\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nSe ejecuta después de que cambie el tamaño de la ventana.\n\nSe retrasa 300 milisegundos, y también se ejecuta una vez cuando se inicia la página.\n\nExample: Ejemplo\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nSe ejecuta cuando empieza el desplazamiento en un [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | El elemento desplazado. |\n\nExample: Ejemplo\n```js\nON('scroll', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nSe ejecuta cuando se detiene el desplazamiento en un [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | El elemento desplazado. |\n\nExample: Ejemplo\n```js\nON('scrollidle', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\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: Ejemplo\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n$(window).trigger('visibilitychange');\n```\n\n### ON('@flag name', function(path, value, type) {})\n\nType: `event`\n\nSe ejecuta cuando se usa un path o un método con el flag personalizado `@name`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Object` | yes |  | El valor. |\n| `type` | `Number` | yes |  | El tipo de cambio. |\n\nExample: Ejemplo\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.age 30\n});\nSET('user.age @saved', 30);\n```\n","entries":[{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"@name","signature":"ON('@name', function(component) {})","since":"","deprecated":false},{"type":"event","name":"#id","signature":"ON('#id', function(component) {})","since":"","deprecated":false},{"type":"event","name":"component.compile","signature":"ON('component.compile', function(name, declaration) {})","since":"","deprecated":false},{"type":"event","name":"component.destroy","signature":"ON('component.destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"destroy","signature":"ON('destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"lazy","signature":"ON('lazy', function(name, loading) {})","since":"","deprecated":false},{"type":"event","name":"binder","signature":"ON('binder', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"plugin.destroy","signature":"ON('plugin.destroy', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"cmd","signature":"ON('cmd', function(name, a, b, c, d, e) {})","since":"","deprecated":false},{"type":"event","name":"exec","signature":"ON('exec', function(path, a, b, c, d) {})","since":"","deprecated":false},{"type":"event","name":"setter","signature":"ON('setter', function(selector, method, a, b) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(output) {})","since":"","deprecated":false},{"type":"event","name":"error","signature":"ON('error', function(output) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","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":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false},{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path, value, type) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammZP8MM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/events/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Événements","summary":"Les événements émis par la bibliothèque.","markdown":"---\ntitle: \"Événements\"\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/events/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Événements\n\n> Les événements émis par la bibliothèque.\n\nGère ces événements avec [ON()](../globals/#on) et supprime les gestionnaires avec [OFF()](../globals/#off). Tes propres événements utilisent les mêmes fonctions avec [EMIT()](../globals/#emit).\n\n## API\n\n### ON('init', function() {})\n\nType: `event`\n\nS'exécute une fois quand les premiers composants sont prêts, juste avant `ready`.\n\nUne page sans composants n'émet pas cet événement.\n\nExample: Exemple\n```js\nON('init', function() {\n\tconsole.log('init'); // init\n});\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nS'exécute une fois quand les premiers composants sont prêts.\n\nUn gestionnaire enregistré plus tard s'exécute immédiatement. Une page sans composants n'émet pas cet événement.\n\nExample: Exemple\n```js\nON('ready', function() {\n\tconsole.log('ready'); // ready\n});\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nS'exécute quand un composant est prêt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Le composant. |\n\nExample: Exemple\n```js\nON('component', function(com) {\n\tconsole.log(com.path); // data.box\n});\n```\n\n### ON('@name', function(component) {})\n\nType: `event`\n\nS'exécute quand un composant portant ce nom est prêt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Le composant. |\n\nExample: Exemple\n```js\nON('@box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### ON('#id', function(component) {})\n\nType: `event`\n\nS'exécute quand un composant ayant cet identifiant est prêt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Le composant. |\n\nExample: Exemple\n```js\nON('#mybox', function(com) {\n\tconsole.log(com.id); // mybox\n});\n```\n\n### ON('component.compile', function(name, declaration) {})\n\nType: `event`\n\nS'exécute quand un composant est déclaré.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom. |\n| `declaration` | `Object` | yes |  | La déclaration. |\n\nExample: Exemple\n```js\nON('component.compile', function(name) {\n\tconsole.log(name); // hello\n});\nCOMPONENT('hello', NOOP);\n```\n\n### ON('component.destroy', function(name, component) {})\n\nType: `event`\n\nS'exécute quand un composant est supprimé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom. |\n| `component` | `Component` | yes |  | Le composant. |\n\nExample: Exemple\n```js\nON('component.destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('destroy', function(name, component) {})\n\nType: `event`\n\nS'exécute quand un composant est supprimé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom. |\n| `component` | `Component` | yes |  | Le composant. |\n\nExample: Exemple\n```js\nON('destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('lazy', function(name, loading) {})\n\nType: `event`\n\nS'exécute quand un composant différé commence et finit de se charger.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom. |\n| `loading` | `Boolean` | yes |  | `true` au début, `false` à la fin. |\n\nExample: Exemple\n```js\nON('lazy', function(name, loading) {\n\tconsole.log(name, loading); // box true\n});\nsetTimeout(() => SETTER('box', 'hello', 'Peter'), 500);\n```\n\n### ON('binder', function(binder) {})\n\nType: `event`\n\nS'exécute quand une liaison de données est prête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | La liaison. |\n\nExample: Exemple\n```js\nON('binder', function(binder) {\n\tconsole.log(binder.path); // user.name\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 |  | Le plugin. |\n\nExample: Exemple\n```js\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\nPLUGIN('users', NOOP);\n```\n\n### ON('plugin.destroy', function(plugin) {})\n\nType: `event`\n\nS'exécute quand un plugin est supprimé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | Le plugin. |\n\nExample: Exemple\n```js\nON('plugin.destroy', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n// Declaring a plugin again removes the previous one\nsetTimeout(() => PLUGIN('users', NOOP), 300);\nsetTimeout(() => PLUGIN('users', NOOP), 600);\n```\n\n### ON('cmd', function(name, a, b, c, d, e) {})\n\nType: `event`\n\nS'exécute avant l'envoi d'une commande aux composants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La commande. |\n| `a` | `Object` | yes |  | Jusqu'à cinq arguments. |\n\nExample: Exemple\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nCMD('refresh', 1);\n```\n\n### ON('exec', function(path, a, b, c, d) {})\n\nType: `event`\n\nS'exécute avant que [EXEC()](../globals/#exec) appelle une fonction ou une méthode de plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | La cible. |\n| `a` | `Object` | yes |  | Jusqu'à quatre arguments. |\n\nExample: Exemple\n```js\nON('exec', function(path, value) {\n\tconsole.log(path, value); // app.run 1\n});\nwindow.app = { run: NOOP };\nEXEC('app.run', 1);\n```\n\n### ON('setter', function(selector, method, a, b) {})\n\nType: `event`\n\nS'exécute avant que [SETTER()](../globals/#setter) appelle les composants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur. |\n| `method` | `String` | yes |  | La méthode. |\n| `a` | `Object` | yes |  | Les deux premiers arguments, `a` et `b`. |\n\nExample: Exemple\n```js\nON('setter', function(selector, method, value) {\n\tconsole.log(selector, method, value); // box hello 1\n});\nSETTER('box', 'hello', 1);\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nS'exécute quand une variable d'environnement est écrite.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom. |\n| `value` | `Object` | yes |  | La valeur. |\n\nExample: Exemple\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // api /v1/\n});\nENV('api', '/v1/');\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nS'exécute après l'import d'un contenu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. Pour un contenu HTML, elle commence par `$import`. |\n| `target` | `jQuery` | yes |  | L'élément cible, ou l'élément `script` ou `link` créé. |\n\nExample: Exemple\n```js\nON('import', function(url, target) {\n\tconsole.log(target.length); // 1\n});\nIMPORT('/part.html');\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nS'exécute avant l'envoi d'une requête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La requête : `url`, `method`, `headers`, `data`, `upload`, `scope` et d'autres. |\n\nDéfinis `options.cancel = true` pour arrêter la requête. `options.respond(response, [headers])` y répond sans serveur, et `options.throw(response, [headers], code)` y répond par une erreur.\n\nExample: Exemple\n```js\nON('request', function(options) {\n\tconsole.log(options.method, options.url); // GET /api/\n\toptions.respond({ ok: true });\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('response', function(output) {})\n\nType: `event`\n\nS'exécute à l'arrivée d'une réponse, avant le callback de la requête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Le résultat : `url`, `method`, `status`, `response`, `raw`, `headers`, `error`, `duration` et d'autres. |\n\nDéfinis `output.process = false` pour ignorer le callback de la requête.\n\nExample: Exemple\n```js\nON('response', function(output) {\n\tconsole.log(output.status, output.response.ok); // 200 true\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('error', function(output) {})\n\nType: `event`\n\nS'exécute quand une requête échoue.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Le résultat de la requête. |\n\nL'événement n'est pas émis quand `DEF.ajaxerrors` vaut `true`.\n\nExample: Exemple\n```js\nON('error', function(output) {\n\tconsole.log(output.status); // 500\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nS'exécute quand [ERROR()](../globals/#error) trouve une erreur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | La valeur vérifiée. |\n\nExample: Exemple\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid\n});\nERROR([{ error: 'Invalid' }]);\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 d'exécutions. |\n\nExample: Exemple\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nS'exécute chaque minute, juste avant `knockknock`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Le nombre d'exécutions. |\n\nExample: Exemple\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nS'exécute après un changement de taille de la fenêtre.\n\nIl est retardé de 300 millisecondes et s'exécute aussi une fois au démarrage de la page.\n\nExample: Exemple\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nS'exécute quand le défilement commence dans une [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'élément qui défile. |\n\nExample: Exemple\n```js\nON('scroll', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nS'exécute quand le défilement s'arrête dans une [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'élément qui défile. |\n\nExample: Exemple\n```js\nON('scrollidle', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nS'exécute quand la page passe en arrière-plan ou revient au premier plan.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` quand la page est visible. |\n\nExample: Exemple\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n$(window).trigger('visibilitychange');\n```\n\n### ON('@flag name', function(path, value, type) {})\n\nType: `event`\n\nS'exécute quand un path ou une méthode est utilisé avec le flag personnalisé `@name`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Object` | yes |  | La valeur. |\n| `type` | `Number` | yes |  | Le type de changement. |\n\nExample: Exemple\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.age 30\n});\nSET('user.age @saved', 30);\n```\n","entries":[{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"@name","signature":"ON('@name', function(component) {})","since":"","deprecated":false},{"type":"event","name":"#id","signature":"ON('#id', function(component) {})","since":"","deprecated":false},{"type":"event","name":"component.compile","signature":"ON('component.compile', function(name, declaration) {})","since":"","deprecated":false},{"type":"event","name":"component.destroy","signature":"ON('component.destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"destroy","signature":"ON('destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"lazy","signature":"ON('lazy', function(name, loading) {})","since":"","deprecated":false},{"type":"event","name":"binder","signature":"ON('binder', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"plugin.destroy","signature":"ON('plugin.destroy', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"cmd","signature":"ON('cmd', function(name, a, b, c, d, e) {})","since":"","deprecated":false},{"type":"event","name":"exec","signature":"ON('exec', function(path, a, b, c, d) {})","since":"","deprecated":false},{"type":"event","name":"setter","signature":"ON('setter', function(selector, method, a, b) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(output) {})","since":"","deprecated":false},{"type":"event","name":"error","signature":"ON('error', function(output) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","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":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false},{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path, value, type) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammZP8MM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/events/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Eventi","summary":"Gli eventi emessi dalla libreria.","markdown":"---\ntitle: Eventi\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/events/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Eventi\n\n> Gli eventi emessi dalla libreria.\n\nGestisci questi eventi con [ON()](../globals/#on) e rimuovi i gestori con [OFF()](../globals/#off). I tuoi eventi usano le stesse funzioni con [EMIT()](../globals/#emit).\n\n## API\n\n### ON('init', function() {})\n\nType: `event`\n\nViene eseguito una volta quando i primi componenti sono pronti, subito prima di `ready`.\n\nUna pagina senza componenti non emette questo evento.\n\nExample: Esempio\n```js\nON('init', function() {\n\tconsole.log('init'); // init\n});\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nViene eseguito una volta quando i primi componenti sono pronti.\n\nUn gestore registrato in seguito viene eseguito immediatamente. Una pagina senza componenti non emette questo evento.\n\nExample: Esempio\n```js\nON('ready', function() {\n\tconsole.log('ready'); // ready\n});\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nViene eseguito quando un componente è pronto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Il componente. |\n\nExample: Esempio\n```js\nON('component', function(com) {\n\tconsole.log(com.path); // data.box\n});\n```\n\n### ON('@name', function(component) {})\n\nType: `event`\n\nViene eseguito quando un componente con questo nome è pronto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Il componente. |\n\nExample: Esempio\n```js\nON('@box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### ON('#id', function(component) {})\n\nType: `event`\n\nViene eseguito quando un componente con questo identificatore è pronto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Il componente. |\n\nExample: Esempio\n```js\nON('#mybox', function(com) {\n\tconsole.log(com.id); // mybox\n});\n```\n\n### ON('component.compile', function(name, declaration) {})\n\nType: `event`\n\nViene eseguito quando viene dichiarato un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome. |\n| `declaration` | `Object` | yes |  | La dichiarazione. |\n\nExample: Esempio\n```js\nON('component.compile', function(name) {\n\tconsole.log(name); // hello\n});\nCOMPONENT('hello', NOOP);\n```\n\n### ON('component.destroy', function(name, component) {})\n\nType: `event`\n\nViene eseguito quando viene rimosso un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome. |\n| `component` | `Component` | yes |  | Il componente. |\n\nExample: Esempio\n```js\nON('component.destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('destroy', function(name, component) {})\n\nType: `event`\n\nViene eseguito quando viene rimosso un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome. |\n| `component` | `Component` | yes |  | Il componente. |\n\nExample: Esempio\n```js\nON('destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('lazy', function(name, loading) {})\n\nType: `event`\n\nViene eseguito quando un componente lazy inizia e finisce il caricamento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome. |\n| `loading` | `Boolean` | yes |  | `true` all'inizio, `false` alla fine. |\n\nExample: Esempio\n```js\nON('lazy', function(name, loading) {\n\tconsole.log(name, loading); // box true\n});\nsetTimeout(() => SETTER('box', 'hello', 'Peter'), 500);\n```\n\n### ON('binder', function(binder) {})\n\nType: `event`\n\nViene eseguito quando un'associazione dei dati è pronta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | L'associazione. |\n\nExample: Esempio\n```js\nON('binder', function(binder) {\n\tconsole.log(binder.path); // user.name\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 |  | Il plugin. |\n\nExample: Esempio\n```js\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\nPLUGIN('users', NOOP);\n```\n\n### ON('plugin.destroy', function(plugin) {})\n\nType: `event`\n\nViene eseguito quando viene rimosso un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | Il plugin. |\n\nExample: Esempio\n```js\nON('plugin.destroy', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n// Declaring a plugin again removes the previous one\nsetTimeout(() => PLUGIN('users', NOOP), 300);\nsetTimeout(() => PLUGIN('users', NOOP), 600);\n```\n\n### ON('cmd', function(name, a, b, c, d, e) {})\n\nType: `event`\n\nViene eseguito prima che un comando venga inviato ai componenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il comando. |\n| `a` | `Object` | yes |  | Fino a cinque argomenti. |\n\nExample: Esempio\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nCMD('refresh', 1);\n```\n\n### ON('exec', function(path, a, b, c, d) {})\n\nType: `event`\n\nViene eseguito prima che [EXEC()](../globals/#exec) chiami una funzione o un metodo di un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | La destinazione. |\n| `a` | `Object` | yes |  | Fino a quattro argomenti. |\n\nExample: Esempio\n```js\nON('exec', function(path, value) {\n\tconsole.log(path, value); // app.run 1\n});\nwindow.app = { run: NOOP };\nEXEC('app.run', 1);\n```\n\n### ON('setter', function(selector, method, a, b) {})\n\nType: `event`\n\nViene eseguito prima che [SETTER()](../globals/#setter) chiami i componenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore. |\n| `method` | `String` | yes |  | Il metodo. |\n| `a` | `Object` | yes |  | I primi due argomenti, `a` e `b`. |\n\nExample: Esempio\n```js\nON('setter', function(selector, method, value) {\n\tconsole.log(selector, method, value); // box hello 1\n});\nSETTER('box', 'hello', 1);\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nViene eseguito quando viene scritta una variabile d'ambiente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome. |\n| `value` | `Object` | yes |  | Il valore. |\n\nExample: Esempio\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // api /v1/\n});\nENV('api', '/v1/');\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nViene eseguito dopo l'importazione dei contenuti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. Per i contenuti HTML, inizia con `$import`. |\n| `target` | `jQuery` | yes |  | L'elemento di destinazione, oppure l'elemento `script` o `link` creato. |\n\nExample: Esempio\n```js\nON('import', function(url, target) {\n\tconsole.log(target.length); // 1\n});\nIMPORT('/part.html');\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nViene eseguito prima dell'invio di una richiesta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La richiesta: `url`, `method`, `headers`, `data`, `upload`, `scope` e altro. |\n\nImposta `options.cancel = true` per interrompere la richiesta. `options.respond(response, [headers])` risponde senza un server e `options.throw(response, [headers], code)` risponde con un errore.\n\nExample: Esempio\n```js\nON('request', function(options) {\n\tconsole.log(options.method, options.url); // GET /api/\n\toptions.respond({ ok: true });\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('response', function(output) {})\n\nType: `event`\n\nViene eseguito dopo l'arrivo di una risposta, prima della callback della richiesta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Il risultato: `url`, `method`, `status`, `response`, `raw`, `headers`, `error`, `duration` e altro. |\n\nImposta `output.process = false` per saltare la callback della richiesta.\n\nExample: Esempio\n```js\nON('response', function(output) {\n\tconsole.log(output.status, output.response.ok); // 200 true\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('error', function(output) {})\n\nType: `event`\n\nViene eseguito quando una richiesta non riesce.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Il risultato della richiesta. |\n\nL'evento non viene emesso quando `DEF.ajaxerrors` è `true`.\n\nExample: Esempio\n```js\nON('error', function(output) {\n\tconsole.log(output.status); // 500\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nViene eseguito quando [ERROR()](../globals/#error) trova un errore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | Il valore controllato. |\n\nExample: Esempio\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid\n});\nERROR([{ error: 'Invalid' }]);\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 esecuzioni. |\n\nExample: Esempio\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nViene eseguito ogni minuto, subito prima di `knockknock`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Il numero di esecuzioni. |\n\nExample: Esempio\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nViene eseguito dopo che la dimensione della finestra è cambiata.\n\nÈ ritardato di 300 millisecondi e viene eseguito anche una volta all'avvio della pagina.\n\nExample: Esempio\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nViene eseguito quando inizia lo scorrimento in una [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'elemento fatto scorrere. |\n\nExample: Esempio\n```js\nON('scroll', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nViene eseguito quando si ferma lo scorrimento in una [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'elemento fatto scorrere. |\n\nExample: Esempio\n```js\nON('scrollidle', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nViene eseguito quando la pagina passa in background o torna in primo piano.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` quando la pagina è visibile. |\n\nExample: Esempio\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n$(window).trigger('visibilitychange');\n```\n\n### ON('@flag name', function(path, value, type) {})\n\nType: `event`\n\nViene eseguito quando un path o un metodo viene usato con il flag personalizzato `@name`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Object` | yes |  | Il valore. |\n| `type` | `Number` | yes |  | Il tipo di modifica. |\n\nExample: Esempio\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.age 30\n});\nSET('user.age @saved', 30);\n```\n","entries":[{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"@name","signature":"ON('@name', function(component) {})","since":"","deprecated":false},{"type":"event","name":"#id","signature":"ON('#id', function(component) {})","since":"","deprecated":false},{"type":"event","name":"component.compile","signature":"ON('component.compile', function(name, declaration) {})","since":"","deprecated":false},{"type":"event","name":"component.destroy","signature":"ON('component.destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"destroy","signature":"ON('destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"lazy","signature":"ON('lazy', function(name, loading) {})","since":"","deprecated":false},{"type":"event","name":"binder","signature":"ON('binder', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"plugin.destroy","signature":"ON('plugin.destroy', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"cmd","signature":"ON('cmd', function(name, a, b, c, d, e) {})","since":"","deprecated":false},{"type":"event","name":"exec","signature":"ON('exec', function(path, a, b, c, d) {})","since":"","deprecated":false},{"type":"event","name":"setter","signature":"ON('setter', function(selector, method, a, b) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(output) {})","since":"","deprecated":false},{"type":"event","name":"error","signature":"ON('error', function(output) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","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":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false},{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path, value, type) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"JammZP8MM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/events/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Udalosti","summary":"Udalosti, ktoré knižnica vysiela.","markdown":"---\ntitle: Udalosti\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/events/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# Udalosti\n\n> Udalosti, ktoré knižnica vysiela.\n\nTieto udalosti spracuj pomocou [ON()](../globals/#on) a obslužné funkcie odstráň pomocou [OFF()](../globals/#off). Tvoje vlastné udalosti používajú tie isté funkcie spolu s [EMIT()](../globals/#emit).\n\n## API\n\n### ON('init', function() {})\n\nType: `event`\n\nSpustí sa raz, keď sú pripravené prvé komponenty, tesne pred `ready`.\n\nStránka bez komponentov túto udalosť nevyšle.\n\nExample: Príklad\n```js\nON('init', function() {\n\tconsole.log('init'); // init\n});\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nSpustí sa raz, keď sú pripravené prvé komponenty.\n\nObslužná funkcia zaregistrovaná neskôr sa spustí okamžite. Stránka bez komponentov túto udalosť nevyšle.\n\nExample: Príklad\n```js\nON('ready', function() {\n\tconsole.log('ready'); // ready\n});\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nSpustí sa, keď je komponent pripravený.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Komponent. |\n\nExample: Príklad\n```js\nON('component', function(com) {\n\tconsole.log(com.path); // data.box\n});\n```\n\n### ON('@name', function(component) {})\n\nType: `event`\n\nSpustí sa, keď je pripravený komponent s týmto názvom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Komponent. |\n\nExample: Príklad\n```js\nON('@box', function(com) {\n\tconsole.log(com.name); // box\n});\n```\n\n### ON('#id', function(component) {})\n\nType: `event`\n\nSpustí sa, keď je pripravený komponent s týmto identifikátorom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Komponent. |\n\nExample: Príklad\n```js\nON('#mybox', function(com) {\n\tconsole.log(com.id); // mybox\n});\n```\n\n### ON('component.compile', function(name, declaration) {})\n\nType: `event`\n\nSpustí sa, keď je komponent deklarovaný.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov. |\n| `declaration` | `Object` | yes |  | Deklarácia. |\n\nExample: Príklad\n```js\nON('component.compile', function(name) {\n\tconsole.log(name); // hello\n});\nCOMPONENT('hello', NOOP);\n```\n\n### ON('component.destroy', function(name, component) {})\n\nType: `event`\n\nSpustí sa, keď sa komponent odstráni.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov. |\n| `component` | `Component` | yes |  | Komponent. |\n\nExample: Príklad\n```js\nON('component.destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('destroy', function(name, component) {})\n\nType: `event`\n\nSpustí sa, keď sa komponent odstráni.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov. |\n| `component` | `Component` | yes |  | Komponent. |\n\nExample: Príklad\n```js\nON('destroy', function(name) {\n\tconsole.log(name); // box\n});\nON('ready', function() {\n\tFIND('box').remove();\n});\n```\n\n### ON('lazy', function(name, loading) {})\n\nType: `event`\n\nSpustí sa, keď komponent s odloženým načítaním začne a dokončí načítavanie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov. |\n| `loading` | `Boolean` | yes |  | `true` na začiatku, `false` na konci. |\n\nExample: Príklad\n```js\nON('lazy', function(name, loading) {\n\tconsole.log(name, loading); // box true\n});\nsetTimeout(() => SETTER('box', 'hello', 'Peter'), 500);\n```\n\n### ON('binder', function(binder) {})\n\nType: `event`\n\nSpustí sa, keď je dátová väzba pripravená.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | Väzba. |\n\nExample: Príklad\n```js\nON('binder', function(binder) {\n\tconsole.log(binder.path); // user.name\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 |  | Plugin. |\n\nExample: Príklad\n```js\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\nPLUGIN('users', NOOP);\n```\n\n### ON('plugin.destroy', function(plugin) {})\n\nType: `event`\n\nSpustí sa, keď sa plugin odstráni.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | Plugin. |\n\nExample: Príklad\n```js\nON('plugin.destroy', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n// Declaring a plugin again removes the previous one\nsetTimeout(() => PLUGIN('users', NOOP), 300);\nsetTimeout(() => PLUGIN('users', NOOP), 600);\n```\n\n### ON('cmd', function(name, a, b, c, d, e) {})\n\nType: `event`\n\nSpustí sa pred odoslaním príkazu komponentom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Príkaz. |\n| `a` | `Object` | yes |  | Až päť argumentov. |\n\nExample: Príklad\n```js\nON('cmd', function(name, value) {\n\tconsole.log(name, value); // refresh 1\n});\nCMD('refresh', 1);\n```\n\n### ON('exec', function(path, a, b, c, d) {})\n\nType: `event`\n\nSpustí sa predtým, ako [EXEC()](../globals/#exec) zavolá funkciu alebo metódu pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Cieľ. |\n| `a` | `Object` | yes |  | Až štyri argumenty. |\n\nExample: Príklad\n```js\nON('exec', function(path, value) {\n\tconsole.log(path, value); // app.run 1\n});\nwindow.app = { run: NOOP };\nEXEC('app.run', 1);\n```\n\n### ON('setter', function(selector, method, a, b) {})\n\nType: `event`\n\nSpustí sa predtým, ako [SETTER()](../globals/#setter) zavolá komponenty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor. |\n| `method` | `String` | yes |  | Metóda. |\n| `a` | `Object` | yes |  | Prvé dva argumenty, `a` a `b`. |\n\nExample: Príklad\n```js\nON('setter', function(selector, method, value) {\n\tconsole.log(selector, method, value); // box hello 1\n});\nSETTER('box', 'hello', 1);\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nSpustí sa pri zápise premennej prostredia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov. |\n| `value` | `Object` | yes |  | Hodnota. |\n\nExample: Príklad\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // api /v1/\n});\nENV('api', '/v1/');\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nSpustí sa po importe obsahu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL. Pri obsahu HTML začína na `$import`. |\n| `target` | `jQuery` | yes |  | Cieľový element alebo vytvorený element `script` či `link`. |\n\nExample: Príklad\n```js\nON('import', function(url, target) {\n\tconsole.log(target.length); // 1\n});\nIMPORT('/part.html');\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nSpustí sa pred odoslaním požiadavky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Požiadavka: `url`, `method`, `headers`, `data`, `upload`, `scope` a ďalšie. |\n\nNastav `options.cancel = true`, ak chceš požiadavku zastaviť. `options.respond(response, [headers])` na ňu odpovie bez servera a `options.throw(response, [headers], code)` na ňu odpovie chybou.\n\nExample: Príklad\n```js\nON('request', function(options) {\n\tconsole.log(options.method, options.url); // GET /api/\n\toptions.respond({ ok: true });\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('response', function(output) {})\n\nType: `event`\n\nSpustí sa po prijatí odpovede, pred callbackom požiadavky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Výsledok: `url`, `method`, `status`, `response`, `raw`, `headers`, `error`, `duration` a ďalšie. |\n\nNastav `output.process = false`, ak chceš callback požiadavky preskočiť.\n\nExample: Príklad\n```js\nON('response', function(output) {\n\tconsole.log(output.status, output.response.ok); // 200 true\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('error', function(output) {})\n\nType: `event`\n\nSpustí sa, keď požiadavka zlyhá.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `output` | `Object` | yes |  | Výsledok požiadavky. |\n\nUdalosť sa nevyšle, keď má `DEF.ajaxerrors` hodnotu `true`.\n\nExample: Príklad\n```js\nON('error', function(output) {\n\tconsole.log(output.status); // 500\n});\nAJAX('GET /api/', NOOP);\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nSpustí sa, keď [ERROR()](../globals/#error) nájde chybu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | Kontrolovaná hodnota. |\n\nExample: Príklad\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid\n});\nERROR([{ error: 'Invalid' }]);\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 spustení. |\n\nExample: Príklad\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nSpúšťa sa každú minútu, tesne pred `knockknock`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Počet spustení. |\n\nExample: Príklad\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nSpustí sa po zmene veľkosti okna.\n\nJe oneskorená o 300 milisekúnd a spustí sa aj raz pri štarte stránky.\n\nExample: Príklad\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nSpustí sa, keď sa začne posúvanie v [SCROLLBAR()](../globals/#scrollbar).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Posúvaný element. |\n\nExample: Príklad\n```js\nON('scroll', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nSpustí sa, keď sa posúvanie v [SCROLLBAR()](../globals/#scrollbar) zastaví.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Posúvaný element. |\n\nExample: Príklad\n```js\nON('scrollidle', function(area) {\n\tconsole.log(area.length); // 1\n});\nvar scrollbar = SCROLLBAR($('#box'), { native: true });\nscrollbar.area.trigger('scroll');\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nSpustí sa, keď stránka prejde na pozadie 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: Príklad\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n$(window).trigger('visibilitychange');\n```\n\n### ON('@flag name', function(path, value, type) {})\n\nType: `event`\n\nSpustí sa, keď sa path alebo metóda použije s vlastným flagom `@name`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `type` | `Number` | yes |  | Typ zmeny. |\n\nExample: Príklad\n```js\nON('@flag saved', function(path, value) {\n\tconsole.log(path, value); // user.age 30\n});\nSET('user.age @saved', 30);\n```\n","entries":[{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"@name","signature":"ON('@name', function(component) {})","since":"","deprecated":false},{"type":"event","name":"#id","signature":"ON('#id', function(component) {})","since":"","deprecated":false},{"type":"event","name":"component.compile","signature":"ON('component.compile', function(name, declaration) {})","since":"","deprecated":false},{"type":"event","name":"component.destroy","signature":"ON('component.destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"destroy","signature":"ON('destroy', function(name, component) {})","since":"","deprecated":false},{"type":"event","name":"lazy","signature":"ON('lazy', function(name, loading) {})","since":"","deprecated":false},{"type":"event","name":"binder","signature":"ON('binder', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"plugin.destroy","signature":"ON('plugin.destroy', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"cmd","signature":"ON('cmd', function(name, a, b, c, d, e) {})","since":"","deprecated":false},{"type":"event","name":"exec","signature":"ON('exec', function(path, a, b, c, d) {})","since":"","deprecated":false},{"type":"event","name":"setter","signature":"ON('setter', function(selector, method, a, b) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(output) {})","since":"","deprecated":false},{"type":"event","name":"error","signature":"ON('error', function(output) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","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":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false},{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path, value, type) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammk9C2j61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-bind/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"ui-bind","summary":"The attributes and commands of the ui-bind element, and the binder object it creates.","markdown":"---\ntitle: ui-bind\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-bind/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# ui-bind\n\n> The attributes and commands of the ui-bind element, and the binder object it creates.\n\nThe `<ui-bind>` element watches a path and updates the DOM when the value changes. Its `config` attribute holds a list of commands. [Data binding](../../guides/data-binding/) explains the concept.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nSets the path that the element watches.\n\nThe attribute accepts these forms:\n\n| Value | Meaning |\n| --- | --- |\n| `form.name` | An absolute path. |\n| `!form.name` | The commands are skipped while the value is `null` or `undefined`. |\n| `?.name` | A path relative to the closest [`ui-plugin`](../ui-plugin/). |\n| `*name` | A path inside `DEF.pathcommon`. |\n| `%name` | A temporary path. |\n| `@key` | A value stored with [`data()`](../component/#data) of the parent component. `@` alone is the value of that component and `@config.key` is a configuration key. |\n| `.name` | A path inside the model of a [virtual binder](../vbinder/). `.` alone is the whole model. |\n| `form.name --> expression` | Transforms the value with an expression that receives `value`. |\n\nWhen the element has a path and no `config`, the path must contain a function, which is called with the element.\n\nExample: Skipping empty values\n```html\n<ui-bind path=\"!form.name\" config=\"text\">Waiting</ui-bind>\n```\n\nExample: Transforming the value\n```html\n<ui-bind path=\"form.name --> value.toUpperCase()\" config=\"text\"></ui-bind>\n<script>SET('form.name', 'peter');</script>\n```\n\nExample: Reading data of the parent component\n```html\n<ui-component name=\"card\" config=\"title:Orders\">\n    <ui-bind path=\"@config.title\" config=\"text\"></ui-bind>\n</ui-component>\n<script>COMPONENT('card', function(self) {});</script>\n```\n\nExample: Calling a function with the element\n```html\n<ui-bind path=\"common.init\" id=\"box\"></ui-bind>\n<script>\n    window.common = { init: element => console.log(element.attr('id')) };  // box\n</script>\n```\n\n### config=\"command:expression;command:expression\"\n\nType: `property`\n\nHolds the commands of the element.\n\nCommands are separated by a semicolon. Each command has the form `name:expression`. See [Command syntax](#command-syntax).\n\nExample: Two commands\n```html\n<ui-bind path=\"form.age\" config=\"text:value + ' years';.adult:value >= 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### element=\"selector\"\n\nType: `property`\n\nApplies the commands to another element.\n\nThe value is a jQuery selector evaluated in the whole document.\n\nExample: Updating an element elsewhere\n```html\n<ui-bind path=\"form.name\" element=\"#target\" config=\"text\"></ui-bind>\n<div id=\"target\"></div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nApplies the commands to the closest matching parent.\n\nThe value is a jQuery selector passed to `closest()`.\n\nExample: Updating a parent element\n```html\n<div class=\"row\">\n    <ui-bind path=\"form.name\" parent=\".row\" config=\"title:value\"></ui-bind>\n</div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nApplies the commands to the first matching descendant.\n\nThe attribute can be combined with [`parent`](#parent).\n\nExample: Updating a child element\n```html\n<ui-bind path=\"form.name\" child=\"b\" config=\"text\">\n    <b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCreates a scope directly on the element.\n\nThe value is the path of the scope.\n\nExample: A scope on the element\n```html\n<ui-bind plugin=\"users\" path=\"?.name\" config=\"text\"></ui-bind>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.set('name', 'Peter');\n    });\n</script>\n```\n\n### [!~]command [selector]:expression\n\nType: `type`\n\nA command is a name followed by an optional expression.\n\nThe expression can have these forms:\n\n| Form | Meaning |\n| --- | --- |\n| omitted | The value itself, as in `text`. |\n| `value + 1` | A JavaScript expression that contains the word `value`. The variables `value`, `path` and `el` are available. |\n| `value => value + 1` | An arrow function. |\n| `common.format` | The path of a function called with `value`, `path` and `el`. |\n| `?/format` | A method of the plugin of the closest scope. |\n\nThe prefixes and separators are:\n\n| Syntax | Meaning |\n| --- | --- |\n| `command selector:expression` | Runs the command on the descendants that match the selector. |\n| `text+title:value` | Runs one expression for several commands. |\n| `!command` | Skips the command while the value is `null` or `undefined`. On the element itself, `text`, `html`, `title`, `value`, `src`, `checked`, `disabled` and `enabled` then return to their original content. |\n| `~command` | Runs the command also while the element is hidden by `show`, `hide`, `visible` or `invisible`. |\n\nExample: Expression forms\n```html\n<ui-bind path=\"form.name\" config=\"text b:value.length;title:n => n + '!';.long:common.long\">\n    <b></b>\n</ui-bind>\n<script>\n    window.common = { long: value => value.length > 3 };\n    SET('form.name', 'Peter');\n</script>\n```\n\nExample: One expression for two commands\n```html\n<ui-bind path=\"form.name\" config=\"text+title:value\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\nExample: Restoring the original content\n```html\n<ui-bind path=\"form.name\" config=\"!text\">Anonymous</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', null), 500);\n</script>\n```\n\nExample: Updating a hidden element\n```html\n<ui-bind path=\"form.name\" config=\"~text;hide:value\">Anonymous</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### text[:expression]\n\nType: `command`\n\nSets the text content.\n\nThe value is escaped. The [`format`](#format), [`currency`](#currency), [`helper`](#helper) and [`empty`](#empty) commands change the output.\n\nExample: Using text\n```html\n<ui-bind path=\"form.name\" config=\"text\"></ui-bind>\n<script>SET('form.name', '<b>Peter</b>');</script>\n```\n\n### html[:expression]\n\nType: `command`\n\nSets the HTML content.\n\nThe value is not escaped.\n\nExample: Using html\n```html\n<ui-bind path=\"form.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### value[:expression]\n\nType: `command`\n\nSets the value of a form field.\n\nThe short name `val` works too.\n\nExample: Using value\n```html\n<ui-bind path=\"form.name\" config=\"value input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('input').val()), 500);  // Peter\n</script>\n```\n\n### title[:expression]\n\nType: `command`\n\nSets the `title` attribute.\n\nExample: Using title\n```html\n<ui-bind path=\"form.name\" config=\"title\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### href[:expression]\n\nType: `command`\n\nSets the `href` attribute.\n\nExample: Using href\n```html\n<ui-bind path=\"form.id\" config=\"href a:'/users/' + value + '/'\">\n    <a>Detail</a>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### src[:expression]\n\nType: `command`\n\nSets the `src` attribute.\n\nExample: Using src\n```html\n<ui-bind path=\"form.photo\" config=\"src img\">\n    <img />\n</ui-bind>\n<script>SET('form.photo', 'data:,');</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nSets any attribute.\n\nThe name of the attribute follows the command. A selector can follow the name.\n\nExample: Using attr\n```html\n<ui-bind path=\"form.id\" config=\"attr data-id:value;attr data-ref b:value\">\n    <b></b>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### .classname[ selector]:expression\n\nType: `command`\n\nToggles a CSS class by the result of the expression.\n\nWrite the name of the class after the dot.\n\nExample: Toggling classes\n```html\n<ui-bind path=\"form.age\" config=\".adult:value >= 18;.minor:value < 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### class:classes\n\nType: `command`\n\nToggles CSS classes once, after the first update.\n\nSeparate several classes with a space.\n\nExample: Using class\n```html\n<ui-bind path=\"form.name\" config=\"class:ready\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### show[:expression]\n\nType: `command`\n\nShows the element when the expression is truthy.\n\nOtherwise the element receives the `hidden` class. While hidden, the commands that follow are skipped unless they have the `~` prefix.\n\nExample: Using show\n```html\n<ui-bind path=\"form.age\" config=\"show:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### hide[:expression]\n\nType: `command`\n\nHides the element when the expression is truthy.\n\nThe element receives the `hidden` class. The name `hidden` works too.\n\nExample: Using hide\n```html\n<ui-bind path=\"form.age\" config=\"hide:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### visible[:expression]\n\nType: `command`\n\nKeeps the layout space when the expression is falsy.\n\nThe element receives the `invisible` class when the expression is falsy.\n\nExample: Using visible\n```html\n<ui-bind path=\"form.age\" config=\"visible:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### invisible[:expression]\n\nType: `command`\n\nAdds the `invisible` class when the expression is truthy.\n\nExample: Using invisible\n```html\n<ui-bind path=\"form.age\" config=\"invisible:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### checked[:expression]\n\nType: `command`\n\nSets the `checked` property of a field.\n\nExample: Using checked\n```html\n<ui-bind path=\"form.active\" config=\"checked input\">\n    <input type=\"checkbox\" />\n</ui-bind>\n<script>\n    SET('form.active', true);\n    setTimeout(() => console.log($('input').prop('checked')), 500);  // true\n</script>\n```\n\n### disabled[:expression]\n\nType: `command`\n\nDisables fields and components when the expression is truthy.\n\nThe short name `disable` works too. Without a selector, the command applies to `ui-component`, `input`, `textarea`, `select` and `button` inside the element. Components receive the `disabled` configuration key.\n\nExample: Using disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.locked', true);</script>\n```\n\n### enabled[:expression]\n\nType: `command`\n\nEnables fields and components when the expression is truthy.\n\nThe short name `enable` works too. The default selector is the same as for [`disabled`](#disabled).\n\nExample: Using enabled\n```html\n<ui-bind path=\"form.valid\" config=\"enabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.valid', false);</script>\n```\n\n### required selector:expression\n\nType: `command`\n\nSets the `required` configuration key of a component.\n\nAdd a selector, because the command has no default one.\n\nExample: Using required\n```html\n<ui-bind path=\"form.strict\" config=\"required ui-component:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'required' && console.log(value);  // true\n    });\n    SET('form.strict', true);\n</script>\n```\n\n### config:expression\n\nType: `command`\n\nReconfigures components with the result of the expression.\n\nThe default selector is `ui-component`.\n\nExample: Using config\n```html\n<ui-bind path=\"form.title\" config=\"config:'title:' + value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'title' && console.log(value);  // Orders\n    });\n    SET('form.title', 'Orders');\n</script>\n```\n\n### set[:expression]\n\nType: `command`\n\nPasses the result of the expression to the `setter` of a component without a path.\n\nThe default selector is `ui-component`. The component can write back to the same path.\n\nExample: Using set\n```html\n<ui-bind path=\"form.name\" config=\"set:value + '!'\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = value => self.text(value);\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### setter:'selector/method',value\n\nType: `command`\n\nCalls a method of matching components.\n\nThe expression holds the arguments of `SETTER()`, evaluated with `value`, `path` and `el`.\n\nExample: Using setter\n```html\n<ui-bind path=\"form.name\" config=\"setter:'box/show',value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.show = value => value && console.log(value);  // Peter\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### template [selector][:selector-->attribute]\n\nType: `command`\n\nRenders a Tangular template.\n\nThe template is the first `<script>` or `<template>` inside the element. The model has the properties `value` and `path`.\n\nThe optional `template:selector-->attribute` form updates only the changed child elements. The selector finds the items and the attribute identifies them. Read more in [Templates with Tangular](../../guides/tangular/).\n\nExample: Using template\n```html\n<ui-bind path=\"form.items\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<li>{{ m }}</li>{{ end }}\n    </script>\n</ui-bind>\n<script>SET('form.items', ['A', 'B']);</script>\n```\n\n### helpers:path\n\nType: `command`\n\nPasses Tangular helpers to the template.\n\nThe value is a path to an object with helpers, or to a function that returns one.\n\nExample: Using helpers\n```html\n<ui-bind path=\"form.name\" config=\"template;helpers:common.helpers\">\n    <script type=\"text/html\">{{ value | shout }}</script>\n</ui-bind>\n<script>\n    window.common = { helpers: { shout: value => value + '!' } };\n    SET('form.name', 'Peter');\n</script>\n```\n\n### vbindarray\n\nType: `command`\n\nRenders an array with a virtual binder per item.\n\nThe template is the first `<script>` or `<template>` inside the element. Paths inside the template start with a dot. See [Virtual binder](../vbinder/).\n\nExample: Using vbindarray\n```html\n<ui-bind path=\"form.users\" config=\"vbindarray\">\n    <script type=\"text/html\">\n        <div><ui-bind path=\".name\" config=\"text\"></ui-bind></div>\n    </script>\n</ui-bind>\n<script>SET('form.users', [{ name: 'Peter' }, { name: 'Anna' }]);</script>\n```\n\n### import:url\n\nType: `command`\n\nLoads content into the element.\n\nThe value is one of these:\n\n| Value | Meaning |\n| --- | --- |\n| A URL that starts with `/`, `http://` or `https://` | Imports the URL once. |\n| `value` or `true` | Moves the first inner `<script>` or `<template>` into the DOM. |\n| An expression | Imports the URL returned by the path value, once per URL. |\n\nThe import waits until the element is visible, so it can be combined with [`show`](#show).\n\nExample: Inserting a template when the element is shown\n```html\n<ui-bind path=\"form.open\" config=\"show;import:value\">\n    <script type=\"text/html\"><b>Loaded</b></script>\n</ui-bind>\n<script>\n    setTimeout(() => SET('form.open', true), 500);\n</script>\n```\n\n### macro:name1,name2\n\nType: `command`\n\nAttaches macros to the element.\n\nSeparate several names with a comma. See [Macro](../macro/).\n\nExample: Using macro\n```html\n<ui-bind path=\"form.name\" config=\"macro:shout\"></ui-bind>\n<script>\n    MACRO('shout', function(self) {\n        self.setter = value => self.text(value + '!');\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nCalls a function on each update.\n\nThe function receives `value`, `path` and `el`, and `this` is the element. It always receives the raw value. The name `change` works too.\n\nExample: Using exec\n```html\n<ui-bind path=\"form.name\" config=\"exec:common.onchange\"></ui-bind>\n<script>\n    window.common = { onchange: (value, path) => value && console.log(value, path) };  // Peter form.name\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### init:path\n\nType: `command`\n\nCalls a function at the beginning of each update.\n\nThe function receives `value`, `path` and `el`.\n\nExample: Using init\n```html\n<ui-bind path=\"form.name\" config=\"init:common.oninit\"></ui-bind>\n<script>\n    window.common = { oninit: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nCalls a function on each update while the element is visible.\n\nThe function receives `value`, `path` and `el`.\n\nExample: Using refresh\n```html\n<ui-bind path=\"form.name\" config=\"refresh:common.onrefresh\"></ui-bind>\n<script>\n    window.common = { onrefresh: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### click [selector]:path\n\nType: `command`\n\nCalls a function when the element is clicked.\n\nThe function receives the jQuery element, the event, the current value and the path. A selector delegates the click to the matching descendants. Disabled inputs and buttons are ignored.\n\nExample: Using click\n```html\n<ui-bind path=\"form.name\" config=\"click button:common.onclick\">\n    <button>Save</button>\n</ui-bind>\n<script>\n    window.common = {\n        onclick: (element, event, value, path) => console.log(element.text(), value, path)  // Save Peter form.name\n    };\n    SET('form.name', 'Peter');\n    setTimeout(() => $('button').click(), 500);\n</script>\n```\n\n### format:format\n\nType: `command`\n\nFormats a number or a date.\n\nA number sets the decimal places. Any other text is a date format.\n\nExample: Using format\n```html\n<ui-bind path=\"form.price\" config=\"text;format:2\"></ui-bind>\n<script>SET('form.price', 1250);</script>\n```\n\n### currency:name\n\nType: `command`\n\nFormats a number with a currency.\n\nThe name refers to a function in `DEF.currencies`.\n\nExample: Using currency\n```html\n<ui-bind path=\"form.price\" config=\"text;currency:eur\"></ui-bind>\n<script>\n    DEF.currencies.eur = value => value.format(2) + ' EUR';\n    SET('form.price', 1250);\n</script>\n```\n\n### helper:name[(arguments)]\n\nType: `command`\n\nTransforms the output with a Tangular helper.\n\nThe value is passed as the first argument of the helper. Other arguments can be written in parentheses.\n\nExample: Using helper\n```html\n<ui-bind path=\"form.name\" config=\"text;helper:wrap('*')\"></ui-bind>\n<script>\n    Thelpers.wrap = (value, chars) => chars + value + chars;\n    SET('form.name', 'Peter');\n</script>\n```\n\n### empty[:text]\n\nType: `command`\n\nSets the text used for an empty value.\n\nWithout a value, the command uses `DEF.empty`, which is `---`.\n\nExample: Using empty\n```html\n<ui-bind path=\"form.name\" config=\"text;empty:Nothing\"></ui-bind>\n```\n\n### default:expression\n\nType: `command`\n\nReplaces `null` and `undefined` with a value.\n\nThe value is a JavaScript expression. The short name `def` works too.\n\nExample: Using default\n```html\n<ui-bind path=\"form.name\" config=\"text;default:'Anonymous'\"></ui-bind>\n```\n\n### selector:selector\n\nType: `command`\n\nApplies all commands to the matching descendants.\n\nExample: Using selector\n```html\n<ui-bind path=\"form.name\" config=\"selector:b;text\">\n    <b></b><b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### assign:path\n\nType: `command`\n\nWrites the jQuery element to a path.\n\nExample: Using assign\n```html\n<ui-bind id=\"box\" path=\"form.name\" config=\"assign:common.box;text\"></ui-bind>\n<script>\n    setTimeout(() => console.log(GET('common.box').attr('id')), 500);  // box\n</script>\n```\n\n### check:path\n\nType: `command`\n\nRuns the commands only when a condition passes.\n\nThe value is a path to a truthy value, or `plugin/method`, which receives `value`, `path` and `el`.\n\nExample: Using check\n```html\n<ui-bind path=\"form.name\" config=\"check:form.ready;text\">Waiting</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nDelays the update in milliseconds.\n\nRepeated updates within the delay run once.\n\nExample: Using delay\n```html\n<ui-bind path=\"form.name\" config=\"delay:500;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('ui-bind').text() || 'empty'), 200);  // empty\n    setTimeout(() => console.log($('ui-bind').text()), 1100);  // Peter\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnores changes of nested paths.\n\nThe commands run only when the path itself or one of its parents changes.\n\nExample: Using strict\n```html\n<ui-bind path=\"form.user\" config=\"strict;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter' });\n    setTimeout(() => SET('form.user.name', 'Anna'), 500);\n</script>\n```\n\n### track:field1,field2\n\nType: `command`\n\nRuns the commands only for selected nested fields.\n\nSeparate several fields with a comma.\n\nExample: Using track\n```html\n<ui-bind path=\"form.user\" config=\"track:name;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter', age: 20 });\n    setTimeout(() => SET('form.user.age', 21), 500);\n    setTimeout(() => SET('form.user.name', 'Anna'), 700);\n</script>\n```\n\n### tracktype:type1,type2\n\nType: `command`\n\nRuns the commands only for selected update types.\n\nSeparate several types with a comma.\n\nExample: Using tracktype\n```html\n<ui-bind path=\"form.age\" config=\"tracktype:2;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10, 1), 500);\n    setTimeout(() => SET('form.age', 20, 2), 700);\n</script>\n```\n\n### changes\n\nType: `command`\n\nSkips the commands when the value has not changed.\n\nThe value is compared with a hash.\n\nExample: Using changes\n```html\n<ui-bind path=\"form.age\" config=\"changes;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10), 500);\n    setTimeout(() => UPD('form.age'), 700);\n</script>\n```\n\n### ready\n\nType: `command`\n\nWaits for the components nested in the element.\n\nThe commands run when all nested components are ready.\n\nExample: Using ready\n```html\n<ui-bind path=\"form.name\" config=\"ready;exec:common.update\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    window.common = { update: () => console.log(FIND('box') ? 'found' : 'missing') };  // found\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### once\n\nType: `command`\n\nRuns the commands only one time.\n\nExample: Using once\n```html\n<ui-bind path=\"form.name\" config=\"once;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', 'Anna'), 700);\n</script>\n```\n\n### focus:selector\n\nType: `command`\n\nMoves the focus to a field after each update.\n\nThe value is a selector of descendants.\n\nExample: Focusing a field\n```html\n<ui-bind path=\"form.name\" config=\"focus:input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n</script>\n```\n\n### resize\n\nType: `command`\n\nCalls the `resize` method of nested components after each update.\n\nExample: Using resize\n```html\n<ui-bind path=\"form.name\" config=\"resize\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.resize = () => console.log('resized');  // resized\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### binder.refresh()\n\nType: `method`\n\nRuns the commands again with the current value of the path.\n\nThe binder is available as `element.ui` or through `$(element).binder()`.\n\nExample: Refreshing a binder\n```js\nvar binder = $('ui-bind').binder();\nwindow.form.name = 'Anna';\nbinder.refresh();\nconsole.log($('ui-bind').text());  // Anna\n```\n\n### binder.exec(value, path)\n\nType: `method`\n\nRuns the commands with a custom value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value passed to the commands. |\n| `path` | `String` | yes |  | The path passed to the commands. |\n\nThe value is not written to the data model.\n\nExample: Running the commands with a value\n```js\nvar binder = $('ui-bind').binder();\nbinder.exec('Preview', 'form.name');\nconsole.log($('ui-bind').text(), GET('form.name'));  // Preview Peter\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"command:expression;command:expression\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"type","name":"Command syntax","signature":"[!~]command [selector]: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[: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":".class","signature":".classname[ selector]:expression","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:classes","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":"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 selector:expression","since":"","deprecated":false},{"type":"command","name":"config","signature":"config:expression","since":"","deprecated":false},{"type":"command","name":"set","signature":"set[:expression]","since":"","deprecated":false},{"type":"command","name":"setter","signature":"setter:'selector/method',value","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":"vbindarray","signature":"vbindarray","since":"","deprecated":false},{"type":"command","name":"import","signature":"import:url","since":"","deprecated":false},{"type":"command","name":"macro","signature":"macro:name1,name2","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"click","signature":"click [selector]:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:format","since":"","deprecated":false},{"type":"command","name":"currency","signature":"currency:name","since":"","deprecated":false},{"type":"command","name":"helper","signature":"helper:name[(arguments)]","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty[:text]","since":"","deprecated":false},{"type":"command","name":"default","signature":"default:expression","since":"","deprecated":false},{"type":"command","name":"selector","signature":"selector:selector","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:field1,field2","since":"","deprecated":false},{"type":"command","name":"tracktype","signature":"tracktype:type1,type2","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"resize","signature":"resize","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"binder.refresh()","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"binder.exec(value, path)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammk9C2j61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-bind/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"ui-bind","summary":"Die Attribute und Befehle des Elements ui-bind und das Binder-Objekt, das es erstellt.","markdown":"---\ntitle: ui-bind\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-bind/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# ui-bind\n\n> Die Attribute und Befehle des Elements ui-bind und das Binder-Objekt, das es erstellt.\n\nDas Element `<ui-bind>` überwacht einen Path und aktualisiert das DOM, wenn sich der Wert ändert. Sein Attribut `config` enthält eine Liste von Befehlen. Das Konzept erklärt [Datenbindung](../../guides/data-binding/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nLegt den Path fest, den das Element überwacht.\n\nDas Attribut akzeptiert diese Formen:\n\n| Wert | Bedeutung |\n| --- | --- |\n| `form.name` | Ein absoluter Path. |\n| `!form.name` | Die Befehle werden übersprungen, solange der Wert `null` oder `undefined` ist. |\n| `?.name` | Ein Path relativ zum nächstgelegenen [`ui-plugin`](../ui-plugin/). |\n| `*name` | Ein Path innerhalb von `DEF.pathcommon`. |\n| `%name` | Ein temporärer Path. |\n| `@key` | Ein Wert, der mit [`data()`](../component/#data) der übergeordneten Komponente gespeichert wurde. `@` allein ist der Wert dieser Komponente und `@config.key` ist ein Konfigurationsschlüssel. |\n| `.name` | Ein Path innerhalb des Modells eines [virtuellen Binders](../vbinder/). `.` allein ist das gesamte Modell. |\n| `form.name --> expression` | Wandelt den Wert mit einem Ausdruck um, der `value` erhält. |\n\nHat das Element einen Path, aber kein `config`, muss der Path eine Funktion enthalten, die mit dem Element aufgerufen wird.\n\nExample: Leere Werte überspringen\n```html\n<ui-bind path=\"!form.name\" config=\"text\">Waiting</ui-bind>\n```\n\nExample: Den Wert umwandeln\n```html\n<ui-bind path=\"form.name --> value.toUpperCase()\" config=\"text\"></ui-bind>\n<script>SET('form.name', 'peter');</script>\n```\n\nExample: Daten der übergeordneten Komponente lesen\n```html\n<ui-component name=\"card\" config=\"title:Orders\">\n    <ui-bind path=\"@config.title\" config=\"text\"></ui-bind>\n</ui-component>\n<script>COMPONENT('card', function(self) {});</script>\n```\n\nExample: Eine Funktion mit dem Element aufrufen\n```html\n<ui-bind path=\"common.init\" id=\"box\"></ui-bind>\n<script>\n    window.common = { init: element => console.log(element.attr('id')) };  // box\n</script>\n```\n\n### config=\"command:expression;command:expression\"\n\nType: `property`\n\nEnthält die Befehle des Elements.\n\nBefehle werden durch ein Semikolon getrennt. Jeder Befehl hat die Form `name:expression`. Siehe [Befehlssyntax](#command-syntax).\n\nExample: Zwei Befehle\n```html\n<ui-bind path=\"form.age\" config=\"text:value + ' years';.adult:value >= 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### element=\"selector\"\n\nType: `property`\n\nWendet die Befehle auf ein anderes Element an.\n\nDer Wert ist ein jQuery-Selektor, der im gesamten Dokument ausgewertet wird.\n\nExample: Ein Element an anderer Stelle aktualisieren\n```html\n<ui-bind path=\"form.name\" element=\"#target\" config=\"text\"></ui-bind>\n<div id=\"target\"></div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nWendet die Befehle auf das nächstgelegene passende Elternelement an.\n\nDer Wert ist ein jQuery-Selektor, der an `closest()` übergeben wird.\n\nExample: Ein Elternelement aktualisieren\n```html\n<div class=\"row\">\n    <ui-bind path=\"form.name\" parent=\".row\" config=\"title:value\"></ui-bind>\n</div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nWendet die Befehle auf den ersten passenden Nachfahren an.\n\nDas Attribut lässt sich mit [`parent`](#parent) kombinieren.\n\nExample: Ein Kindelement aktualisieren\n```html\n<ui-bind path=\"form.name\" child=\"b\" config=\"text\">\n    <b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nErstellt einen Scope direkt auf dem Element.\n\nDer Wert ist der Path des Scopes.\n\nExample: Ein Scope auf dem Element\n```html\n<ui-bind plugin=\"users\" path=\"?.name\" config=\"text\"></ui-bind>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.set('name', 'Peter');\n    });\n</script>\n```\n\n### [!~]command [selector]:expression\n\nType: `type`\n\nEin Befehl besteht aus einem Namen und einem optionalen Ausdruck.\n\nDer Ausdruck kann diese Formen haben:\n\n| Form | Bedeutung |\n| --- | --- |\n| weggelassen | Der Wert selbst, wie bei `text`. |\n| `value + 1` | Ein JavaScript-Ausdruck, der das Wort `value` enthält. Die Variablen `value`, `path` und `el` stehen zur Verfügung. |\n| `value => value + 1` | Eine Pfeilfunktion. |\n| `common.format` | Der Path einer Funktion, die mit `value`, `path` und `el` aufgerufen wird. |\n| `?/format` | Eine Methode des Plugins des nächstgelegenen Scopes. |\n\nDie Präfixe und Trennzeichen sind:\n\n| Syntax | Bedeutung |\n| --- | --- |\n| `command selector:expression` | Führt den Befehl auf den Nachfahren aus, die zum Selektor passen. |\n| `text+title:value` | Führt einen Ausdruck für mehrere Befehle aus. |\n| `!command` | Überspringt den Befehl, solange der Wert `null` oder `undefined` ist. Auf dem Element selbst kehren `text`, `html`, `title`, `value`, `src`, `checked`, `disabled` und `enabled` dann zu ihrem ursprünglichen Inhalt zurück. |\n| `~command` | Führt den Befehl auch aus, während das Element durch `show`, `hide`, `visible` oder `invisible` ausgeblendet ist. |\n\nExample: Formen von Ausdrücken\n```html\n<ui-bind path=\"form.name\" config=\"text b:value.length;title:n => n + '!';.long:common.long\">\n    <b></b>\n</ui-bind>\n<script>\n    window.common = { long: value => value.length > 3 };\n    SET('form.name', 'Peter');\n</script>\n```\n\nExample: Ein Ausdruck für zwei Befehle\n```html\n<ui-bind path=\"form.name\" config=\"text+title:value\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\nExample: Den ursprünglichen Inhalt wiederherstellen\n```html\n<ui-bind path=\"form.name\" config=\"!text\">Anonymous</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', null), 500);\n</script>\n```\n\nExample: Ein ausgeblendetes Element aktualisieren\n```html\n<ui-bind path=\"form.name\" config=\"~text;hide:value\">Anonymous</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### text[:expression]\n\nType: `command`\n\nSetzt den Textinhalt.\n\nDer Wert wird escapt. Die Befehle [`format`](#format), [`currency`](#currency), [`helper`](#helper) und [`empty`](#empty) verändern die Ausgabe.\n\nExample: text verwenden\n```html\n<ui-bind path=\"form.name\" config=\"text\"></ui-bind>\n<script>SET('form.name', '<b>Peter</b>');</script>\n```\n\n### html[:expression]\n\nType: `command`\n\nSetzt den HTML-Inhalt.\n\nDer Wert wird nicht escapt.\n\nExample: html verwenden\n```html\n<ui-bind path=\"form.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### value[:expression]\n\nType: `command`\n\nSetzt den Wert eines Formularfelds.\n\nAuch der Kurzname `val` funktioniert.\n\nExample: value verwenden\n```html\n<ui-bind path=\"form.name\" config=\"value input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('input').val()), 500);  // Peter\n</script>\n```\n\n### title[:expression]\n\nType: `command`\n\nSetzt das Attribut `title`.\n\nExample: title verwenden\n```html\n<ui-bind path=\"form.name\" config=\"title\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### href[:expression]\n\nType: `command`\n\nSetzt das Attribut `href`.\n\nExample: href verwenden\n```html\n<ui-bind path=\"form.id\" config=\"href a:'/users/' + value + '/'\">\n    <a>Detail</a>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### src[:expression]\n\nType: `command`\n\nSetzt das Attribut `src`.\n\nExample: src verwenden\n```html\n<ui-bind path=\"form.photo\" config=\"src img\">\n    <img />\n</ui-bind>\n<script>SET('form.photo', 'data:,');</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nSetzt ein beliebiges Attribut.\n\nDer Name des Attributs folgt auf den Befehl. Auf den Namen kann ein Selektor folgen.\n\nExample: attr verwenden\n```html\n<ui-bind path=\"form.id\" config=\"attr data-id:value;attr data-ref b:value\">\n    <b></b>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### .classname[ selector]:expression\n\nType: `command`\n\nSchaltet eine CSS-Klasse anhand des Ergebnisses des Ausdrucks um.\n\nSchreibe den Namen der Klasse hinter den Punkt.\n\nExample: Klassen umschalten\n```html\n<ui-bind path=\"form.age\" config=\".adult:value >= 18;.minor:value < 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### class:classes\n\nType: `command`\n\nSchaltet CSS-Klassen einmalig um, nach der ersten Aktualisierung.\n\nTrenne mehrere Klassen durch ein Leerzeichen.\n\nExample: class verwenden\n```html\n<ui-bind path=\"form.name\" config=\"class:ready\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### show[:expression]\n\nType: `command`\n\nZeigt das Element an, wenn der Ausdruck truthy ist.\n\nAndernfalls erhält das Element die Klasse `hidden`. Solange es ausgeblendet ist, werden die folgenden Befehle übersprungen, sofern sie nicht das Präfix `~` haben.\n\nExample: show verwenden\n```html\n<ui-bind path=\"form.age\" config=\"show:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### hide[:expression]\n\nType: `command`\n\nBlendet das Element aus, wenn der Ausdruck truthy ist.\n\nDas Element erhält die Klasse `hidden`. Auch der Name `hidden` funktioniert.\n\nExample: hide verwenden\n```html\n<ui-bind path=\"form.age\" config=\"hide:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### visible[:expression]\n\nType: `command`\n\nBehält den Platz im Layout bei, wenn der Ausdruck falsy ist.\n\nDas Element erhält die Klasse `invisible`, wenn der Ausdruck falsy ist.\n\nExample: visible verwenden\n```html\n<ui-bind path=\"form.age\" config=\"visible:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### invisible[:expression]\n\nType: `command`\n\nFügt die Klasse `invisible` hinzu, wenn der Ausdruck truthy ist.\n\nExample: invisible verwenden\n```html\n<ui-bind path=\"form.age\" config=\"invisible:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### checked[:expression]\n\nType: `command`\n\nSetzt die Eigenschaft `checked` eines Felds.\n\nExample: checked verwenden\n```html\n<ui-bind path=\"form.active\" config=\"checked input\">\n    <input type=\"checkbox\" />\n</ui-bind>\n<script>\n    SET('form.active', true);\n    setTimeout(() => console.log($('input').prop('checked')), 500);  // true\n</script>\n```\n\n### disabled[:expression]\n\nType: `command`\n\nDeaktiviert Felder und Komponenten, wenn der Ausdruck truthy ist.\n\nAuch der Kurzname `disable` funktioniert. Ohne Selektor gilt der Befehl für `ui-component`, `input`, `textarea`, `select` und `button` innerhalb des Elements. Komponenten erhalten den Konfigurationsschlüssel `disabled`.\n\nExample: disabled verwenden\n```html\n<ui-bind path=\"form.locked\" config=\"disabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.locked', true);</script>\n```\n\n### enabled[:expression]\n\nType: `command`\n\nAktiviert Felder und Komponenten, wenn der Ausdruck truthy ist.\n\nAuch der Kurzname `enable` funktioniert. Der Standardselektor ist derselbe wie bei [`disabled`](#disabled).\n\nExample: enabled verwenden\n```html\n<ui-bind path=\"form.valid\" config=\"enabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.valid', false);</script>\n```\n\n### required selector:expression\n\nType: `command`\n\nSetzt den Konfigurationsschlüssel `required` einer Komponente.\n\nGib einen Selektor an, denn der Befehl hat keinen Standardselektor.\n\nExample: required verwenden\n```html\n<ui-bind path=\"form.strict\" config=\"required ui-component:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'required' && console.log(value);  // true\n    });\n    SET('form.strict', true);\n</script>\n```\n\n### config:expression\n\nType: `command`\n\nKonfiguriert Komponenten mit dem Ergebnis des Ausdrucks neu.\n\nDer Standardselektor ist `ui-component`.\n\nExample: config verwenden\n```html\n<ui-bind path=\"form.title\" config=\"config:'title:' + value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'title' && console.log(value);  // Orders\n    });\n    SET('form.title', 'Orders');\n</script>\n```\n\n### set[:expression]\n\nType: `command`\n\nÜbergibt das Ergebnis des Ausdrucks an den `setter` einer Komponente ohne Path.\n\nDer Standardselektor ist `ui-component`. Die Komponente kann in denselben Path zurückschreiben.\n\nExample: set verwenden\n```html\n<ui-bind path=\"form.name\" config=\"set:value + '!'\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = value => self.text(value);\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### setter:'selector/method',value\n\nType: `command`\n\nRuft eine Methode der passenden Komponenten auf.\n\nDer Ausdruck enthält die Argumente von `SETTER()` und wird mit `value`, `path` und `el` ausgewertet.\n\nExample: setter verwenden\n```html\n<ui-bind path=\"form.name\" config=\"setter:'box/show',value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.show = value => value && console.log(value);  // Peter\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### template [selector][:selector-->attribute]\n\nType: `command`\n\nRendert ein Tangular-Template.\n\nDas Template ist das erste `<script>` oder `<template>` innerhalb des Elements. Das Modell hat die Eigenschaften `value` und `path`.\n\nDie optionale Form `template:selector-->attribute` aktualisiert nur die geänderten Kindelemente. Der Selektor findet die Einträge und das Attribut identifiziert sie. Mehr dazu erfährst du unter [Templates mit Tangular](../../guides/tangular/).\n\nExample: template verwenden\n```html\n<ui-bind path=\"form.items\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<li>{{ m }}</li>{{ end }}\n    </script>\n</ui-bind>\n<script>SET('form.items', ['A', 'B']);</script>\n```\n\n### helpers:path\n\nType: `command`\n\nÜbergibt Tangular-Helper an das Template.\n\nDer Wert ist ein Path zu einem Objekt mit Helpern oder zu einer Funktion, die ein solches Objekt zurückgibt.\n\nExample: helpers verwenden\n```html\n<ui-bind path=\"form.name\" config=\"template;helpers:common.helpers\">\n    <script type=\"text/html\">{{ value | shout }}</script>\n</ui-bind>\n<script>\n    window.common = { helpers: { shout: value => value + '!' } };\n    SET('form.name', 'Peter');\n</script>\n```\n\n### vbindarray\n\nType: `command`\n\nRendert ein Array mit einem virtuellen Binder pro Eintrag.\n\nDas Template ist das erste `<script>` oder `<template>` innerhalb des Elements. Paths innerhalb des Templates beginnen mit einem Punkt. Siehe [Virtueller Binder](../vbinder/).\n\nExample: vbindarray verwenden\n```html\n<ui-bind path=\"form.users\" config=\"vbindarray\">\n    <script type=\"text/html\">\n        <div><ui-bind path=\".name\" config=\"text\"></ui-bind></div>\n    </script>\n</ui-bind>\n<script>SET('form.users', [{ name: 'Peter' }, { name: 'Anna' }]);</script>\n```\n\n### import:url\n\nType: `command`\n\nLädt Inhalte in das Element.\n\nDer Wert ist einer der folgenden:\n\n| Wert | Bedeutung |\n| --- | --- |\n| Eine URL, die mit `/`, `http://` oder `https://` beginnt | Importiert die URL einmal. |\n| `value` oder `true` | Verschiebt das erste innere `<script>` oder `<template>` in das DOM. |\n| Ein Ausdruck | Importiert die URL, die der Wert des Paths liefert, einmal pro URL. |\n\nDer Import wartet, bis das Element sichtbar ist, und lässt sich daher mit [`show`](#show) kombinieren.\n\nExample: Ein Template einfügen, wenn das Element angezeigt wird\n```html\n<ui-bind path=\"form.open\" config=\"show;import:value\">\n    <script type=\"text/html\"><b>Loaded</b></script>\n</ui-bind>\n<script>\n    setTimeout(() => SET('form.open', true), 500);\n</script>\n```\n\n### macro:name1,name2\n\nType: `command`\n\nHängt Macros an das Element an.\n\nTrenne mehrere Namen durch ein Komma. Siehe [Macro](../macro/).\n\nExample: macro verwenden\n```html\n<ui-bind path=\"form.name\" config=\"macro:shout\"></ui-bind>\n<script>\n    MACRO('shout', function(self) {\n        self.setter = value => self.text(value + '!');\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nRuft bei jeder Aktualisierung eine Funktion auf.\n\nDie Funktion erhält `value`, `path` und `el`, und `this` ist das Element. Dabei bekommt die Funktion immer den Rohwert. Auch der Name `change` funktioniert.\n\nExample: exec verwenden\n```html\n<ui-bind path=\"form.name\" config=\"exec:common.onchange\"></ui-bind>\n<script>\n    window.common = { onchange: (value, path) => value && console.log(value, path) };  // Peter form.name\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### init:path\n\nType: `command`\n\nRuft zu Beginn jeder Aktualisierung eine Funktion auf.\n\nDie Funktion erhält `value`, `path` und `el`.\n\nExample: init verwenden\n```html\n<ui-bind path=\"form.name\" config=\"init:common.oninit\"></ui-bind>\n<script>\n    window.common = { oninit: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nRuft bei jeder Aktualisierung eine Funktion auf, solange das Element sichtbar ist.\n\nDie Funktion erhält `value`, `path` und `el`.\n\nExample: refresh verwenden\n```html\n<ui-bind path=\"form.name\" config=\"refresh:common.onrefresh\"></ui-bind>\n<script>\n    window.common = { onrefresh: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### click [selector]:path\n\nType: `command`\n\nRuft eine Funktion auf, wenn auf das Element geklickt wird.\n\nDie Funktion erhält das jQuery-Element, das Event, den aktuellen Wert und den Path. Ein Selektor delegiert den Klick an die passenden Nachfahren. Deaktivierte Eingabefelder und Buttons werden ignoriert.\n\nExample: click verwenden\n```html\n<ui-bind path=\"form.name\" config=\"click button:common.onclick\">\n    <button>Save</button>\n</ui-bind>\n<script>\n    window.common = {\n        onclick: (element, event, value, path) => console.log(element.text(), value, path)  // Save Peter form.name\n    };\n    SET('form.name', 'Peter');\n    setTimeout(() => $('button').click(), 500);\n</script>\n```\n\n### format:format\n\nType: `command`\n\nFormatiert eine Zahl oder ein Datum.\n\nEine Zahl legt die Dezimalstellen fest. Jeder andere Text ist ein Datumsformat.\n\nExample: format verwenden\n```html\n<ui-bind path=\"form.price\" config=\"text;format:2\"></ui-bind>\n<script>SET('form.price', 1250);</script>\n```\n\n### currency:name\n\nType: `command`\n\nFormatiert eine Zahl mit einer Währung.\n\nDer Name verweist auf eine Funktion in `DEF.currencies`.\n\nExample: currency verwenden\n```html\n<ui-bind path=\"form.price\" config=\"text;currency:eur\"></ui-bind>\n<script>\n    DEF.currencies.eur = value => value.format(2) + ' EUR';\n    SET('form.price', 1250);\n</script>\n```\n\n### helper:name[(arguments)]\n\nType: `command`\n\nWandelt die Ausgabe mit einem Tangular-Helper um.\n\nDer Wert wird als erstes Argument an den Helper übergeben. Weitere Argumente kannst du in Klammern angeben.\n\nExample: helper verwenden\n```html\n<ui-bind path=\"form.name\" config=\"text;helper:wrap('*')\"></ui-bind>\n<script>\n    Thelpers.wrap = (value, chars) => chars + value + chars;\n    SET('form.name', 'Peter');\n</script>\n```\n\n### empty[:text]\n\nType: `command`\n\nLegt den Text für einen leeren Wert fest.\n\nOhne Wert verwendet der Befehl `DEF.empty`, also `---`.\n\nExample: empty verwenden\n```html\n<ui-bind path=\"form.name\" config=\"text;empty:Nothing\"></ui-bind>\n```\n\n### default:expression\n\nType: `command`\n\nErsetzt `null` und `undefined` durch einen Wert.\n\nDer Wert ist ein JavaScript-Ausdruck. Auch der Kurzname `def` funktioniert.\n\nExample: default verwenden\n```html\n<ui-bind path=\"form.name\" config=\"text;default:'Anonymous'\"></ui-bind>\n```\n\n### selector:selector\n\nType: `command`\n\nWendet alle Befehle auf die passenden Nachfahren an.\n\nExample: selector verwenden\n```html\n<ui-bind path=\"form.name\" config=\"selector:b;text\">\n    <b></b><b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### assign:path\n\nType: `command`\n\nSchreibt das jQuery-Element in einen Path.\n\nExample: assign verwenden\n```html\n<ui-bind id=\"box\" path=\"form.name\" config=\"assign:common.box;text\"></ui-bind>\n<script>\n    setTimeout(() => console.log(GET('common.box').attr('id')), 500);  // box\n</script>\n```\n\n### check:path\n\nType: `command`\n\nFührt die Befehle nur aus, wenn eine Bedingung erfüllt ist.\n\nDer Wert ist ein Path zu einem truthy Wert oder `plugin/method`, das `value`, `path` und `el` erhält.\n\nExample: check verwenden\n```html\n<ui-bind path=\"form.name\" config=\"check:form.ready;text\">Waiting</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nVerzögert die Aktualisierung um eine Anzahl von Millisekunden.\n\nWiederholte Aktualisierungen innerhalb der Verzögerung laufen nur einmal.\n\nExample: delay verwenden\n```html\n<ui-bind path=\"form.name\" config=\"delay:500;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('ui-bind').text() || 'empty'), 200);  // empty\n    setTimeout(() => console.log($('ui-bind').text()), 1100);  // Peter\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnoriert Änderungen an verschachtelten Paths.\n\nDie Befehle laufen nur, wenn sich der Path selbst oder einer seiner übergeordneten Paths ändert.\n\nExample: strict verwenden\n```html\n<ui-bind path=\"form.user\" config=\"strict;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter' });\n    setTimeout(() => SET('form.user.name', 'Anna'), 500);\n</script>\n```\n\n### track:field1,field2\n\nType: `command`\n\nFührt die Befehle nur für ausgewählte verschachtelte Felder aus.\n\nTrenne mehrere Felder durch ein Komma.\n\nExample: track verwenden\n```html\n<ui-bind path=\"form.user\" config=\"track:name;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter', age: 20 });\n    setTimeout(() => SET('form.user.age', 21), 500);\n    setTimeout(() => SET('form.user.name', 'Anna'), 700);\n</script>\n```\n\n### tracktype:type1,type2\n\nType: `command`\n\nFührt die Befehle nur für ausgewählte Aktualisierungstypen aus.\n\nTrenne mehrere Typen durch ein Komma.\n\nExample: tracktype verwenden\n```html\n<ui-bind path=\"form.age\" config=\"tracktype:2;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10, 1), 500);\n    setTimeout(() => SET('form.age', 20, 2), 700);\n</script>\n```\n\n### changes\n\nType: `command`\n\nÜberspringt die Befehle, wenn sich der Wert nicht geändert hat.\n\nDer Wert wird anhand eines Hashs verglichen.\n\nExample: changes verwenden\n```html\n<ui-bind path=\"form.age\" config=\"changes;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10), 500);\n    setTimeout(() => UPD('form.age'), 700);\n</script>\n```\n\n### ready\n\nType: `command`\n\nWartet auf die im Element verschachtelten Komponenten.\n\nDie Befehle laufen, sobald alle verschachtelten Komponenten bereit sind.\n\nExample: ready verwenden\n```html\n<ui-bind path=\"form.name\" config=\"ready;exec:common.update\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    window.common = { update: () => console.log(FIND('box') ? 'found' : 'missing') };  // found\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### once\n\nType: `command`\n\nFührt die Befehle nur ein einziges Mal aus.\n\nExample: once verwenden\n```html\n<ui-bind path=\"form.name\" config=\"once;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', 'Anna'), 700);\n</script>\n```\n\n### focus:selector\n\nType: `command`\n\nSetzt nach jeder Aktualisierung den Fokus auf ein Feld.\n\nDer Wert ist ein Selektor für Nachfahren.\n\nExample: Ein Feld fokussieren\n```html\n<ui-bind path=\"form.name\" config=\"focus:input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n</script>\n```\n\n### resize\n\nType: `command`\n\nRuft nach jeder Aktualisierung die Methode `resize` der verschachtelten Komponenten auf.\n\nExample: resize verwenden\n```html\n<ui-bind path=\"form.name\" config=\"resize\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.resize = () => console.log('resized');  // resized\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### binder.refresh()\n\nType: `method`\n\nFührt die Befehle erneut mit dem aktuellen Wert des Paths aus.\n\nDer Binder steht als `element.ui` oder über `$(element).binder()` zur Verfügung.\n\nExample: Einen Binder aktualisieren\n```js\nvar binder = $('ui-bind').binder();\nwindow.form.name = 'Anna';\nbinder.refresh();\nconsole.log($('ui-bind').text());  // Anna\n```\n\n### binder.exec(value, path)\n\nType: `method`\n\nFührt die Befehle mit einem eigenen Wert aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der an die Befehle übergebene Wert. |\n| `path` | `String` | yes |  | Der an die Befehle übergebene Path. |\n\nDer Wert wird nicht in das Datenmodell geschrieben.\n\nExample: Die Befehle mit einem Wert ausführen\n```js\nvar binder = $('ui-bind').binder();\nbinder.exec('Preview', 'form.name');\nconsole.log($('ui-bind').text(), GET('form.name'));  // Preview Peter\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"command:expression;command:expression\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"type","name":"Command syntax","signature":"[!~]command [selector]: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[: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":".class","signature":".classname[ selector]:expression","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:classes","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":"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 selector:expression","since":"","deprecated":false},{"type":"command","name":"config","signature":"config:expression","since":"","deprecated":false},{"type":"command","name":"set","signature":"set[:expression]","since":"","deprecated":false},{"type":"command","name":"setter","signature":"setter:'selector/method',value","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":"vbindarray","signature":"vbindarray","since":"","deprecated":false},{"type":"command","name":"import","signature":"import:url","since":"","deprecated":false},{"type":"command","name":"macro","signature":"macro:name1,name2","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"click","signature":"click [selector]:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:format","since":"","deprecated":false},{"type":"command","name":"currency","signature":"currency:name","since":"","deprecated":false},{"type":"command","name":"helper","signature":"helper:name[(arguments)]","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty[:text]","since":"","deprecated":false},{"type":"command","name":"default","signature":"default:expression","since":"","deprecated":false},{"type":"command","name":"selector","signature":"selector:selector","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:field1,field2","since":"","deprecated":false},{"type":"command","name":"tracktype","signature":"tracktype:type1,type2","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"resize","signature":"resize","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"binder.refresh()","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"binder.exec(value, path)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammk9C2j61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-bind/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"ui-bind","summary":"Los atributos y comandos del elemento ui-bind, y el objeto binder que crea.","markdown":"---\ntitle: ui-bind\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-bind/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# ui-bind\n\n> Los atributos y comandos del elemento ui-bind, y el objeto binder que crea.\n\nEl elemento `<ui-bind>` observa un path y actualiza el DOM cuando cambia el valor. Su atributo `config` contiene una lista de comandos. [Enlace de datos](../../guides/data-binding/) explica el concepto.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nDefine el path que observa el elemento.\n\nEl atributo admite estas formas:\n\n| Valor | Significado |\n| --- | --- |\n| `form.name` | Un path absoluto. |\n| `!form.name` | Los comandos se omiten mientras el valor sea `null` o `undefined`. |\n| `?.name` | Un path relativo al [`ui-plugin`](../ui-plugin/) más cercano. |\n| `*name` | Un path dentro de `DEF.pathcommon`. |\n| `%name` | Un path temporal. |\n| `@key` | Un valor guardado con [`data()`](../component/#data) del componente padre. `@` por sí solo es el valor de ese componente y `@config.key` es una clave de configuración. |\n| `.name` | Un path dentro del modelo de un [binder virtual](../vbinder/). `.` por sí solo es el modelo completo. |\n| `form.name --> expression` | Transforma el valor con una expresión que recibe `value`. |\n\nCuando el elemento tiene un path y no tiene `config`, el path debe contener una función, a la que se llama con el elemento.\n\nExample: Omitir los valores vacíos\n```html\n<ui-bind path=\"!form.name\" config=\"text\">Waiting</ui-bind>\n```\n\nExample: Transformar el valor\n```html\n<ui-bind path=\"form.name --> value.toUpperCase()\" config=\"text\"></ui-bind>\n<script>SET('form.name', 'peter');</script>\n```\n\nExample: Leer datos del componente padre\n```html\n<ui-component name=\"card\" config=\"title:Orders\">\n    <ui-bind path=\"@config.title\" config=\"text\"></ui-bind>\n</ui-component>\n<script>COMPONENT('card', function(self) {});</script>\n```\n\nExample: Llamar a una función con el elemento\n```html\n<ui-bind path=\"common.init\" id=\"box\"></ui-bind>\n<script>\n    window.common = { init: element => console.log(element.attr('id')) };  // box\n</script>\n```\n\n### config=\"command:expression;command:expression\"\n\nType: `property`\n\nContiene los comandos del elemento.\n\nLos comandos se separan con punto y coma. Cada comando tiene la forma `name:expression`. Consulta la [sintaxis de los comandos](#command-syntax).\n\nExample: Dos comandos\n```html\n<ui-bind path=\"form.age\" config=\"text:value + ' years';.adult:value >= 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### element=\"selector\"\n\nType: `property`\n\nAplica los comandos a otro elemento.\n\nEl valor es un selector de jQuery que se evalúa en todo el documento.\n\nExample: Actualizar un elemento situado en otro lugar\n```html\n<ui-bind path=\"form.name\" element=\"#target\" config=\"text\"></ui-bind>\n<div id=\"target\"></div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nAplica los comandos al padre coincidente más cercano.\n\nEl valor es un selector de jQuery que se pasa a `closest()`.\n\nExample: Actualizar un elemento padre\n```html\n<div class=\"row\">\n    <ui-bind path=\"form.name\" parent=\".row\" config=\"title:value\"></ui-bind>\n</div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nAplica los comandos al primer descendiente coincidente.\n\nEl atributo se puede combinar con [`parent`](#parent).\n\nExample: Actualizar un elemento hijo\n```html\n<ui-bind path=\"form.name\" child=\"b\" config=\"text\">\n    <b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un scope directamente en el elemento.\n\nEl valor es el path del scope.\n\nExample: Un scope en el elemento\n```html\n<ui-bind plugin=\"users\" path=\"?.name\" config=\"text\"></ui-bind>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.set('name', 'Peter');\n    });\n</script>\n```\n\n### [!~]command [selector]:expression\n\nType: `type`\n\nUn comando es un nombre seguido de una expresión opcional.\n\nLa expresión puede tener estas formas:\n\n| Forma | Significado |\n| --- | --- |\n| omitida | El propio valor, como en `text`. |\n| `value + 1` | Una expresión de JavaScript que contiene la palabra `value`. Dispones de las variables `value`, `path` y `el`. |\n| `value => value + 1` | Una función flecha. |\n| `common.format` | El path de una función a la que se llama con `value`, `path` y `el`. |\n| `?/format` | Un método del plugin del scope más cercano. |\n\nLos prefijos y separadores son:\n\n| Sintaxis | Significado |\n| --- | --- |\n| `command selector:expression` | Ejecuta el comando en los descendientes que coinciden con el selector. |\n| `text+title:value` | Ejecuta una expresión para varios comandos. |\n| `!command` | Omite el comando mientras el valor sea `null` o `undefined`. En el propio elemento, `text`, `html`, `title`, `value`, `src`, `checked`, `disabled` y `enabled` vuelven entonces a su contenido original. |\n| `~command` | Ejecuta el comando también mientras el elemento está oculto por `show`, `hide`, `visible` o `invisible`. |\n\nExample: Formas de la expresión\n```html\n<ui-bind path=\"form.name\" config=\"text b:value.length;title:n => n + '!';.long:common.long\">\n    <b></b>\n</ui-bind>\n<script>\n    window.common = { long: value => value.length > 3 };\n    SET('form.name', 'Peter');\n</script>\n```\n\nExample: Una expresión para dos comandos\n```html\n<ui-bind path=\"form.name\" config=\"text+title:value\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\nExample: Restaurar el contenido original\n```html\n<ui-bind path=\"form.name\" config=\"!text\">Anonymous</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', null), 500);\n</script>\n```\n\nExample: Actualizar un elemento oculto\n```html\n<ui-bind path=\"form.name\" config=\"~text;hide:value\">Anonymous</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### text[:expression]\n\nType: `command`\n\nDefine el contenido de texto.\n\nEl valor se escapa. Los comandos [`format`](#format), [`currency`](#currency), [`helper`](#helper) y [`empty`](#empty) cambian la salida.\n\nExample: Usar text\n```html\n<ui-bind path=\"form.name\" config=\"text\"></ui-bind>\n<script>SET('form.name', '<b>Peter</b>');</script>\n```\n\n### html[:expression]\n\nType: `command`\n\nDefine el contenido HTML.\n\nEl valor no se escapa.\n\nExample: Usar html\n```html\n<ui-bind path=\"form.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### value[:expression]\n\nType: `command`\n\nDefine el valor de un campo de formulario.\n\nTambién funciona el nombre corto `val`.\n\nExample: Usar value\n```html\n<ui-bind path=\"form.name\" config=\"value input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('input').val()), 500);  // Peter\n</script>\n```\n\n### title[:expression]\n\nType: `command`\n\nEstablece el atributo `title`.\n\nExample: Usar title\n```html\n<ui-bind path=\"form.name\" config=\"title\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### href[:expression]\n\nType: `command`\n\nEstablece el atributo `href`.\n\nExample: Usar href\n```html\n<ui-bind path=\"form.id\" config=\"href a:'/users/' + value + '/'\">\n    <a>Detail</a>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### src[:expression]\n\nType: `command`\n\nEstablece el atributo `src`.\n\nExample: Usar src\n```html\n<ui-bind path=\"form.photo\" config=\"src img\">\n    <img />\n</ui-bind>\n<script>SET('form.photo', 'data:,');</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nDefine cualquier atributo.\n\nEl nombre del atributo va después del comando. Después del nombre puede ir un selector.\n\nExample: Usar attr\n```html\n<ui-bind path=\"form.id\" config=\"attr data-id:value;attr data-ref b:value\">\n    <b></b>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### .classname[ selector]:expression\n\nType: `command`\n\nAlterna una clase CSS según el resultado de la expresión.\n\nEscribe el nombre de la clase después del punto.\n\nExample: Alternar clases\n```html\n<ui-bind path=\"form.age\" config=\".adult:value >= 18;.minor:value < 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### class:classes\n\nType: `command`\n\nAlterna clases CSS una sola vez, después de la primera actualización.\n\nSepara varias clases con un espacio.\n\nExample: Usar class\n```html\n<ui-bind path=\"form.name\" config=\"class:ready\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### show[:expression]\n\nType: `command`\n\nMuestra el elemento cuando la expresión es truthy.\n\nEn caso contrario, el elemento recibe la clase `hidden`. Mientras está oculto, los comandos siguientes se omiten salvo que lleven el prefijo `~`.\n\nExample: Usar show\n```html\n<ui-bind path=\"form.age\" config=\"show:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### hide[:expression]\n\nType: `command`\n\nOculta el elemento cuando la expresión es truthy.\n\nEl elemento recibe la clase `hidden`. También funciona el nombre `hidden`.\n\nExample: Usar hide\n```html\n<ui-bind path=\"form.age\" config=\"hide:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### visible[:expression]\n\nType: `command`\n\nConserva el espacio en el diseño cuando la expresión es falsy.\n\nEl elemento recibe la clase `invisible` cuando la expresión es falsy.\n\nExample: Usar visible\n```html\n<ui-bind path=\"form.age\" config=\"visible:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### invisible[:expression]\n\nType: `command`\n\nAñade la clase `invisible` cuando la expresión es truthy.\n\nExample: Usar invisible\n```html\n<ui-bind path=\"form.age\" config=\"invisible:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### checked[:expression]\n\nType: `command`\n\nDefine la propiedad `checked` de un campo.\n\nExample: Usar checked\n```html\n<ui-bind path=\"form.active\" config=\"checked input\">\n    <input type=\"checkbox\" />\n</ui-bind>\n<script>\n    SET('form.active', true);\n    setTimeout(() => console.log($('input').prop('checked')), 500);  // true\n</script>\n```\n\n### disabled[:expression]\n\nType: `command`\n\nDesactiva campos y componentes cuando la expresión es truthy.\n\nTambién funciona el nombre corto `disable`. Sin selector, el comando se aplica a `ui-component`, `input`, `textarea`, `select` y `button` dentro del elemento. Los componentes reciben la clave de configuración `disabled`.\n\nExample: Usar disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.locked', true);</script>\n```\n\n### enabled[:expression]\n\nType: `command`\n\nActiva campos y componentes cuando la expresión es truthy.\n\nTambién funciona el nombre corto `enable`. El selector predeterminado es el mismo que el de [`disabled`](#disabled).\n\nExample: Usar enabled\n```html\n<ui-bind path=\"form.valid\" config=\"enabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.valid', false);</script>\n```\n\n### required selector:expression\n\nType: `command`\n\nDefine la clave de configuración `required` de un componente.\n\nAñade un selector, porque el comando no tiene ninguno predeterminado.\n\nExample: Usar required\n```html\n<ui-bind path=\"form.strict\" config=\"required ui-component:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'required' && console.log(value);  // true\n    });\n    SET('form.strict', true);\n</script>\n```\n\n### config:expression\n\nType: `command`\n\nReconfigura los componentes con el resultado de la expresión.\n\nEl selector predeterminado es `ui-component`.\n\nExample: Usar config\n```html\n<ui-bind path=\"form.title\" config=\"config:'title:' + value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'title' && console.log(value);  // Orders\n    });\n    SET('form.title', 'Orders');\n</script>\n```\n\n### set[:expression]\n\nType: `command`\n\nPasa el resultado de la expresión al `setter` de un componente sin path.\n\nEl selector predeterminado es `ui-component`. El componente puede volver a escribir en el mismo path.\n\nExample: Usar set\n```html\n<ui-bind path=\"form.name\" config=\"set:value + '!'\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = value => self.text(value);\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### setter:'selector/method',value\n\nType: `command`\n\nLlama a un método de los componentes coincidentes.\n\nLa expresión contiene los argumentos de `SETTER()`, evaluados con `value`, `path` y `el`.\n\nExample: Usar setter\n```html\n<ui-bind path=\"form.name\" config=\"setter:'box/show',value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.show = value => value && console.log(value);  // Peter\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### template [selector][:selector-->attribute]\n\nType: `command`\n\nRenderiza una plantilla de Tangular.\n\nLa plantilla es el primer `<script>` o `<template>` dentro del elemento. El modelo tiene las propiedades `value` y `path`.\n\nLa forma opcional `template:selector-->attribute` actualiza solo los elementos hijos que han cambiado. El selector encuentra los ítems y el atributo los identifica. Más información en [Plantillas con Tangular](../../guides/tangular/).\n\nExample: Usar template\n```html\n<ui-bind path=\"form.items\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<li>{{ m }}</li>{{ end }}\n    </script>\n</ui-bind>\n<script>SET('form.items', ['A', 'B']);</script>\n```\n\n### helpers:path\n\nType: `command`\n\nPasa helpers de Tangular a la plantilla.\n\nEl valor es un path a un objeto con helpers o a una función que devuelve uno.\n\nExample: Usar helpers\n```html\n<ui-bind path=\"form.name\" config=\"template;helpers:common.helpers\">\n    <script type=\"text/html\">{{ value | shout }}</script>\n</ui-bind>\n<script>\n    window.common = { helpers: { shout: value => value + '!' } };\n    SET('form.name', 'Peter');\n</script>\n```\n\n### vbindarray\n\nType: `command`\n\nRenderiza un array con un binder virtual por ítem.\n\nLa plantilla es el primer `<script>` o `<template>` dentro del elemento. Los paths dentro de la plantilla empiezan por un punto. Consulta [Binder virtual](../vbinder/).\n\nExample: Usar vbindarray\n```html\n<ui-bind path=\"form.users\" config=\"vbindarray\">\n    <script type=\"text/html\">\n        <div><ui-bind path=\".name\" config=\"text\"></ui-bind></div>\n    </script>\n</ui-bind>\n<script>SET('form.users', [{ name: 'Peter' }, { name: 'Anna' }]);</script>\n```\n\n### import:url\n\nType: `command`\n\nCarga contenido en el elemento.\n\nEl valor es uno de estos:\n\n| Valor | Significado |\n| --- | --- |\n| Una URL que empieza por `/`, `http://` o `https://` | Importa la URL una sola vez. |\n| `value` o `true` | Mueve al DOM el primer `<script>` o `<template>` interior. |\n| Una expresión | Importa la URL que devuelve el valor del path, una vez por URL. |\n\nLa importación espera hasta que el elemento sea visible, así que se puede combinar con [`show`](#show).\n\nExample: Insertar una plantilla cuando se muestra el elemento\n```html\n<ui-bind path=\"form.open\" config=\"show;import:value\">\n    <script type=\"text/html\"><b>Loaded</b></script>\n</ui-bind>\n<script>\n    setTimeout(() => SET('form.open', true), 500);\n</script>\n```\n\n### macro:name1,name2\n\nType: `command`\n\nAsocia macros al elemento.\n\nSepara varios nombres con una coma. Consulta [Macro](../macro/).\n\nExample: Usar macro\n```html\n<ui-bind path=\"form.name\" config=\"macro:shout\"></ui-bind>\n<script>\n    MACRO('shout', function(self) {\n        self.setter = value => self.text(value + '!');\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nLlama a una función en cada actualización.\n\nLa función recibe `value`, `path` y `el`, y `this` es el elemento. Siempre recibe el valor sin procesar. También funciona el nombre `change`.\n\nExample: Usar exec\n```html\n<ui-bind path=\"form.name\" config=\"exec:common.onchange\"></ui-bind>\n<script>\n    window.common = { onchange: (value, path) => value && console.log(value, path) };  // Peter form.name\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### init:path\n\nType: `command`\n\nLlama a una función al principio de cada actualización.\n\nLa función recibe `value`, `path` y `el`.\n\nExample: Usar init\n```html\n<ui-bind path=\"form.name\" config=\"init:common.oninit\"></ui-bind>\n<script>\n    window.common = { oninit: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nLlama a una función en cada actualización mientras el elemento está visible.\n\nLa función recibe `value`, `path` y `el`.\n\nExample: Usar refresh\n```html\n<ui-bind path=\"form.name\" config=\"refresh:common.onrefresh\"></ui-bind>\n<script>\n    window.common = { onrefresh: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### click [selector]:path\n\nType: `command`\n\nLlama a una función cuando se hace clic en el elemento.\n\nLa función recibe el elemento de jQuery, el evento, el valor actual y el path. Un selector delega el clic en los descendientes coincidentes. Los inputs y botones desactivados se ignoran.\n\nExample: Usar click\n```html\n<ui-bind path=\"form.name\" config=\"click button:common.onclick\">\n    <button>Save</button>\n</ui-bind>\n<script>\n    window.common = {\n        onclick: (element, event, value, path) => console.log(element.text(), value, path)  // Save Peter form.name\n    };\n    SET('form.name', 'Peter');\n    setTimeout(() => $('button').click(), 500);\n</script>\n```\n\n### format:format\n\nType: `command`\n\nDa formato a un número o a una fecha.\n\nUn número define los decimales. Cualquier otro texto es un formato de fecha.\n\nExample: Usar format\n```html\n<ui-bind path=\"form.price\" config=\"text;format:2\"></ui-bind>\n<script>SET('form.price', 1250);</script>\n```\n\n### currency:name\n\nType: `command`\n\nDa formato a un número con una moneda.\n\nEl nombre hace referencia a una función de `DEF.currencies`.\n\nExample: Usar currency\n```html\n<ui-bind path=\"form.price\" config=\"text;currency:eur\"></ui-bind>\n<script>\n    DEF.currencies.eur = value => value.format(2) + ' EUR';\n    SET('form.price', 1250);\n</script>\n```\n\n### helper:name[(arguments)]\n\nType: `command`\n\nTransforma la salida con un helper de Tangular.\n\nEl valor se pasa como primer argumento del helper. Puedes escribir otros argumentos entre paréntesis.\n\nExample: Usar helper\n```html\n<ui-bind path=\"form.name\" config=\"text;helper:wrap('*')\"></ui-bind>\n<script>\n    Thelpers.wrap = (value, chars) => chars + value + chars;\n    SET('form.name', 'Peter');\n</script>\n```\n\n### empty[:text]\n\nType: `command`\n\nDefine el texto que se usa para un valor vacío.\n\nSin valor, el comando usa `DEF.empty`, que es `---`.\n\nExample: Usar empty\n```html\n<ui-bind path=\"form.name\" config=\"text;empty:Nothing\"></ui-bind>\n```\n\n### default:expression\n\nType: `command`\n\nSustituye `null` y `undefined` por un valor.\n\nEl valor es una expresión de JavaScript. También funciona el nombre corto `def`.\n\nExample: Usar default\n```html\n<ui-bind path=\"form.name\" config=\"text;default:'Anonymous'\"></ui-bind>\n```\n\n### selector:selector\n\nType: `command`\n\nAplica todos los comandos a los descendientes coincidentes.\n\nExample: Usar selector\n```html\n<ui-bind path=\"form.name\" config=\"selector:b;text\">\n    <b></b><b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### assign:path\n\nType: `command`\n\nEscribe el elemento de jQuery en un path.\n\nExample: Usar assign\n```html\n<ui-bind id=\"box\" path=\"form.name\" config=\"assign:common.box;text\"></ui-bind>\n<script>\n    setTimeout(() => console.log(GET('common.box').attr('id')), 500);  // box\n</script>\n```\n\n### check:path\n\nType: `command`\n\nEjecuta los comandos solo cuando se cumple una condición.\n\nEl valor es un path a un valor truthy, o `plugin/method`, que recibe `value`, `path` y `el`.\n\nExample: Usar check\n```html\n<ui-bind path=\"form.name\" config=\"check:form.ready;text\">Waiting</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nRetrasa la actualización en milisegundos.\n\nLas actualizaciones repetidas dentro del retardo se ejecutan una sola vez.\n\nExample: Usar delay\n```html\n<ui-bind path=\"form.name\" config=\"delay:500;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('ui-bind').text() || 'empty'), 200);  // empty\n    setTimeout(() => console.log($('ui-bind').text()), 1100);  // Peter\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnora los cambios de los paths anidados.\n\nLos comandos se ejecutan solo cuando cambia el propio path o uno de sus padres.\n\nExample: Usar strict\n```html\n<ui-bind path=\"form.user\" config=\"strict;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter' });\n    setTimeout(() => SET('form.user.name', 'Anna'), 500);\n</script>\n```\n\n### track:field1,field2\n\nType: `command`\n\nEjecuta los comandos solo para los campos anidados seleccionados.\n\nSepara varios campos con una coma.\n\nExample: Usar track\n```html\n<ui-bind path=\"form.user\" config=\"track:name;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter', age: 20 });\n    setTimeout(() => SET('form.user.age', 21), 500);\n    setTimeout(() => SET('form.user.name', 'Anna'), 700);\n</script>\n```\n\n### tracktype:type1,type2\n\nType: `command`\n\nEjecuta los comandos solo para los tipos de actualización seleccionados.\n\nSepara varios tipos con una coma.\n\nExample: Usar tracktype\n```html\n<ui-bind path=\"form.age\" config=\"tracktype:2;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10, 1), 500);\n    setTimeout(() => SET('form.age', 20, 2), 700);\n</script>\n```\n\n### changes\n\nType: `command`\n\nOmite los comandos cuando el valor no ha cambiado.\n\nEl valor se compara mediante un hash.\n\nExample: Usar changes\n```html\n<ui-bind path=\"form.age\" config=\"changes;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10), 500);\n    setTimeout(() => UPD('form.age'), 700);\n</script>\n```\n\n### ready\n\nType: `command`\n\nEspera a los componentes anidados en el elemento.\n\nLos comandos se ejecutan cuando todos los componentes anidados están listos.\n\nExample: Usar ready\n```html\n<ui-bind path=\"form.name\" config=\"ready;exec:common.update\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    window.common = { update: () => console.log(FIND('box') ? 'found' : 'missing') };  // found\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### once\n\nType: `command`\n\nEjecuta los comandos una sola vez.\n\nExample: Usar once\n```html\n<ui-bind path=\"form.name\" config=\"once;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', 'Anna'), 700);\n</script>\n```\n\n### focus:selector\n\nType: `command`\n\nMueve el foco a un campo después de cada actualización.\n\nEl valor es un selector de descendientes.\n\nExample: Dar el foco a un campo\n```html\n<ui-bind path=\"form.name\" config=\"focus:input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n</script>\n```\n\n### resize\n\nType: `command`\n\nLlama al método `resize` de los componentes anidados después de cada actualización.\n\nExample: Usar resize\n```html\n<ui-bind path=\"form.name\" config=\"resize\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.resize = () => console.log('resized');  // resized\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### binder.refresh()\n\nType: `method`\n\nVuelve a ejecutar los comandos con el valor actual del path.\n\nEl binder está disponible como `element.ui` o mediante `$(element).binder()`.\n\nExample: Refrescar un binder\n```js\nvar binder = $('ui-bind').binder();\nwindow.form.name = 'Anna';\nbinder.refresh();\nconsole.log($('ui-bind').text());  // Anna\n```\n\n### binder.exec(value, path)\n\nType: `method`\n\nEjecuta los comandos con un valor personalizado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor que se pasa a los comandos. |\n| `path` | `String` | yes |  | El path que se pasa a los comandos. |\n\nEl valor no se escribe en el modelo de datos.\n\nExample: Ejecutar los comandos con un valor\n```js\nvar binder = $('ui-bind').binder();\nbinder.exec('Preview', 'form.name');\nconsole.log($('ui-bind').text(), GET('form.name'));  // Preview Peter\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"command:expression;command:expression\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"type","name":"Command syntax","signature":"[!~]command [selector]: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[: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":".class","signature":".classname[ selector]:expression","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:classes","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":"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 selector:expression","since":"","deprecated":false},{"type":"command","name":"config","signature":"config:expression","since":"","deprecated":false},{"type":"command","name":"set","signature":"set[:expression]","since":"","deprecated":false},{"type":"command","name":"setter","signature":"setter:'selector/method',value","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":"vbindarray","signature":"vbindarray","since":"","deprecated":false},{"type":"command","name":"import","signature":"import:url","since":"","deprecated":false},{"type":"command","name":"macro","signature":"macro:name1,name2","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"click","signature":"click [selector]:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:format","since":"","deprecated":false},{"type":"command","name":"currency","signature":"currency:name","since":"","deprecated":false},{"type":"command","name":"helper","signature":"helper:name[(arguments)]","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty[:text]","since":"","deprecated":false},{"type":"command","name":"default","signature":"default:expression","since":"","deprecated":false},{"type":"command","name":"selector","signature":"selector:selector","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:field1,field2","since":"","deprecated":false},{"type":"command","name":"tracktype","signature":"tracktype:type1,type2","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"resize","signature":"resize","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"binder.refresh()","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"binder.exec(value, path)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammk9C2j61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-bind/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"ui-bind","summary":"Les attributs et les commandes de l'élément ui-bind, ainsi que l'objet binder qu'il crée.","markdown":"---\ntitle: ui-bind\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-bind/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# ui-bind\n\n> Les attributs et les commandes de l'élément ui-bind, ainsi que l'objet binder qu'il crée.\n\nL'élément `<ui-bind>` observe un path et met à jour le DOM quand la valeur change. Son attribut `config` contient une liste de commandes. [Liaison de données](../../guides/data-binding/) explique le concept.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nDéfinit le path que l'élément observe.\n\nL'attribut accepte ces formes :\n\n| Valeur | Signification |\n| --- | --- |\n| `form.name` | Un path absolu. |\n| `!form.name` | Les commandes sont ignorées tant que la valeur est `null` ou `undefined`. |\n| `?.name` | Un path relatif au [`ui-plugin`](../ui-plugin/) le plus proche. |\n| `*name` | Un path à l'intérieur de `DEF.pathcommon`. |\n| `%name` | Un path temporaire. |\n| `@key` | Une valeur stockée avec [`data()`](../component/#data) du composant parent. `@` seul est la valeur de ce composant et `@config.key` est une clé de configuration. |\n| `.name` | Un path à l'intérieur du modèle de données d'un [binder virtuel](../vbinder/). `.` seul est le modèle de données entier. |\n| `form.name --> expression` | Transforme la valeur avec une expression qui reçoit `value`. |\n\nQuand l'élément a un path et aucun `config`, le path doit contenir une fonction, qui est appelée avec l'élément.\n\nExample: Ignorer les valeurs vides\n```html\n<ui-bind path=\"!form.name\" config=\"text\">Waiting</ui-bind>\n```\n\nExample: Transformer la valeur\n```html\n<ui-bind path=\"form.name --> value.toUpperCase()\" config=\"text\"></ui-bind>\n<script>SET('form.name', 'peter');</script>\n```\n\nExample: Lire les données du composant parent\n```html\n<ui-component name=\"card\" config=\"title:Orders\">\n    <ui-bind path=\"@config.title\" config=\"text\"></ui-bind>\n</ui-component>\n<script>COMPONENT('card', function(self) {});</script>\n```\n\nExample: Appeler une fonction avec l'élément\n```html\n<ui-bind path=\"common.init\" id=\"box\"></ui-bind>\n<script>\n    window.common = { init: element => console.log(element.attr('id')) };  // box\n</script>\n```\n\n### config=\"command:expression;command:expression\"\n\nType: `property`\n\nContient les commandes de l'élément.\n\nLes commandes sont séparées par un point-virgule. Chaque commande a la forme `name:expression`. Consulte [Syntaxe des commandes](#command-syntax).\n\nExample: Deux commandes\n```html\n<ui-bind path=\"form.age\" config=\"text:value + ' years';.adult:value >= 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### element=\"selector\"\n\nType: `property`\n\nApplique les commandes à un autre élément.\n\nLa valeur est un sélecteur jQuery évalué dans tout le document.\n\nExample: Mettre à jour un élément ailleurs dans la page\n```html\n<ui-bind path=\"form.name\" element=\"#target\" config=\"text\"></ui-bind>\n<div id=\"target\"></div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nApplique les commandes au parent correspondant le plus proche.\n\nLa valeur est un sélecteur jQuery passé à `closest()`.\n\nExample: Mettre à jour un élément parent\n```html\n<div class=\"row\">\n    <ui-bind path=\"form.name\" parent=\".row\" config=\"title:value\"></ui-bind>\n</div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nApplique les commandes au premier descendant correspondant.\n\nL'attribut peut être combiné avec [`parent`](#parent).\n\nExample: Mettre à jour un élément enfant\n```html\n<ui-bind path=\"form.name\" child=\"b\" config=\"text\">\n    <b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrée un scope directement sur l'élément.\n\nLa valeur est le path du scope.\n\nExample: Un scope sur l'élément\n```html\n<ui-bind plugin=\"users\" path=\"?.name\" config=\"text\"></ui-bind>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.set('name', 'Peter');\n    });\n</script>\n```\n\n### [!~]command [selector]:expression\n\nType: `type`\n\nUne commande est un nom suivi d'une expression facultative.\n\nL'expression peut prendre ces formes :\n\n| Forme | Signification |\n| --- | --- |\n| omise | La valeur elle-même, comme dans `text`. |\n| `value + 1` | Une expression JavaScript qui contient le mot `value`. Les variables `value`, `path` et `el` sont disponibles. |\n| `value => value + 1` | Une fonction fléchée. |\n| `common.format` | Le path d'une fonction appelée avec `value`, `path` et `el`. |\n| `?/format` | Une méthode du plugin du scope le plus proche. |\n\nLes préfixes et séparateurs sont :\n\n| Syntaxe | Signification |\n| --- | --- |\n| `command selector:expression` | Exécute la commande sur les descendants qui correspondent au sélecteur. |\n| `text+title:value` | Exécute une seule expression pour plusieurs commandes. |\n| `!command` | Ignore la commande tant que la valeur est `null` ou `undefined`. Sur l'élément lui-même, `text`, `html`, `title`, `value`, `src`, `checked`, `disabled` et `enabled` reviennent alors à leur contenu d'origine. |\n| `~command` | Exécute la commande même quand l'élément est masqué par `show`, `hide`, `visible` ou `invisible`. |\n\nExample: Formes d'expression\n```html\n<ui-bind path=\"form.name\" config=\"text b:value.length;title:n => n + '!';.long:common.long\">\n    <b></b>\n</ui-bind>\n<script>\n    window.common = { long: value => value.length > 3 };\n    SET('form.name', 'Peter');\n</script>\n```\n\nExample: Une expression pour deux commandes\n```html\n<ui-bind path=\"form.name\" config=\"text+title:value\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\nExample: Restaurer le contenu d'origine\n```html\n<ui-bind path=\"form.name\" config=\"!text\">Anonymous</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', null), 500);\n</script>\n```\n\nExample: Mettre à jour un élément masqué\n```html\n<ui-bind path=\"form.name\" config=\"~text;hide:value\">Anonymous</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### text[:expression]\n\nType: `command`\n\nDéfinit le contenu textuel.\n\nLa valeur est échappée. Les commandes [`format`](#format), [`currency`](#currency), [`helper`](#helper) et [`empty`](#empty) modifient la sortie.\n\nExample: Utiliser text\n```html\n<ui-bind path=\"form.name\" config=\"text\"></ui-bind>\n<script>SET('form.name', '<b>Peter</b>');</script>\n```\n\n### html[:expression]\n\nType: `command`\n\nDéfinit le contenu HTML.\n\nLa valeur n'est pas échappée.\n\nExample: Utiliser html\n```html\n<ui-bind path=\"form.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### value[:expression]\n\nType: `command`\n\nDéfinit la valeur d'un champ de formulaire.\n\nLe nom court `val` fonctionne aussi.\n\nExample: Utiliser value\n```html\n<ui-bind path=\"form.name\" config=\"value input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('input').val()), 500);  // Peter\n</script>\n```\n\n### title[:expression]\n\nType: `command`\n\nDéfinit l'attribut `title`.\n\nExample: Utiliser title\n```html\n<ui-bind path=\"form.name\" config=\"title\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### href[:expression]\n\nType: `command`\n\nDéfinit l'attribut `href`.\n\nExample: Utiliser href\n```html\n<ui-bind path=\"form.id\" config=\"href a:'/users/' + value + '/'\">\n    <a>Detail</a>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### src[:expression]\n\nType: `command`\n\nDéfinit l'attribut `src`.\n\nExample: Utiliser src\n```html\n<ui-bind path=\"form.photo\" config=\"src img\">\n    <img />\n</ui-bind>\n<script>SET('form.photo', 'data:,');</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nDéfinit n'importe quel attribut.\n\nLe nom de l'attribut suit la commande. Un sélecteur peut suivre le nom.\n\nExample: Utiliser attr\n```html\n<ui-bind path=\"form.id\" config=\"attr data-id:value;attr data-ref b:value\">\n    <b></b>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### .classname[ selector]:expression\n\nType: `command`\n\nBascule une classe CSS selon le résultat de l'expression.\n\nÉcris le nom de la classe après le point.\n\nExample: Basculer des classes\n```html\n<ui-bind path=\"form.age\" config=\".adult:value >= 18;.minor:value < 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### class:classes\n\nType: `command`\n\nBascule des classes CSS une seule fois, après la première mise à jour.\n\nSépare plusieurs classes par un espace.\n\nExample: Utiliser class\n```html\n<ui-bind path=\"form.name\" config=\"class:ready\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### show[:expression]\n\nType: `command`\n\nAffiche l'élément quand l'expression est vraie.\n\nSinon, l'élément reçoit la classe `hidden`. Tant qu'il est masqué, les commandes qui suivent sont ignorées, sauf si elles ont le préfixe `~`.\n\nExample: Utiliser show\n```html\n<ui-bind path=\"form.age\" config=\"show:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### hide[:expression]\n\nType: `command`\n\nMasque l'élément quand l'expression est vraie.\n\nL'élément reçoit la classe `hidden`. Le nom `hidden` fonctionne aussi.\n\nExample: Utiliser hide\n```html\n<ui-bind path=\"form.age\" config=\"hide:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### visible[:expression]\n\nType: `command`\n\nConserve l'espace occupé dans la mise en page quand l'expression est fausse.\n\nL'élément reçoit la classe `invisible` quand l'expression est fausse.\n\nExample: Utiliser visible\n```html\n<ui-bind path=\"form.age\" config=\"visible:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### invisible[:expression]\n\nType: `command`\n\nAjoute la classe `invisible` quand l'expression est vraie.\n\nExample: Utiliser invisible\n```html\n<ui-bind path=\"form.age\" config=\"invisible:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### checked[:expression]\n\nType: `command`\n\nDéfinit la propriété `checked` d'un champ.\n\nExample: Utiliser checked\n```html\n<ui-bind path=\"form.active\" config=\"checked input\">\n    <input type=\"checkbox\" />\n</ui-bind>\n<script>\n    SET('form.active', true);\n    setTimeout(() => console.log($('input').prop('checked')), 500);  // true\n</script>\n```\n\n### disabled[:expression]\n\nType: `command`\n\nDésactive les champs et les composants quand l'expression est vraie.\n\nLe nom court `disable` fonctionne aussi. Sans sélecteur, la commande s'applique à `ui-component`, `input`, `textarea`, `select` et `button` à l'intérieur de l'élément. Les composants reçoivent la clé de configuration `disabled`.\n\nExample: Utiliser disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.locked', true);</script>\n```\n\n### enabled[:expression]\n\nType: `command`\n\nActive les champs et les composants quand l'expression est vraie.\n\nLe nom court `enable` fonctionne aussi. Le sélecteur par défaut est le même que pour [`disabled`](#disabled).\n\nExample: Utiliser enabled\n```html\n<ui-bind path=\"form.valid\" config=\"enabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.valid', false);</script>\n```\n\n### required selector:expression\n\nType: `command`\n\nDéfinit la clé de configuration `required` d'un composant.\n\nAjoute un sélecteur, car la commande n'en a aucun par défaut.\n\nExample: Utiliser required\n```html\n<ui-bind path=\"form.strict\" config=\"required ui-component:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'required' && console.log(value);  // true\n    });\n    SET('form.strict', true);\n</script>\n```\n\n### config:expression\n\nType: `command`\n\nReconfigure les composants avec le résultat de l'expression.\n\nLe sélecteur par défaut est `ui-component`.\n\nExample: Utiliser config\n```html\n<ui-bind path=\"form.title\" config=\"config:'title:' + value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'title' && console.log(value);  // Orders\n    });\n    SET('form.title', 'Orders');\n</script>\n```\n\n### set[:expression]\n\nType: `command`\n\nPasse le résultat de l'expression au `setter` d'un composant sans path.\n\nLe sélecteur par défaut est `ui-component`. Le composant peut réécrire dans le même path.\n\nExample: Utiliser set\n```html\n<ui-bind path=\"form.name\" config=\"set:value + '!'\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = value => self.text(value);\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### setter:'selector/method',value\n\nType: `command`\n\nAppelle une méthode des composants correspondants.\n\nL'expression contient les arguments de `SETTER()`, évalués avec `value`, `path` et `el`.\n\nExample: Utiliser setter\n```html\n<ui-bind path=\"form.name\" config=\"setter:'box/show',value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.show = value => value && console.log(value);  // Peter\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### template [selector][:selector-->attribute]\n\nType: `command`\n\nEffectue le rendu d'un modèle Tangular.\n\nLe modèle est le premier `<script>` ou `<template>` à l'intérieur de l'élément. Le modèle de données a les propriétés `value` et `path`.\n\nLa forme facultative `template:selector-->attribute` ne met à jour que les éléments enfants modifiés. Le sélecteur trouve les éléments et l'attribut les identifie. Pour en savoir plus, lis [Modèles avec Tangular](../../guides/tangular/).\n\nExample: Utiliser template\n```html\n<ui-bind path=\"form.items\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<li>{{ m }}</li>{{ end }}\n    </script>\n</ui-bind>\n<script>SET('form.items', ['A', 'B']);</script>\n```\n\n### helpers:path\n\nType: `command`\n\nPasse des helpers Tangular au modèle.\n\nLa valeur est un path vers un objet contenant des helpers, ou vers une fonction qui en renvoie un.\n\nExample: Utiliser helpers\n```html\n<ui-bind path=\"form.name\" config=\"template;helpers:common.helpers\">\n    <script type=\"text/html\">{{ value | shout }}</script>\n</ui-bind>\n<script>\n    window.common = { helpers: { shout: value => value + '!' } };\n    SET('form.name', 'Peter');\n</script>\n```\n\n### vbindarray\n\nType: `command`\n\nEffectue le rendu d'un tableau avec un binder virtuel par élément.\n\nLe modèle est le premier `<script>` ou `<template>` à l'intérieur de l'élément. Les paths à l'intérieur du modèle commencent par un point. Consulte [Binder virtuel](../vbinder/).\n\nExample: Utiliser vbindarray\n```html\n<ui-bind path=\"form.users\" config=\"vbindarray\">\n    <script type=\"text/html\">\n        <div><ui-bind path=\".name\" config=\"text\"></ui-bind></div>\n    </script>\n</ui-bind>\n<script>SET('form.users', [{ name: 'Peter' }, { name: 'Anna' }]);</script>\n```\n\n### import:url\n\nType: `command`\n\nCharge du contenu dans l'élément.\n\nLa valeur est l'une des suivantes :\n\n| Valeur | Signification |\n| --- | --- |\n| Une URL qui commence par `/`, `http://` ou `https://` | Importe l'URL une seule fois. |\n| `value` ou `true` | Déplace le premier `<script>` ou `<template>` interne dans le DOM. |\n| Une expression | Importe l'URL renvoyée par la valeur du path, une fois par URL. |\n\nL'importation attend que l'élément soit visible, tu peux donc la combiner avec [`show`](#show).\n\nExample: Insérer un modèle quand l'élément est affiché\n```html\n<ui-bind path=\"form.open\" config=\"show;import:value\">\n    <script type=\"text/html\"><b>Loaded</b></script>\n</ui-bind>\n<script>\n    setTimeout(() => SET('form.open', true), 500);\n</script>\n```\n\n### macro:name1,name2\n\nType: `command`\n\nAttache des macros à l'élément.\n\nSépare plusieurs noms par une virgule. Consulte [Macro](../macro/).\n\nExample: Utiliser macro\n```html\n<ui-bind path=\"form.name\" config=\"macro:shout\"></ui-bind>\n<script>\n    MACRO('shout', function(self) {\n        self.setter = value => self.text(value + '!');\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nAppelle une fonction à chaque mise à jour.\n\nLa fonction reçoit `value`, `path` et `el`, et `this` est l'élément. Elle reçoit toujours la valeur brute. Le nom `change` fonctionne aussi.\n\nExample: Utiliser exec\n```html\n<ui-bind path=\"form.name\" config=\"exec:common.onchange\"></ui-bind>\n<script>\n    window.common = { onchange: (value, path) => value && console.log(value, path) };  // Peter form.name\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### init:path\n\nType: `command`\n\nAppelle une fonction au début de chaque mise à jour.\n\nLa fonction reçoit `value`, `path` et `el`.\n\nExample: Utiliser init\n```html\n<ui-bind path=\"form.name\" config=\"init:common.oninit\"></ui-bind>\n<script>\n    window.common = { oninit: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nAppelle une fonction à chaque mise à jour tant que l'élément est visible.\n\nLa fonction reçoit `value`, `path` et `el`.\n\nExample: Utiliser refresh\n```html\n<ui-bind path=\"form.name\" config=\"refresh:common.onrefresh\"></ui-bind>\n<script>\n    window.common = { onrefresh: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### click [selector]:path\n\nType: `command`\n\nAppelle une fonction quand on clique sur l'élément.\n\nLa fonction reçoit l'élément jQuery, l'événement, la valeur actuelle et le path. Un sélecteur délègue le clic aux descendants correspondants. Les champs et les boutons désactivés sont ignorés.\n\nExample: Utiliser click\n```html\n<ui-bind path=\"form.name\" config=\"click button:common.onclick\">\n    <button>Save</button>\n</ui-bind>\n<script>\n    window.common = {\n        onclick: (element, event, value, path) => console.log(element.text(), value, path)  // Save Peter form.name\n    };\n    SET('form.name', 'Peter');\n    setTimeout(() => $('button').click(), 500);\n</script>\n```\n\n### format:format\n\nType: `command`\n\nFormate un nombre ou une date.\n\nUn nombre définit les décimales. Tout autre texte est un format de date.\n\nExample: Utiliser format\n```html\n<ui-bind path=\"form.price\" config=\"text;format:2\"></ui-bind>\n<script>SET('form.price', 1250);</script>\n```\n\n### currency:name\n\nType: `command`\n\nFormate un nombre avec une devise.\n\nLe nom fait référence à une fonction de `DEF.currencies`.\n\nExample: Utiliser currency\n```html\n<ui-bind path=\"form.price\" config=\"text;currency:eur\"></ui-bind>\n<script>\n    DEF.currencies.eur = value => value.format(2) + ' EUR';\n    SET('form.price', 1250);\n</script>\n```\n\n### helper:name[(arguments)]\n\nType: `command`\n\nTransforme la sortie avec un helper Tangular.\n\nLa valeur est passée comme premier argument du helper. Tu peux écrire d'autres arguments entre parenthèses.\n\nExample: Utiliser helper\n```html\n<ui-bind path=\"form.name\" config=\"text;helper:wrap('*')\"></ui-bind>\n<script>\n    Thelpers.wrap = (value, chars) => chars + value + chars;\n    SET('form.name', 'Peter');\n</script>\n```\n\n### empty[:text]\n\nType: `command`\n\nDéfinit le texte utilisé pour une valeur vide.\n\nSans valeur, la commande utilise `DEF.empty`, qui vaut `---`.\n\nExample: Utiliser empty\n```html\n<ui-bind path=\"form.name\" config=\"text;empty:Nothing\"></ui-bind>\n```\n\n### default:expression\n\nType: `command`\n\nRemplace `null` et `undefined` par une valeur.\n\nLa valeur est une expression JavaScript. Le nom court `def` fonctionne aussi.\n\nExample: Utiliser default\n```html\n<ui-bind path=\"form.name\" config=\"text;default:'Anonymous'\"></ui-bind>\n```\n\n### selector:selector\n\nType: `command`\n\nApplique toutes les commandes aux descendants correspondants.\n\nExample: Utiliser selector\n```html\n<ui-bind path=\"form.name\" config=\"selector:b;text\">\n    <b></b><b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### assign:path\n\nType: `command`\n\nÉcrit l'élément jQuery dans un path.\n\nExample: Utiliser assign\n```html\n<ui-bind id=\"box\" path=\"form.name\" config=\"assign:common.box;text\"></ui-bind>\n<script>\n    setTimeout(() => console.log(GET('common.box').attr('id')), 500);  // box\n</script>\n```\n\n### check:path\n\nType: `command`\n\nExécute les commandes uniquement quand une condition est remplie.\n\nLa valeur est un path vers une valeur vraie, ou `plugin/method`, qui reçoit `value`, `path` et `el`.\n\nExample: Utiliser check\n```html\n<ui-bind path=\"form.name\" config=\"check:form.ready;text\">Waiting</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nRetarde la mise à jour, en millisecondes.\n\nLes mises à jour répétées pendant le délai ne s'exécutent qu'une fois.\n\nExample: Utiliser delay\n```html\n<ui-bind path=\"form.name\" config=\"delay:500;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('ui-bind').text() || 'empty'), 200);  // empty\n    setTimeout(() => console.log($('ui-bind').text()), 1100);  // Peter\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnore les modifications des paths imbriqués.\n\nLes commandes ne s'exécutent que lorsque le path lui-même ou l'un de ses parents change.\n\nExample: Utiliser strict\n```html\n<ui-bind path=\"form.user\" config=\"strict;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter' });\n    setTimeout(() => SET('form.user.name', 'Anna'), 500);\n</script>\n```\n\n### track:field1,field2\n\nType: `command`\n\nExécute les commandes uniquement pour certains champs imbriqués.\n\nSépare plusieurs champs par une virgule.\n\nExample: Utiliser track\n```html\n<ui-bind path=\"form.user\" config=\"track:name;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter', age: 20 });\n    setTimeout(() => SET('form.user.age', 21), 500);\n    setTimeout(() => SET('form.user.name', 'Anna'), 700);\n</script>\n```\n\n### tracktype:type1,type2\n\nType: `command`\n\nExécute les commandes uniquement pour certains types de mise à jour.\n\nSépare plusieurs types par une virgule.\n\nExample: Utiliser tracktype\n```html\n<ui-bind path=\"form.age\" config=\"tracktype:2;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10, 1), 500);\n    setTimeout(() => SET('form.age', 20, 2), 700);\n</script>\n```\n\n### changes\n\nType: `command`\n\nIgnore les commandes quand la valeur n'a pas changé.\n\nLa valeur est comparée à l'aide d'un hash.\n\nExample: Utiliser changes\n```html\n<ui-bind path=\"form.age\" config=\"changes;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10), 500);\n    setTimeout(() => UPD('form.age'), 700);\n</script>\n```\n\n### ready\n\nType: `command`\n\nAttend les composants imbriqués dans l'élément.\n\nLes commandes s'exécutent quand tous les composants imbriqués sont prêts.\n\nExample: Utiliser ready\n```html\n<ui-bind path=\"form.name\" config=\"ready;exec:common.update\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    window.common = { update: () => console.log(FIND('box') ? 'found' : 'missing') };  // found\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### once\n\nType: `command`\n\nExécute les commandes une seule fois.\n\nExample: Utiliser once\n```html\n<ui-bind path=\"form.name\" config=\"once;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', 'Anna'), 700);\n</script>\n```\n\n### focus:selector\n\nType: `command`\n\nDéplace le focus vers un champ après chaque mise à jour.\n\nLa valeur est un sélecteur de descendants.\n\nExample: Donner le focus à un champ\n```html\n<ui-bind path=\"form.name\" config=\"focus:input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n</script>\n```\n\n### resize\n\nType: `command`\n\nAppelle la méthode `resize` des composants imbriqués après chaque mise à jour.\n\nExample: Utiliser resize\n```html\n<ui-bind path=\"form.name\" config=\"resize\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.resize = () => console.log('resized');  // resized\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### binder.refresh()\n\nType: `method`\n\nExécute de nouveau les commandes avec la valeur actuelle du path.\n\nLe binder est disponible via `element.ui` ou `$(element).binder()`.\n\nExample: Rafraîchir un binder\n```js\nvar binder = $('ui-bind').binder();\nwindow.form.name = 'Anna';\nbinder.refresh();\nconsole.log($('ui-bind').text());  // Anna\n```\n\n### binder.exec(value, path)\n\nType: `method`\n\nExécute les commandes avec une valeur personnalisée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur passée aux commandes. |\n| `path` | `String` | yes |  | Le path passé aux commandes. |\n\nLa valeur n'est pas écrite dans le modèle de données.\n\nExample: Exécuter les commandes avec une valeur\n```js\nvar binder = $('ui-bind').binder();\nbinder.exec('Preview', 'form.name');\nconsole.log($('ui-bind').text(), GET('form.name'));  // Preview Peter\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"command:expression;command:expression\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"type","name":"Command syntax","signature":"[!~]command [selector]: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[: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":".class","signature":".classname[ selector]:expression","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:classes","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":"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 selector:expression","since":"","deprecated":false},{"type":"command","name":"config","signature":"config:expression","since":"","deprecated":false},{"type":"command","name":"set","signature":"set[:expression]","since":"","deprecated":false},{"type":"command","name":"setter","signature":"setter:'selector/method',value","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":"vbindarray","signature":"vbindarray","since":"","deprecated":false},{"type":"command","name":"import","signature":"import:url","since":"","deprecated":false},{"type":"command","name":"macro","signature":"macro:name1,name2","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"click","signature":"click [selector]:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:format","since":"","deprecated":false},{"type":"command","name":"currency","signature":"currency:name","since":"","deprecated":false},{"type":"command","name":"helper","signature":"helper:name[(arguments)]","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty[:text]","since":"","deprecated":false},{"type":"command","name":"default","signature":"default:expression","since":"","deprecated":false},{"type":"command","name":"selector","signature":"selector:selector","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:field1,field2","since":"","deprecated":false},{"type":"command","name":"tracktype","signature":"tracktype:type1,type2","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"resize","signature":"resize","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"binder.refresh()","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"binder.exec(value, path)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammk9C2j61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-bind/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"ui-bind","summary":"Gli attributi e i comandi dell'elemento ui-bind e l'oggetto binder che crea.","markdown":"---\ntitle: ui-bind\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-bind/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# ui-bind\n\n> Gli attributi e i comandi dell'elemento ui-bind e l'oggetto binder che crea.\n\nL'elemento `<ui-bind>` osserva un path e aggiorna il DOM quando il valore cambia. Il suo attributo `config` contiene un elenco di comandi. [Associazione dei dati](../../guides/data-binding/) spiega il concetto.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nImposta il path osservato dall'elemento.\n\nL'attributo accetta queste forme:\n\n| Valore | Significato |\n| --- | --- |\n| `form.name` | Un path assoluto. |\n| `!form.name` | I comandi vengono saltati finché il valore è `null` o `undefined`. |\n| `?.name` | Un path relativo al [`ui-plugin`](../ui-plugin/) più vicino. |\n| `*name` | Un path dentro `DEF.pathcommon`. |\n| `%name` | Un path temporaneo. |\n| `@key` | Un valore memorizzato con [`data()`](../component/#data) del componente padre. `@` da solo è il valore di quel componente e `@config.key` è una chiave di configurazione. |\n| `.name` | Un path dentro il modello di un [binder virtuale](../vbinder/). `.` da solo è l'intero modello. |\n| `form.name --> expression` | Trasforma il valore con un'espressione che riceve `value`. |\n\nQuando l'elemento ha un path e nessun `config`, il path deve contenere una funzione, che viene chiamata con l'elemento.\n\nExample: Saltare i valori vuoti\n```html\n<ui-bind path=\"!form.name\" config=\"text\">Waiting</ui-bind>\n```\n\nExample: Trasformare il valore\n```html\n<ui-bind path=\"form.name --> value.toUpperCase()\" config=\"text\"></ui-bind>\n<script>SET('form.name', 'peter');</script>\n```\n\nExample: Leggere i dati del componente padre\n```html\n<ui-component name=\"card\" config=\"title:Orders\">\n    <ui-bind path=\"@config.title\" config=\"text\"></ui-bind>\n</ui-component>\n<script>COMPONENT('card', function(self) {});</script>\n```\n\nExample: Chiamare una funzione con l'elemento\n```html\n<ui-bind path=\"common.init\" id=\"box\"></ui-bind>\n<script>\n    window.common = { init: element => console.log(element.attr('id')) };  // box\n</script>\n```\n\n### config=\"command:expression;command:expression\"\n\nType: `property`\n\nContiene i comandi dell'elemento.\n\nI comandi sono separati da un punto e virgola. Ogni comando ha la forma `name:expression`. Vedi [Sintassi dei comandi](#command-syntax).\n\nExample: Due comandi\n```html\n<ui-bind path=\"form.age\" config=\"text:value + ' years';.adult:value >= 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### element=\"selector\"\n\nType: `property`\n\nApplica i comandi a un altro elemento.\n\nIl valore è un selettore jQuery valutato sull'intero documento.\n\nExample: Aggiornare un elemento altrove\n```html\n<ui-bind path=\"form.name\" element=\"#target\" config=\"text\"></ui-bind>\n<div id=\"target\"></div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nApplica i comandi al genitore corrispondente più vicino.\n\nIl valore è un selettore jQuery passato a `closest()`.\n\nExample: Aggiornare un elemento genitore\n```html\n<div class=\"row\">\n    <ui-bind path=\"form.name\" parent=\".row\" config=\"title:value\"></ui-bind>\n</div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nApplica i comandi al primo discendente corrispondente.\n\nPuoi combinare l'attributo con [`parent`](#parent).\n\nExample: Aggiornare un elemento figlio\n```html\n<ui-bind path=\"form.name\" child=\"b\" config=\"text\">\n    <b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea uno scope direttamente sull'elemento.\n\nIl valore è il path dello scope.\n\nExample: Uno scope sull'elemento\n```html\n<ui-bind plugin=\"users\" path=\"?.name\" config=\"text\"></ui-bind>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.set('name', 'Peter');\n    });\n</script>\n```\n\n### [!~]command [selector]:expression\n\nType: `type`\n\nUn comando è un nome seguito da un'espressione facoltativa.\n\nL'espressione può avere queste forme:\n\n| Forma | Significato |\n| --- | --- |\n| omessa | Il valore stesso, come in `text`. |\n| `value + 1` | Un'espressione JavaScript che contiene la parola `value`. Sono disponibili le variabili `value`, `path` e `el`. |\n| `value => value + 1` | Una arrow function. |\n| `common.format` | Il path di una funzione chiamata con `value`, `path` e `el`. |\n| `?/format` | Un metodo del plugin dello scope più vicino. |\n\nI prefissi e i separatori sono:\n\n| Sintassi | Significato |\n| --- | --- |\n| `command selector:expression` | Esegue il comando sui discendenti che corrispondono al selettore. |\n| `text+title:value` | Esegue una sola espressione per più comandi. |\n| `!command` | Salta il comando finché il valore è `null` o `undefined`. Sull'elemento stesso, `text`, `html`, `title`, `value`, `src`, `checked`, `disabled` e `enabled` tornano allora al contenuto originale. |\n| `~command` | Esegue il comando anche mentre l'elemento è nascosto da `show`, `hide`, `visible` o `invisible`. |\n\nExample: Forme dell'espressione\n```html\n<ui-bind path=\"form.name\" config=\"text b:value.length;title:n => n + '!';.long:common.long\">\n    <b></b>\n</ui-bind>\n<script>\n    window.common = { long: value => value.length > 3 };\n    SET('form.name', 'Peter');\n</script>\n```\n\nExample: Una sola espressione per due comandi\n```html\n<ui-bind path=\"form.name\" config=\"text+title:value\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\nExample: Ripristinare il contenuto originale\n```html\n<ui-bind path=\"form.name\" config=\"!text\">Anonymous</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', null), 500);\n</script>\n```\n\nExample: Aggiornare un elemento nascosto\n```html\n<ui-bind path=\"form.name\" config=\"~text;hide:value\">Anonymous</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### text[:expression]\n\nType: `command`\n\nImposta il contenuto testuale.\n\nIl valore viene codificato. I comandi [`format`](#format), [`currency`](#currency), [`helper`](#helper) ed [`empty`](#empty) modificano l'output.\n\nExample: Uso di text\n```html\n<ui-bind path=\"form.name\" config=\"text\"></ui-bind>\n<script>SET('form.name', '<b>Peter</b>');</script>\n```\n\n### html[:expression]\n\nType: `command`\n\nImposta il contenuto HTML.\n\nIl valore non viene codificato.\n\nExample: Uso di html\n```html\n<ui-bind path=\"form.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### value[:expression]\n\nType: `command`\n\nImposta il valore di un campo del form.\n\nFunziona anche il nome breve `val`.\n\nExample: Uso di value\n```html\n<ui-bind path=\"form.name\" config=\"value input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('input').val()), 500);  // Peter\n</script>\n```\n\n### title[:expression]\n\nType: `command`\n\nImposta l'attributo `title`.\n\nExample: Uso di title\n```html\n<ui-bind path=\"form.name\" config=\"title\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### href[:expression]\n\nType: `command`\n\nImposta l'attributo `href`.\n\nExample: Uso di href\n```html\n<ui-bind path=\"form.id\" config=\"href a:'/users/' + value + '/'\">\n    <a>Detail</a>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### src[:expression]\n\nType: `command`\n\nImposta l'attributo `src`.\n\nExample: Uso di src\n```html\n<ui-bind path=\"form.photo\" config=\"src img\">\n    <img />\n</ui-bind>\n<script>SET('form.photo', 'data:,');</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nImposta un attributo qualsiasi.\n\nIl nome dell'attributo segue il comando. Dopo il nome può esserci un selettore.\n\nExample: Uso di attr\n```html\n<ui-bind path=\"form.id\" config=\"attr data-id:value;attr data-ref b:value\">\n    <b></b>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### .classname[ selector]:expression\n\nType: `command`\n\nAttiva o disattiva una classe CSS in base al risultato dell'espressione.\n\nScrivi il nome della classe dopo il punto.\n\nExample: Attivare e disattivare le classi\n```html\n<ui-bind path=\"form.age\" config=\".adult:value >= 18;.minor:value < 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### class:classes\n\nType: `command`\n\nAttiva o disattiva le classi CSS una sola volta, dopo il primo aggiornamento.\n\nSepara più classi con uno spazio.\n\nExample: Uso di class\n```html\n<ui-bind path=\"form.name\" config=\"class:ready\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### show[:expression]\n\nType: `command`\n\nMostra l'elemento quando l'espressione è truthy.\n\nAltrimenti l'elemento riceve la classe `hidden`. Finché è nascosto, i comandi successivi vengono saltati, a meno che non abbiano il prefisso `~`.\n\nExample: Uso di show\n```html\n<ui-bind path=\"form.age\" config=\"show:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### hide[:expression]\n\nType: `command`\n\nNasconde l'elemento quando l'espressione è truthy.\n\nL'elemento riceve la classe `hidden`. Funziona anche il nome `hidden`.\n\nExample: Uso di hide\n```html\n<ui-bind path=\"form.age\" config=\"hide:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### visible[:expression]\n\nType: `command`\n\nMantiene lo spazio nel layout quando l'espressione è falsy.\n\nL'elemento riceve la classe `invisible` quando l'espressione è falsy.\n\nExample: Uso di visible\n```html\n<ui-bind path=\"form.age\" config=\"visible:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### invisible[:expression]\n\nType: `command`\n\nAggiunge la classe `invisible` quando l'espressione è truthy.\n\nExample: Uso di invisible\n```html\n<ui-bind path=\"form.age\" config=\"invisible:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### checked[:expression]\n\nType: `command`\n\nImposta la proprietà `checked` di un campo.\n\nExample: Uso di checked\n```html\n<ui-bind path=\"form.active\" config=\"checked input\">\n    <input type=\"checkbox\" />\n</ui-bind>\n<script>\n    SET('form.active', true);\n    setTimeout(() => console.log($('input').prop('checked')), 500);  // true\n</script>\n```\n\n### disabled[:expression]\n\nType: `command`\n\nDisabilita campi e componenti quando l'espressione è truthy.\n\nFunziona anche il nome breve `disable`. Senza selettore, il comando si applica a `ui-component`, `input`, `textarea`, `select` e `button` dentro l'elemento. I componenti ricevono la chiave di configurazione `disabled`.\n\nExample: Uso di disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.locked', true);</script>\n```\n\n### enabled[:expression]\n\nType: `command`\n\nAbilita campi e componenti quando l'espressione è truthy.\n\nFunziona anche il nome breve `enable`. Il selettore predefinito è lo stesso di [`disabled`](#disabled).\n\nExample: Uso di enabled\n```html\n<ui-bind path=\"form.valid\" config=\"enabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.valid', false);</script>\n```\n\n### required selector:expression\n\nType: `command`\n\nImposta la chiave di configurazione `required` di un componente.\n\nAggiungi un selettore, perché il comando non ne ha uno predefinito.\n\nExample: Uso di required\n```html\n<ui-bind path=\"form.strict\" config=\"required ui-component:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'required' && console.log(value);  // true\n    });\n    SET('form.strict', true);\n</script>\n```\n\n### config:expression\n\nType: `command`\n\nRiconfigura i componenti con il risultato dell'espressione.\n\nIl selettore predefinito è `ui-component`.\n\nExample: Uso di config\n```html\n<ui-bind path=\"form.title\" config=\"config:'title:' + value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'title' && console.log(value);  // Orders\n    });\n    SET('form.title', 'Orders');\n</script>\n```\n\n### set[:expression]\n\nType: `command`\n\nPassa il risultato dell'espressione al `setter` di un componente senza path.\n\nIl selettore predefinito è `ui-component`. Il componente può riscrivere sullo stesso path.\n\nExample: Uso di set\n```html\n<ui-bind path=\"form.name\" config=\"set:value + '!'\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = value => self.text(value);\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### setter:'selector/method',value\n\nType: `command`\n\nChiama un metodo dei componenti corrispondenti.\n\nL'espressione contiene gli argomenti di `SETTER()`, valutati con `value`, `path` e `el`.\n\nExample: Uso di setter\n```html\n<ui-bind path=\"form.name\" config=\"setter:'box/show',value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.show = value => value && console.log(value);  // Peter\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### template [selector][:selector-->attribute]\n\nType: `command`\n\nEsegue il rendering di un template Tangular.\n\nIl template è il primo `<script>` o `<template>` dentro l'elemento. Il modello ha le proprietà `value` e `path`.\n\nLa forma facoltativa `template:selector-->attribute` aggiorna solo gli elementi figli modificati. Il selettore trova gli elementi e l'attributo li identifica. Approfondisci in [Template con Tangular](../../guides/tangular/).\n\nExample: Uso di template\n```html\n<ui-bind path=\"form.items\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<li>{{ m }}</li>{{ end }}\n    </script>\n</ui-bind>\n<script>SET('form.items', ['A', 'B']);</script>\n```\n\n### helpers:path\n\nType: `command`\n\nPassa gli helper di Tangular al template.\n\nIl valore è un path verso un oggetto con gli helper o verso una funzione che ne restituisce uno.\n\nExample: Uso di helpers\n```html\n<ui-bind path=\"form.name\" config=\"template;helpers:common.helpers\">\n    <script type=\"text/html\">{{ value | shout }}</script>\n</ui-bind>\n<script>\n    window.common = { helpers: { shout: value => value + '!' } };\n    SET('form.name', 'Peter');\n</script>\n```\n\n### vbindarray\n\nType: `command`\n\nEsegue il rendering di un array con un binder virtuale per ogni elemento.\n\nIl template è il primo `<script>` o `<template>` dentro l'elemento. I path dentro il template iniziano con un punto. Vedi [Binder virtuale](../vbinder/).\n\nExample: Uso di vbindarray\n```html\n<ui-bind path=\"form.users\" config=\"vbindarray\">\n    <script type=\"text/html\">\n        <div><ui-bind path=\".name\" config=\"text\"></ui-bind></div>\n    </script>\n</ui-bind>\n<script>SET('form.users', [{ name: 'Peter' }, { name: 'Anna' }]);</script>\n```\n\n### import:url\n\nType: `command`\n\nCarica contenuto nell'elemento.\n\nIl valore è uno di questi:\n\n| Valore | Significato |\n| --- | --- |\n| Un URL che inizia con `/`, `http://` o `https://` | Importa l'URL una sola volta. |\n| `value` o `true` | Sposta nel DOM il primo `<script>` o `<template>` interno. |\n| Un'espressione | Importa l'URL restituito dal valore del path, una volta per ogni URL. |\n\nL'importazione attende che l'elemento sia visibile, quindi puoi combinarla con [`show`](#show).\n\nExample: Inserire un template quando l'elemento viene mostrato\n```html\n<ui-bind path=\"form.open\" config=\"show;import:value\">\n    <script type=\"text/html\"><b>Loaded</b></script>\n</ui-bind>\n<script>\n    setTimeout(() => SET('form.open', true), 500);\n</script>\n```\n\n### macro:name1,name2\n\nType: `command`\n\nCollega le macro all'elemento.\n\nSepara più nomi con una virgola. Vedi [Macro](../macro/).\n\nExample: Uso di macro\n```html\n<ui-bind path=\"form.name\" config=\"macro:shout\"></ui-bind>\n<script>\n    MACRO('shout', function(self) {\n        self.setter = value => self.text(value + '!');\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nChiama una funzione a ogni aggiornamento.\n\nLa funzione riceve `value`, `path` ed `el`, e `this` è l'elemento. Riceve sempre il valore grezzo. Funziona anche il nome `change`.\n\nExample: Uso di exec\n```html\n<ui-bind path=\"form.name\" config=\"exec:common.onchange\"></ui-bind>\n<script>\n    window.common = { onchange: (value, path) => value && console.log(value, path) };  // Peter form.name\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### init:path\n\nType: `command`\n\nChiama una funzione all'inizio di ogni aggiornamento.\n\nLa funzione riceve `value`, `path` ed `el`.\n\nExample: Uso di init\n```html\n<ui-bind path=\"form.name\" config=\"init:common.oninit\"></ui-bind>\n<script>\n    window.common = { oninit: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nChiama una funzione a ogni aggiornamento mentre l'elemento è visibile.\n\nLa funzione riceve `value`, `path` ed `el`.\n\nExample: Uso di refresh\n```html\n<ui-bind path=\"form.name\" config=\"refresh:common.onrefresh\"></ui-bind>\n<script>\n    window.common = { onrefresh: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### click [selector]:path\n\nType: `command`\n\nChiama una funzione quando si fa clic sull'elemento.\n\nLa funzione riceve l'elemento jQuery, l'evento, il valore corrente e il path. Un selettore delega il clic ai discendenti corrispondenti. Gli input e i pulsanti disabilitati vengono ignorati.\n\nExample: Uso di click\n```html\n<ui-bind path=\"form.name\" config=\"click button:common.onclick\">\n    <button>Save</button>\n</ui-bind>\n<script>\n    window.common = {\n        onclick: (element, event, value, path) => console.log(element.text(), value, path)  // Save Peter form.name\n    };\n    SET('form.name', 'Peter');\n    setTimeout(() => $('button').click(), 500);\n</script>\n```\n\n### format:format\n\nType: `command`\n\nFormatta un numero o una data.\n\nUn numero imposta le cifre decimali. Qualsiasi altro testo è un formato di data.\n\nExample: Uso di format\n```html\n<ui-bind path=\"form.price\" config=\"text;format:2\"></ui-bind>\n<script>SET('form.price', 1250);</script>\n```\n\n### currency:name\n\nType: `command`\n\nFormatta un numero con una valuta.\n\nIl nome si riferisce a una funzione in `DEF.currencies`.\n\nExample: Uso di currency\n```html\n<ui-bind path=\"form.price\" config=\"text;currency:eur\"></ui-bind>\n<script>\n    DEF.currencies.eur = value => value.format(2) + ' EUR';\n    SET('form.price', 1250);\n</script>\n```\n\n### helper:name[(arguments)]\n\nType: `command`\n\nTrasforma l'output con un helper di Tangular.\n\nIl valore viene passato come primo argomento dell'helper. Puoi scrivere altri argomenti tra parentesi.\n\nExample: Uso di helper\n```html\n<ui-bind path=\"form.name\" config=\"text;helper:wrap('*')\"></ui-bind>\n<script>\n    Thelpers.wrap = (value, chars) => chars + value + chars;\n    SET('form.name', 'Peter');\n</script>\n```\n\n### empty[:text]\n\nType: `command`\n\nImposta il testo usato per un valore vuoto.\n\nSenza un valore, il comando usa `DEF.empty`, cioè `---`.\n\nExample: Uso di empty\n```html\n<ui-bind path=\"form.name\" config=\"text;empty:Nothing\"></ui-bind>\n```\n\n### default:expression\n\nType: `command`\n\nSostituisce `null` e `undefined` con un valore.\n\nIl valore è un'espressione JavaScript. Funziona anche il nome breve `def`.\n\nExample: Uso di default\n```html\n<ui-bind path=\"form.name\" config=\"text;default:'Anonymous'\"></ui-bind>\n```\n\n### selector:selector\n\nType: `command`\n\nApplica tutti i comandi ai discendenti corrispondenti.\n\nExample: Uso di selector\n```html\n<ui-bind path=\"form.name\" config=\"selector:b;text\">\n    <b></b><b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### assign:path\n\nType: `command`\n\nScrive l'elemento jQuery in un path.\n\nExample: Uso di assign\n```html\n<ui-bind id=\"box\" path=\"form.name\" config=\"assign:common.box;text\"></ui-bind>\n<script>\n    setTimeout(() => console.log(GET('common.box').attr('id')), 500);  // box\n</script>\n```\n\n### check:path\n\nType: `command`\n\nEsegue i comandi solo quando una condizione è soddisfatta.\n\nIl valore è un path verso un valore truthy, oppure `plugin/method`, che riceve `value`, `path` ed `el`.\n\nExample: Uso di check\n```html\n<ui-bind path=\"form.name\" config=\"check:form.ready;text\">Waiting</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nRitarda l'aggiornamento di un certo numero di millisecondi.\n\nGli aggiornamenti ripetuti entro il ritardo vengono eseguiti una sola volta.\n\nExample: Uso di delay\n```html\n<ui-bind path=\"form.name\" config=\"delay:500;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('ui-bind').text() || 'empty'), 200);  // empty\n    setTimeout(() => console.log($('ui-bind').text()), 1100);  // Peter\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnora le modifiche dei path annidati.\n\nI comandi vengono eseguiti solo quando cambia il path stesso o uno dei suoi genitori.\n\nExample: Uso di strict\n```html\n<ui-bind path=\"form.user\" config=\"strict;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter' });\n    setTimeout(() => SET('form.user.name', 'Anna'), 500);\n</script>\n```\n\n### track:field1,field2\n\nType: `command`\n\nEsegue i comandi solo per i campi annidati selezionati.\n\nSepara più campi con una virgola.\n\nExample: Uso di track\n```html\n<ui-bind path=\"form.user\" config=\"track:name;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter', age: 20 });\n    setTimeout(() => SET('form.user.age', 21), 500);\n    setTimeout(() => SET('form.user.name', 'Anna'), 700);\n</script>\n```\n\n### tracktype:type1,type2\n\nType: `command`\n\nEsegue i comandi solo per i tipi di aggiornamento selezionati.\n\nSepara più tipi con una virgola.\n\nExample: Uso di tracktype\n```html\n<ui-bind path=\"form.age\" config=\"tracktype:2;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10, 1), 500);\n    setTimeout(() => SET('form.age', 20, 2), 700);\n</script>\n```\n\n### changes\n\nType: `command`\n\nSalta i comandi quando il valore non è cambiato.\n\nIl valore viene confrontato tramite un hash.\n\nExample: Uso di changes\n```html\n<ui-bind path=\"form.age\" config=\"changes;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10), 500);\n    setTimeout(() => UPD('form.age'), 700);\n</script>\n```\n\n### ready\n\nType: `command`\n\nAttende i componenti annidati nell'elemento.\n\nI comandi vengono eseguiti quando tutti i componenti annidati sono pronti.\n\nExample: Uso di ready\n```html\n<ui-bind path=\"form.name\" config=\"ready;exec:common.update\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    window.common = { update: () => console.log(FIND('box') ? 'found' : 'missing') };  // found\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### once\n\nType: `command`\n\nEsegue i comandi una sola volta.\n\nExample: Uso di once\n```html\n<ui-bind path=\"form.name\" config=\"once;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', 'Anna'), 700);\n</script>\n```\n\n### focus:selector\n\nType: `command`\n\nSposta il focus su un campo dopo ogni aggiornamento.\n\nIl valore è un selettore di discendenti.\n\nExample: Dare il focus a un campo\n```html\n<ui-bind path=\"form.name\" config=\"focus:input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n</script>\n```\n\n### resize\n\nType: `command`\n\nChiama il metodo `resize` dei componenti annidati dopo ogni aggiornamento.\n\nExample: Uso di resize\n```html\n<ui-bind path=\"form.name\" config=\"resize\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.resize = () => console.log('resized');  // resized\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### binder.refresh()\n\nType: `method`\n\nEsegue di nuovo i comandi con il valore corrente del path.\n\nIl binder è disponibile come `element.ui` o tramite `$(element).binder()`.\n\nExample: Aggiornare un binder\n```js\nvar binder = $('ui-bind').binder();\nwindow.form.name = 'Anna';\nbinder.refresh();\nconsole.log($('ui-bind').text());  // Anna\n```\n\n### binder.exec(value, path)\n\nType: `method`\n\nEsegue i comandi con un valore personalizzato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore passato ai comandi. |\n| `path` | `String` | yes |  | Il path passato ai comandi. |\n\nIl valore non viene scritto nel modello dei dati.\n\nExample: Eseguire i comandi con un valore\n```js\nvar binder = $('ui-bind').binder();\nbinder.exec('Preview', 'form.name');\nconsole.log($('ui-bind').text(), GET('form.name'));  // Preview Peter\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"command:expression;command:expression\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"type","name":"Command syntax","signature":"[!~]command [selector]: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[: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":".class","signature":".classname[ selector]:expression","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:classes","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":"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 selector:expression","since":"","deprecated":false},{"type":"command","name":"config","signature":"config:expression","since":"","deprecated":false},{"type":"command","name":"set","signature":"set[:expression]","since":"","deprecated":false},{"type":"command","name":"setter","signature":"setter:'selector/method',value","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":"vbindarray","signature":"vbindarray","since":"","deprecated":false},{"type":"command","name":"import","signature":"import:url","since":"","deprecated":false},{"type":"command","name":"macro","signature":"macro:name1,name2","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"click","signature":"click [selector]:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:format","since":"","deprecated":false},{"type":"command","name":"currency","signature":"currency:name","since":"","deprecated":false},{"type":"command","name":"helper","signature":"helper:name[(arguments)]","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty[:text]","since":"","deprecated":false},{"type":"command","name":"default","signature":"default:expression","since":"","deprecated":false},{"type":"command","name":"selector","signature":"selector:selector","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:field1,field2","since":"","deprecated":false},{"type":"command","name":"tracktype","signature":"tracktype:type1,type2","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"resize","signature":"resize","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"binder.refresh()","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"binder.exec(value, path)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammk9C2j61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-bind/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"ui-bind","summary":"Atribúty a príkazy elementu ui-bind a objekt binder, ktorý vytvára.","markdown":"---\ntitle: ui-bind\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-bind/\nupdated: 2026-11-18T13:58:24.464Z\n---\n\n# ui-bind\n\n> Atribúty a príkazy elementu ui-bind a objekt binder, ktorý vytvára.\n\nElement `<ui-bind>` sleduje path a pri zmene hodnoty aktualizuje DOM. Jeho atribút `config` obsahuje zoznam príkazov. Princíp vysvetľuje časť [Dátová väzba](../../guides/data-binding/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nNastaví path, ktorý element sleduje.\n\nAtribút prijíma tieto tvary:\n\n| Hodnota | Význam |\n| --- | --- |\n| `form.name` | Absolútna path. |\n| `!form.name` | Príkazy sa preskočia, kým je hodnota `null` alebo `undefined`. |\n| `?.name` | Path relatívna k najbližšiemu [`ui-plugin`](../ui-plugin/). |\n| `*name` | Path v rámci `DEF.pathcommon`. |\n| `%name` | Dočasná path. |\n| `@key` | Hodnota uložená pomocou [`data()`](../component/#data) nadradeného komponentu. Samotný `@` je hodnota tohto komponentu a `@config.key` je konfiguračný kľúč. |\n| `.name` | Path v modeli [virtuálneho binderu](../vbinder/). Samotná `.` je celý model. |\n| `form.name --> expression` | Transformuje hodnotu výrazom, ktorý dostane `value`. |\n\nAk má element path a nemá `config`, musí path obsahovať funkciu, ktorá sa zavolá s elementom.\n\nExample: Preskočenie prázdnych hodnôt\n```html\n<ui-bind path=\"!form.name\" config=\"text\">Waiting</ui-bind>\n```\n\nExample: Transformácia hodnoty\n```html\n<ui-bind path=\"form.name --> value.toUpperCase()\" config=\"text\"></ui-bind>\n<script>SET('form.name', 'peter');</script>\n```\n\nExample: Čítanie údajov nadradeného komponentu\n```html\n<ui-component name=\"card\" config=\"title:Orders\">\n    <ui-bind path=\"@config.title\" config=\"text\"></ui-bind>\n</ui-component>\n<script>COMPONENT('card', function(self) {});</script>\n```\n\nExample: Volanie funkcie s elementom\n```html\n<ui-bind path=\"common.init\" id=\"box\"></ui-bind>\n<script>\n    window.common = { init: element => console.log(element.attr('id')) };  // box\n</script>\n```\n\n### config=\"command:expression;command:expression\"\n\nType: `property`\n\nObsahuje príkazy elementu.\n\nPríkazy sa oddeľujú bodkočiarkou. Každý príkaz má tvar `name:expression`. Pozri [Syntax príkazov](#command-syntax).\n\nExample: Dva príkazy\n```html\n<ui-bind path=\"form.age\" config=\"text:value + ' years';.adult:value >= 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### element=\"selector\"\n\nType: `property`\n\nPoužije príkazy na iný element.\n\nHodnota je selektor jQuery, ktorý sa vyhodnotí v celom dokumente.\n\nExample: Aktualizácia elementu na inom mieste\n```html\n<ui-bind path=\"form.name\" element=\"#target\" config=\"text\"></ui-bind>\n<div id=\"target\"></div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nPoužije príkazy na najbližší zodpovedajúci nadradený element.\n\nHodnota je selektor jQuery odovzdaný do `closest()`.\n\nExample: Aktualizácia nadradeného elementu\n```html\n<div class=\"row\">\n    <ui-bind path=\"form.name\" parent=\".row\" config=\"title:value\"></ui-bind>\n</div>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nPoužije príkazy na prvý zodpovedajúci vnorený element.\n\nAtribút môžeš skombinovať s [`parent`](#parent).\n\nExample: Aktualizácia vnoreného elementu\n```html\n<ui-bind path=\"form.name\" child=\"b\" config=\"text\">\n    <b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nVytvorí scope priamo na elemente.\n\nHodnota je path scopu.\n\nExample: Scope na elemente\n```html\n<ui-bind plugin=\"users\" path=\"?.name\" config=\"text\"></ui-bind>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.set('name', 'Peter');\n    });\n</script>\n```\n\n### [!~]command [selector]:expression\n\nType: `type`\n\nPríkaz je názov, za ktorým môže nasledovať výraz.\n\nVýraz môže mať tieto tvary:\n\n| Tvar | Význam |\n| --- | --- |\n| vynechaný | Samotná hodnota, ako v `text`. |\n| `value + 1` | Výraz JavaScriptu, ktorý obsahuje slovo `value`. K dispozícii sú premenné `value`, `path` a `el`. |\n| `value => value + 1` | Šípková funkcia. |\n| `common.format` | Path funkcie, ktorá sa volá s `value`, `path` a `el`. |\n| `?/format` | Metóda pluginu najbližšieho scopu. |\n\nPredpony a oddeľovače sú:\n\n| Syntax | Význam |\n| --- | --- |\n| `command selector:expression` | Spustí príkaz na vnorených elementoch, ktoré zodpovedajú selektoru. |\n| `text+title:value` | Spustí jeden výraz pre viacero príkazov. |\n| `!command` | Preskočí príkaz, kým je hodnota `null` alebo `undefined`. Na samotnom elemente sa potom `text`, `html`, `title`, `value`, `src`, `checked`, `disabled` a `enabled` vrátia k pôvodnému obsahu. |\n| `~command` | Spustí príkaz aj vtedy, keď je element skrytý pomocou `show`, `hide`, `visible` alebo `invisible`. |\n\nExample: Tvary výrazov\n```html\n<ui-bind path=\"form.name\" config=\"text b:value.length;title:n => n + '!';.long:common.long\">\n    <b></b>\n</ui-bind>\n<script>\n    window.common = { long: value => value.length > 3 };\n    SET('form.name', 'Peter');\n</script>\n```\n\nExample: Jeden výraz pre dva príkazy\n```html\n<ui-bind path=\"form.name\" config=\"text+title:value\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\nExample: Obnovenie pôvodného obsahu\n```html\n<ui-bind path=\"form.name\" config=\"!text\">Anonymous</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', null), 500);\n</script>\n```\n\nExample: Aktualizácia skrytého elementu\n```html\n<ui-bind path=\"form.name\" config=\"~text;hide:value\">Anonymous</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### text[:expression]\n\nType: `command`\n\nNastaví textový obsah.\n\nHodnota sa escapuje. Výstup menia príkazy [`format`](#format), [`currency`](#currency), [`helper`](#helper) a [`empty`](#empty).\n\nExample: Použitie príkazu text\n```html\n<ui-bind path=\"form.name\" config=\"text\"></ui-bind>\n<script>SET('form.name', '<b>Peter</b>');</script>\n```\n\n### html[:expression]\n\nType: `command`\n\nNastaví obsah HTML.\n\nHodnota sa neescapuje.\n\nExample: Použitie príkazu html\n```html\n<ui-bind path=\"form.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### value[:expression]\n\nType: `command`\n\nNastaví hodnotu poľa formulára.\n\nFunguje aj skrátený názov `val`.\n\nExample: Použitie príkazu value\n```html\n<ui-bind path=\"form.name\" config=\"value input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('input').val()), 500);  // Peter\n</script>\n```\n\n### title[:expression]\n\nType: `command`\n\nNastaví atribút `title`.\n\nExample: Použitie príkazu title\n```html\n<ui-bind path=\"form.name\" config=\"title\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### href[:expression]\n\nType: `command`\n\nNastaví atribút `href`.\n\nExample: Použitie príkazu href\n```html\n<ui-bind path=\"form.id\" config=\"href a:'/users/' + value + '/'\">\n    <a>Detail</a>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### src[:expression]\n\nType: `command`\n\nNastaví atribút `src`.\n\nExample: Použitie príkazu src\n```html\n<ui-bind path=\"form.photo\" config=\"src img\">\n    <img />\n</ui-bind>\n<script>SET('form.photo', 'data:,');</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nNastaví ľubovoľný atribút.\n\nNázov atribútu nasleduje za príkazom. Za názvom môže nasledovať selektor.\n\nExample: Použitie príkazu attr\n```html\n<ui-bind path=\"form.id\" config=\"attr data-id:value;attr data-ref b:value\">\n    <b></b>\n</ui-bind>\n<script>SET('form.id', 5);</script>\n```\n\n### .classname[ selector]:expression\n\nType: `command`\n\nPrepína triedu CSS podľa výsledku výrazu.\n\nNázov triedy napíš za bodku.\n\nExample: Prepínanie tried\n```html\n<ui-bind path=\"form.age\" config=\".adult:value >= 18;.minor:value < 18\"></ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### class:classes\n\nType: `command`\n\nPrepne triedy CSS raz, po prvej aktualizácii.\n\nViacero tried oddeľ medzerou.\n\nExample: Použitie príkazu class\n```html\n<ui-bind path=\"form.name\" config=\"class:ready\"></ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### show[:expression]\n\nType: `command`\n\nZobrazí element, keď je výsledok výrazu pravdivý.\n\nV opačnom prípade element dostane triedu `hidden`. Kým je skrytý, nasledujúce príkazy sa preskakujú, pokiaľ nemajú predponu `~`.\n\nExample: Použitie príkazu show\n```html\n<ui-bind path=\"form.age\" config=\"show:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### hide[:expression]\n\nType: `command`\n\nSkryje element, keď je výsledok výrazu pravdivý.\n\nElement dostane triedu `hidden`. Funguje aj názov `hidden`.\n\nExample: Použitie príkazu hide\n```html\n<ui-bind path=\"form.age\" config=\"hide:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### visible[:expression]\n\nType: `command`\n\nZachová miesto v rozložení, keď je výsledok výrazu nepravdivý.\n\nKeď je výsledok výrazu nepravdivý, element dostane triedu `invisible`.\n\nExample: Použitie príkazu visible\n```html\n<ui-bind path=\"form.age\" config=\"visible:value >= 18\">Adult</ui-bind>\n<script>SET('form.age', 10);</script>\n```\n\n### invisible[:expression]\n\nType: `command`\n\nPridá triedu `invisible`, keď je výsledok výrazu pravdivý.\n\nExample: Použitie príkazu invisible\n```html\n<ui-bind path=\"form.age\" config=\"invisible:value >= 18\">Minor</ui-bind>\n<script>SET('form.age', 20);</script>\n```\n\n### checked[:expression]\n\nType: `command`\n\nNastaví vlastnosť `checked` poľa.\n\nExample: Použitie príkazu checked\n```html\n<ui-bind path=\"form.active\" config=\"checked input\">\n    <input type=\"checkbox\" />\n</ui-bind>\n<script>\n    SET('form.active', true);\n    setTimeout(() => console.log($('input').prop('checked')), 500);  // true\n</script>\n```\n\n### disabled[:expression]\n\nType: `command`\n\nZakáže polia a komponenty, keď je výsledok výrazu pravdivý.\n\nFunguje aj skrátený názov `disable`. Bez selektora sa príkaz použije na `ui-component`, `input`, `textarea`, `select` a `button` vnútri elementu. Komponenty dostanú konfiguračný kľúč `disabled`.\n\nExample: Použitie príkazu disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.locked', true);</script>\n```\n\n### enabled[:expression]\n\nType: `command`\n\nPovolí polia a komponenty, keď je výsledok výrazu pravdivý.\n\nFunguje aj skrátený názov `enable`. Predvolený selektor je rovnaký ako pri [`disabled`](#disabled).\n\nExample: Použitie príkazu enabled\n```html\n<ui-bind path=\"form.valid\" config=\"enabled\">\n    <button>Save</button>\n</ui-bind>\n<script>SET('form.valid', false);</script>\n```\n\n### required selector:expression\n\nType: `command`\n\nNastaví konfiguračný kľúč `required` komponentu.\n\nPridaj selektor, pretože príkaz žiadny predvolený nemá.\n\nExample: Použitie príkazu required\n```html\n<ui-bind path=\"form.strict\" config=\"required ui-component:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'required' && console.log(value);  // true\n    });\n    SET('form.strict', true);\n</script>\n```\n\n### config:expression\n\nType: `command`\n\nZmení konfiguráciu komponentov podľa výsledku výrazu.\n\nPredvolený selektor je `ui-component`.\n\nExample: Použitie príkazu config\n```html\n<ui-bind path=\"form.title\" config=\"config:'title:' + value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = (key, value) => key === 'title' && console.log(value);  // Orders\n    });\n    SET('form.title', 'Orders');\n</script>\n```\n\n### set[:expression]\n\nType: `command`\n\nOdovzdá výsledok výrazu metóde `setter` komponentu bez path.\n\nPredvolený selektor je `ui-component`. Komponent môže zapisovať späť na tú istú path.\n\nExample: Použitie príkazu set\n```html\n<ui-bind path=\"form.name\" config=\"set:value + '!'\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = value => self.text(value);\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### setter:'selector/method',value\n\nType: `command`\n\nZavolá metódu zodpovedajúcich komponentov.\n\nVýraz obsahuje argumenty funkcie `SETTER()`, ktoré sa vyhodnotia s `value`, `path` a `el`.\n\nExample: Použitie príkazu setter\n```html\n<ui-bind path=\"form.name\" config=\"setter:'box/show',value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.show = value => value && console.log(value);  // Peter\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### template [selector][:selector-->attribute]\n\nType: `command`\n\nVykreslí šablónu Tangular.\n\nŠablóna je prvý `<script>` alebo `<template>` vnútri elementu. Model má vlastnosti `value` a `path`.\n\nVoliteľný tvar `template:selector-->attribute` aktualizuje iba zmenené vnorené elementy. Selektor nájde položky a atribút ich identifikuje. Viac sa dočítaš v časti [Šablóny s Tangular](../../guides/tangular/).\n\nExample: Použitie príkazu template\n```html\n<ui-bind path=\"form.items\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<li>{{ m }}</li>{{ end }}\n    </script>\n</ui-bind>\n<script>SET('form.items', ['A', 'B']);</script>\n```\n\n### helpers:path\n\nType: `command`\n\nOdovzdá šablóne helpery Tangular.\n\nHodnota je path k objektu s helpermi alebo k funkcii, ktorá taký objekt vráti.\n\nExample: Použitie príkazu helpers\n```html\n<ui-bind path=\"form.name\" config=\"template;helpers:common.helpers\">\n    <script type=\"text/html\">{{ value | shout }}</script>\n</ui-bind>\n<script>\n    window.common = { helpers: { shout: value => value + '!' } };\n    SET('form.name', 'Peter');\n</script>\n```\n\n### vbindarray\n\nType: `command`\n\nVykreslí pole s jedným virtuálnym binderom na položku.\n\nŠablóna je prvý `<script>` alebo `<template>` vnútri elementu. Path v šablóne sa začínajú bodkou. Pozri [Virtuálny binder](../vbinder/).\n\nExample: Použitie príkazu vbindarray\n```html\n<ui-bind path=\"form.users\" config=\"vbindarray\">\n    <script type=\"text/html\">\n        <div><ui-bind path=\".name\" config=\"text\"></ui-bind></div>\n    </script>\n</ui-bind>\n<script>SET('form.users', [{ name: 'Peter' }, { name: 'Anna' }]);</script>\n```\n\n### import:url\n\nType: `command`\n\nNačíta obsah do elementu.\n\nHodnota je jedna z týchto možností:\n\n| Hodnota | Význam |\n| --- | --- |\n| URL, ktorá sa začína na `/`, `http://` alebo `https://` | Importuje URL raz. |\n| `value` alebo `true` | Presunie prvý vnútorný `<script>` alebo `<template>` do DOM. |\n| Výraz | Importuje URL, ktorú vráti hodnota na path, a to raz pre každú URL. |\n\nImport čaká, kým bude element viditeľný, takže ho môžeš skombinovať s [`show`](#show).\n\nExample: Vloženie šablóny pri zobrazení elementu\n```html\n<ui-bind path=\"form.open\" config=\"show;import:value\">\n    <script type=\"text/html\"><b>Loaded</b></script>\n</ui-bind>\n<script>\n    setTimeout(() => SET('form.open', true), 500);\n</script>\n```\n\n### macro:name1,name2\n\nType: `command`\n\nPripojí k elementu macro.\n\nViacero názvov oddeľ čiarkou. Pozri [Macro](../macro/).\n\nExample: Použitie príkazu macro\n```html\n<ui-bind path=\"form.name\" config=\"macro:shout\"></ui-bind>\n<script>\n    MACRO('shout', function(self) {\n        self.setter = value => self.text(value + '!');\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nZavolá funkciu pri každej aktualizácii.\n\nFunkcia dostane `value`, `path` a `el` a `this` je element. Vždy dostane nespracovanú hodnotu. Funguje aj názov `change`.\n\nExample: Použitie príkazu exec\n```html\n<ui-bind path=\"form.name\" config=\"exec:common.onchange\"></ui-bind>\n<script>\n    window.common = { onchange: (value, path) => value && console.log(value, path) };  // Peter form.name\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### init:path\n\nType: `command`\n\nZavolá funkciu na začiatku každej aktualizácie.\n\nFunkcia dostane `value`, `path` a `el`.\n\nExample: Použitie príkazu init\n```html\n<ui-bind path=\"form.name\" config=\"init:common.oninit\"></ui-bind>\n<script>\n    window.common = { oninit: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nZavolá funkciu pri každej aktualizácii, kým je element viditeľný.\n\nFunkcia dostane `value`, `path` a `el`.\n\nExample: Použitie príkazu refresh\n```html\n<ui-bind path=\"form.name\" config=\"refresh:common.onrefresh\"></ui-bind>\n<script>\n    window.common = { onrefresh: value => value && console.log(value) };  // Peter\n    SET('form.name', 'Peter');\n</script>\n```\n\n### click [selector]:path\n\nType: `command`\n\nZavolá funkciu po kliknutí na element.\n\nFunkcia dostane element jQuery, udalosť, aktuálnu hodnotu a path. Selektor deleguje kliknutie na zodpovedajúce vnorené elementy. Zakázané vstupné polia a tlačidlá sa ignorujú.\n\nExample: Použitie príkazu click\n```html\n<ui-bind path=\"form.name\" config=\"click button:common.onclick\">\n    <button>Save</button>\n</ui-bind>\n<script>\n    window.common = {\n        onclick: (element, event, value, path) => console.log(element.text(), value, path)  // Save Peter form.name\n    };\n    SET('form.name', 'Peter');\n    setTimeout(() => $('button').click(), 500);\n</script>\n```\n\n### format:format\n\nType: `command`\n\nNaformátuje číslo alebo dátum.\n\nČíslo nastaví počet desatinných miest. Akýkoľvek iný text je formát dátumu.\n\nExample: Použitie príkazu format\n```html\n<ui-bind path=\"form.price\" config=\"text;format:2\"></ui-bind>\n<script>SET('form.price', 1250);</script>\n```\n\n### currency:name\n\nType: `command`\n\nNaformátuje číslo s menou.\n\nNázov odkazuje na funkciu v `DEF.currencies`.\n\nExample: Použitie príkazu currency\n```html\n<ui-bind path=\"form.price\" config=\"text;currency:eur\"></ui-bind>\n<script>\n    DEF.currencies.eur = value => value.format(2) + ' EUR';\n    SET('form.price', 1250);\n</script>\n```\n\n### helper:name[(arguments)]\n\nType: `command`\n\nTransformuje výstup helperom Tangular.\n\nHodnota sa odovzdá ako prvý argument helpera. Ďalšie argumenty môžeš napísať do zátvoriek.\n\nExample: Použitie príkazu helper\n```html\n<ui-bind path=\"form.name\" config=\"text;helper:wrap('*')\"></ui-bind>\n<script>\n    Thelpers.wrap = (value, chars) => chars + value + chars;\n    SET('form.name', 'Peter');\n</script>\n```\n\n### empty[:text]\n\nType: `command`\n\nNastaví text použitý pre prázdnu hodnotu.\n\nBez hodnoty príkaz použije `DEF.empty`, čo je `---`.\n\nExample: Použitie príkazu empty\n```html\n<ui-bind path=\"form.name\" config=\"text;empty:Nothing\"></ui-bind>\n```\n\n### default:expression\n\nType: `command`\n\nNahradí `null` a `undefined` hodnotou.\n\nHodnota je výraz JavaScriptu. Funguje aj skrátený názov `def`.\n\nExample: Použitie príkazu default\n```html\n<ui-bind path=\"form.name\" config=\"text;default:'Anonymous'\"></ui-bind>\n```\n\n### selector:selector\n\nType: `command`\n\nPoužije všetky príkazy na zodpovedajúce vnorené elementy.\n\nExample: Použitie príkazu selector\n```html\n<ui-bind path=\"form.name\" config=\"selector:b;text\">\n    <b></b><b></b>\n</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### assign:path\n\nType: `command`\n\nZapíše element jQuery na path.\n\nExample: Použitie príkazu assign\n```html\n<ui-bind id=\"box\" path=\"form.name\" config=\"assign:common.box;text\"></ui-bind>\n<script>\n    setTimeout(() => console.log(GET('common.box').attr('id')), 500);  // box\n</script>\n```\n\n### check:path\n\nType: `command`\n\nSpustí príkazy iba vtedy, keď je splnená podmienka.\n\nHodnota je path k pravdivej hodnote alebo `plugin/method`, ktorá dostane `value`, `path` a `el`.\n\nExample: Použitie príkazu check\n```html\n<ui-bind path=\"form.name\" config=\"check:form.ready;text\">Waiting</ui-bind>\n<script>SET('form.name', 'Peter');</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nOneskorí aktualizáciu o zadaný počet milisekúnd.\n\nOpakované aktualizácie v rámci oneskorenia sa spustia raz.\n\nExample: Použitie príkazu delay\n```html\n<ui-bind path=\"form.name\" config=\"delay:500;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => console.log($('ui-bind').text() || 'empty'), 200);  // empty\n    setTimeout(() => console.log($('ui-bind').text()), 1100);  // Peter\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnoruje zmeny vnorených path.\n\nPríkazy sa spustia iba vtedy, keď sa zmení samotná path alebo niektorá z jej nadradených path.\n\nExample: Použitie príkazu strict\n```html\n<ui-bind path=\"form.user\" config=\"strict;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter' });\n    setTimeout(() => SET('form.user.name', 'Anna'), 500);\n</script>\n```\n\n### track:field1,field2\n\nType: `command`\n\nSpustí príkazy iba pre vybrané vnorené polia.\n\nViacero polí oddeľ čiarkou.\n\nExample: Použitie príkazu track\n```html\n<ui-bind path=\"form.user\" config=\"track:name;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: (value, path) => console.log(path) };\n    SET('form.user', { name: 'Peter', age: 20 });\n    setTimeout(() => SET('form.user.age', 21), 500);\n    setTimeout(() => SET('form.user.name', 'Anna'), 700);\n</script>\n```\n\n### tracktype:type1,type2\n\nType: `command`\n\nSpustí príkazy iba pre vybrané typy aktualizácií.\n\nViacero typov oddeľ čiarkou.\n\nExample: Použitie príkazu tracktype\n```html\n<ui-bind path=\"form.age\" config=\"tracktype:2;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10, 1), 500);\n    setTimeout(() => SET('form.age', 20, 2), 700);\n</script>\n```\n\n### changes\n\nType: `command`\n\nPreskočí príkazy, keď sa hodnota nezmenila.\n\nHodnota sa porovnáva pomocou hashu.\n\nExample: Použitie príkazu changes\n```html\n<ui-bind path=\"form.age\" config=\"changes;exec:common.update\"></ui-bind>\n<script>\n    window.common = { update: value => value && console.log(value) };\n    setTimeout(() => SET('form.age', 10), 500);\n    setTimeout(() => UPD('form.age'), 700);\n</script>\n```\n\n### ready\n\nType: `command`\n\nPočká na komponenty vnorené v elemente.\n\nPríkazy sa spustia, keď sú všetky vnorené komponenty pripravené.\n\nExample: Použitie príkazu ready\n```html\n<ui-bind path=\"form.name\" config=\"ready;exec:common.update\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    window.common = { update: () => console.log(FIND('box') ? 'found' : 'missing') };  // found\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### once\n\nType: `command`\n\nSpustí príkazy iba raz.\n\nExample: Použitie príkazu once\n```html\n<ui-bind path=\"form.name\" config=\"once;text\"></ui-bind>\n<script>\n    SET('form.name', 'Peter');\n    setTimeout(() => SET('form.name', 'Anna'), 700);\n</script>\n```\n\n### focus:selector\n\nType: `command`\n\nPo každej aktualizácii presunie fokus na pole.\n\nHodnota je selektor vnorených elementov.\n\nExample: Presunutie fokusu na pole\n```html\n<ui-bind path=\"form.name\" config=\"focus:input\">\n    <input />\n</ui-bind>\n<script>\n    SET('form.name', 'Peter');\n</script>\n```\n\n### resize\n\nType: `command`\n\nPo každej aktualizácii zavolá metódu `resize` vnorených komponentov.\n\nExample: Použitie príkazu resize\n```html\n<ui-bind path=\"form.name\" config=\"resize\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n<script>\n    COMPONENT('box', function(self) {\n        self.resize = () => console.log('resized');  // resized\n    });\n    setTimeout(() => SET('form.name', 'Peter'), 500);\n</script>\n```\n\n### binder.refresh()\n\nType: `method`\n\nZnova spustí príkazy s aktuálnou hodnotou na path.\n\nBinder je dostupný ako `element.ui` alebo cez `$(element).binder()`.\n\nExample: Obnovenie binderu\n```js\nvar binder = $('ui-bind').binder();\nwindow.form.name = 'Anna';\nbinder.refresh();\nconsole.log($('ui-bind').text());  // Anna\n```\n\n### binder.exec(value, path)\n\nType: `method`\n\nSpustí príkazy s vlastnou hodnotou.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota odovzdaná príkazom. |\n| `path` | `String` | yes |  | Path odovzdaná príkazom. |\n\nHodnota sa nezapíše do dátového modelu.\n\nExample: Spustenie príkazov s hodnotou\n```js\nvar binder = $('ui-bind').binder();\nbinder.exec('Preview', 'form.name');\nconsole.log($('ui-bind').text(), GET('form.name'));  // Preview Peter\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"command:expression;command:expression\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"type","name":"Command syntax","signature":"[!~]command [selector]: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[: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":".class","signature":".classname[ selector]:expression","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:classes","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":"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 selector:expression","since":"","deprecated":false},{"type":"command","name":"config","signature":"config:expression","since":"","deprecated":false},{"type":"command","name":"set","signature":"set[:expression]","since":"","deprecated":false},{"type":"command","name":"setter","signature":"setter:'selector/method',value","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":"vbindarray","signature":"vbindarray","since":"","deprecated":false},{"type":"command","name":"import","signature":"import:url","since":"","deprecated":false},{"type":"command","name":"macro","signature":"macro:name1,name2","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"click","signature":"click [selector]:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:format","since":"","deprecated":false},{"type":"command","name":"currency","signature":"currency:name","since":"","deprecated":false},{"type":"command","name":"helper","signature":"helper:name[(arguments)]","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty[:text]","since":"","deprecated":false},{"type":"command","name":"default","signature":"default:expression","since":"","deprecated":false},{"type":"command","name":"selector","signature":"selector:selector","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:field1,field2","since":"","deprecated":false},{"type":"command","name":"tracktype","signature":"tracktype:type1,type2","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"resize","signature":"resize","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"binder.refresh()","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"binder.exec(value, path)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:24.464Z"}
{"id":"Jammi89ej61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/scope/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Scope","summary":"The properties and methods of a scope object.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/scope/\nupdated: 2026-11-18T14:27:30.824Z\n---\n\n# Scope\n\n> The properties and methods of a scope object.\n\nA scope object represents a [`ui-plugin`](../ui-plugin/) element in the page. Paths used through the object are relative to the path of the scope. Get the object with `$(element).scope()`. [Scopes](../../guides/scopes/) explains the concept.\n\n## API\n\n### scope.path\n\nType: `property`\n\nThe absolute path of the scope.\n\nExample: Reading path\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.path);  // users\n```\n\n### scope.id\n\nType: `property`\n\nThe unique generated identifier of the scope.\n\nThe same value is available as `ID`.\n\nExample: Reading id\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.id === scope.ID);  // true\n```\n\n### scope.element\n\nType: `property`\n\nThe element of the scope as a jQuery object.\n\nExample: Reading element\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### scope.config\n\nType: `property`\n\nThe parsed configuration of the element.\n\nExample: Reading config\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.config.limit);  // 10\n```\n\n### scope.parent\n\nType: `property`\n\nThe parent scope.\n\nThe property is `undefined` for a scope without a parent.\n\nExample: Reading parent\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.parent.path);  // users\n```\n\n### scope.isolated\n\nType: `property`\n\nTells whether the path ignores the parent scope.\n\nExample: Reading isolated\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.isolated);  // false\n```\n\n### scope.elements\n\nType: `property`\n\nThe elements of the parent scopes and of this scope.\n\nThe elements are DOM nodes, and the last one is the element of this scope.\n\nExample: Reading elements\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.elements.length);  // 2\n```\n\n### scope.plugin\n\nType: `property`\n\nThe [Plugin](../plugin/) connected to the scope.\n\nExample: Reading plugin\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.plugin.name);  // users\n```\n\n### scope.makepath(path)\n\nType: `method`\n\nResolves a path relative to the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `String` The resolved path.\n\n`?` is the path of the scope, `?1` is the path of the parent scope and `?2` is the path two levels up. When that level does not exist, the path of the scope is used.\n\nExample: Using makepath()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.makepath('?.name'));  // users.name\n```\n\n### scope.get([path])\n\nType: `method`\n\nReads a path relative to the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n\nReturns: `Object` The value.\n\nWithout an argument, the method returns the whole model.\n\nExample: Using get()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.set(path, value, [timeout], [reset])\n\nType: `method`\n\nWrites a value to a path relative to the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n| `value` | `Object` | yes |  | The value. |\n| `timeout` | `Number` | no |  | A value of `10` or more delays the change in milliseconds. A lower value is the type of the change. |\n| `reset` | `Boolean` | no |  | `true` resets the state after a delayed change. |\n\nExample: Using set()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 2);\nconsole.log(GET('users.page'));  // 2\n```\n\n### scope.push(path, value, [timeout], [reset])\n\nType: `method`\n\nAdds an item to an array relative to the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n| `value` | `Object` | yes |  | The item. |\n| `timeout` | `Number` | no |  | A value of `10` or more delays the change in milliseconds. A lower value is the type of the change. |\n| `reset` | `Boolean` | no |  | `true` resets the state after a delayed change. |\n\nExample: Using push()\n```js\nvar scope = $('ui-plugin').scope();\nscope.push('items', 'A');\nconsole.log(scope.get('items'));  // [\"A\"]\n```\n\n### scope.update([path], [timeout], [reset])\n\nType: `method`\n\nNotifies the listeners of a path relative to the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `timeout` | `Number` | no |  | A value of `10` or more delays the change in milliseconds. A lower value is the type of the change. |\n| `reset` | `Boolean` | no |  | `true` resets the state. |\n\nExample: Using update()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(value));  // 5\nwindow.users.page = 5;\nscope.update('page');\n```\n\n### scope.change([path])\n\nType: `method`\n\nMarks components on a path as touched and modified.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n\nExample: Using change()\n```js\nvar scope = $('ui-plugin').scope();\nscope.change();\nconsole.log(FIND('field').config.touched);  // true\n```\n\n### scope.reset([path])\n\nType: `method`\n\nClears the state of components on a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n\nThe touched and modified state is cleared. The value does not change.\n\nExample: Using reset()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.modify('Peter');\nscope.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### scope.default([path], [timeout])\n\nType: `method`\n\nRestores the default value of the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `timeout` | `Number` | no |  | The delay in milliseconds. |\n\nThe default value comes from the [`default`](../ui-plugin/#default) attribute of the element. A number as the first argument is a delay in milliseconds.\n\nExample: Using default()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 5);\nscope.default();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.can()\n\nType: `method`\n\nTells whether the components in the scope can be saved.\n\nReturns: `Boolean` The result.\n\nThe result is `true` when at least one component is touched and none is invalid. A scope without components returns `true`.\n\nExample: Using can()\n```js\nvar scope = $('ui-plugin').scope();\nFIND('field').modify('Peter');\nconsole.log(scope.can());  // true\n```\n\n### scope.errors()\n\nType: `method`\n\nReturns the touched and invalid components of the scope.\n\nReturns: `Array` The components.\n\nExample: Using errors()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.validate = value => !!value;\ncom.bind('touched');\ncom.validate2();\nconsole.log(scope.errors().length);  // 1\n```\n\n### scope.watch(path, callback, [init])\n\nType: `method`\n\nWatches a path relative to the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n| `callback` | `Function` | yes |  | The function that receives the changes. |\n| `init` | `Boolean` | no |  | `true` calls the callback immediately. |\n\nReturns: `Scope` The scope.\n\nThe callback receives `path`, `value` and `type`, and `this` is the scope.\n\nExample: Using watch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(path, value));  // users.page 2\nscope.set('page', 2);\n```\n\n### scope.unwatch(path)\n\nType: `method`\n\nRemoves the watchers of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n\nReturns: `Scope` The scope.\n\nThe method removes all watchers that this scope has on the path.\n\nExample: Using unwatch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', () => console.log('called'));\nscope.unwatch('page');\nscope.set('page', 2);\nconsole.log('end');  // end\n```\n\n### scope.apply()\n\nType: `method`\n\nMakes the scope active.\n\nReturns: `Scope` The scope.\n\nFunctions such as `SET()` then replace `?` with the path of this scope.\n\nExample: Using apply()\n```js\nvar scope = $('ui-plugin').scope();\nscope.apply();\nSET('?.page', 3);\nconsole.log(GET('users.page'));  // 3\n```\n\n### scope.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nFinds components inside the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector of the component. |\n| `many` | `Boolean` | no |  | `true` returns an array. |\n| `callback` | `Function` | no |  | Waits for the component and receives it. |\n| `timeout` | `Number` | no |  | The longest wait in milliseconds. |\n\nReturns: `Component|Array` The result.\n\nThe arguments are the same as in the jQuery `FIND()` extension.\n\nExample: Using FIND()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.FIND('field').name);  // field\n```\n\n### scope.SETTER(selector, method, [...args])\n\nType: `method`\n\nCalls a method of components inside the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector of the component. |\n| `method` | `String` | yes |  | The name of the method. |\n| `args` | `Object` | no |  | The arguments. |\n\nExample: Using SETTER()\n```js\nvar scope = $('ui-plugin').scope();\nscope.SETTER('field/reconfigure', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.RECONFIGURE(selector, value)\n\nType: `method`\n\nReconfigures components inside the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector of the component. |\n| `value` | `String|Object` | yes |  | The configuration. |\n\nExample: Using RECONFIGURE()\n```js\nvar scope = $('ui-plugin').scope();\nscope.RECONFIGURE('field', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.find(selector)\n\nType: `method`\n\nFinds nested elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | A selector or an object of selectors. |\n\nReturns: `jQuery|Object` The result.\n\nAn object of selectors returns an object of jQuery results with the same keys.\n\nExample: Using find()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.find('span').length);  // 1\n```\n\n### scope.closest(selector)\n\nType: `method`\n\nFinds the closest matching parent of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector. |\n\nReturns: `jQuery` The result.\n\nExample: Using closest()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.closest('body').length);  // 1\n```\n\n### scope.append(value)\n\nType: `method`\n\nAdds content to the end of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | The content. |\n\nReturns: `jQuery` The element.\n\nAn array is joined.\n\nExample: Using append()\n```js\nvar scope = $('ui-plugin').scope();\nscope.append('<b>A</b>');\nconsole.log(scope.find('b').text());  // A\n```\n\n### scope.event(name, [selector], callback)\n\nType: `method`\n\nAttaches a jQuery event to the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `selector` | `String` | no |  | The delegated selector. |\n| `callback` | `Function` | yes |  | The handler. |\n\nReturns: `Scope` The scope.\n\nThe arguments are the same as in the jQuery `on()` method.\n\nExample: Using event()\n```js\nvar scope = $('ui-plugin').scope();\nscope.event('click', 'span', () => console.log('clicked'));  // clicked\nscope.find('span').click();\n```\n\n### scope.attr(name, [value])\n\nType: `method`\n\nReads or writes 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: `String|Scope` The value, or the scope when `value` is passed.\n\nExample: Using attr()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attr('title', 'Users');\nconsole.log(scope.attr('title'));  // Users\n```\n\n### scope.attrd(name, [value])\n\nType: `method`\n\nReads or writes 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|Scope` The value, or the scope when `value` is passed.\n\nExample: Using attrd()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attrd('id', '5');\nconsole.log(scope.attr('data-id'));  // 5\n```\n\n### scope.attrd2(name)\n\nType: `method`\n\nReads a `data-` attribute from the element or its closest parent that has it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name without the `data-` prefix. |\n\nReturns: `String` The value.\n\nExample: Using attrd2()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.attrd2('area'));  // main\n```\n\n### scope.css(name, [value])\n\nType: `method`\n\nReads or writes 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: `String|Scope` The value, or the scope when `value` is passed.\n\nExample: Using css()\n```js\nvar scope = $('ui-plugin').scope();\nscope.css('display', 'block');\nconsole.log(scope.css('display'));  // block\n```\n\n### scope.autofocus([selector])\n\nType: `method`\n\nMoves the focus to the first visible field in the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | The fields. |\n\nReturns: `Scope` The scope.\n\nThe method does nothing on mobile devices.\n\nExample: Using autofocus()\n```js\nvar scope = $('ui-plugin').scope();\nscope.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### scope.remove()\n\nType: `method`\n\nRemoves the scope, its element and its components.\n\nExample: Using remove()\n```js\nvar scope = $('ui-plugin').scope();\nscope.remove();\nconsole.log($('ui-plugin').length);  // 0\n```\n","entries":[{"type":"property","name":"path","signature":"scope.path","since":"","deprecated":false},{"type":"property","name":"id","signature":"scope.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"scope.element","since":"","deprecated":false},{"type":"property","name":"config","signature":"scope.config","since":"","deprecated":false},{"type":"property","name":"parent","signature":"scope.parent","since":"","deprecated":false},{"type":"property","name":"isolated","signature":"scope.isolated","since":"","deprecated":false},{"type":"property","name":"elements","signature":"scope.elements","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"scope.plugin","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"scope.makepath(path)","since":"","deprecated":false},{"type":"method","name":"get()","signature":"scope.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"scope.set(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"scope.push(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"scope.update([path], [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"scope.change([path])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"scope.reset([path])","since":"","deprecated":false},{"type":"method","name":"default()","signature":"scope.default([path], [timeout])","since":"","deprecated":false},{"type":"method","name":"can()","signature":"scope.can()","since":"","deprecated":false},{"type":"method","name":"errors()","signature":"scope.errors()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"scope.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"scope.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"apply()","signature":"scope.apply()","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"scope.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"scope.SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"scope.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"scope.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"scope.closest(selector)","since":"","deprecated":false},{"type":"method","name":"append()","signature":"scope.append(value)","since":"","deprecated":false},{"type":"method","name":"event()","signature":"scope.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"scope.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"scope.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"scope.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"scope.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"scope.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"scope.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T14:27:30.824Z"}
{"id":"Jammi89ej61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/scope/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Scope","summary":"Die Eigenschaften und Methoden eines Scope-Objekts.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/scope/\nupdated: 2026-11-18T14:27:30.824Z\n---\n\n# Scope\n\n> Die Eigenschaften und Methoden eines Scope-Objekts.\n\nEin Scope-Objekt repräsentiert ein [`ui-plugin`](../ui-plugin/)-Element auf der Seite. Paths, die du über das Objekt verwendest, sind relativ zum Path des Scopes. Das Objekt erhältst du mit `$(element).scope()`. [Scopes](../../guides/scopes/) erklärt das Konzept.\n\n## API\n\n### scope.path\n\nType: `property`\n\nDer absolute Path des Scopes.\n\nExample: path lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.path);  // users\n```\n\n### scope.id\n\nType: `property`\n\nDie eindeutige, generierte Kennung des Scopes.\n\nDerselbe Wert steht als `ID` zur Verfügung.\n\nExample: id lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.id === scope.ID);  // true\n```\n\n### scope.element\n\nType: `property`\n\nDas Element des Scopes als jQuery-Objekt.\n\nExample: element lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### scope.config\n\nType: `property`\n\nDie geparste Konfiguration des Elements.\n\nExample: config lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.config.limit);  // 10\n```\n\n### scope.parent\n\nType: `property`\n\nDer übergeordnete Scope.\n\nBei einem Scope ohne übergeordneten Scope ist die Eigenschaft `undefined`.\n\nExample: parent lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.parent.path);  // users\n```\n\n### scope.isolated\n\nType: `property`\n\nGibt an, ob der Path den übergeordneten Scope ignoriert.\n\nExample: isolated lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.isolated);  // false\n```\n\n### scope.elements\n\nType: `property`\n\nDie Elemente der übergeordneten Scopes und dieses Scopes.\n\nDie Elemente sind DOM-Knoten, und das letzte ist das Element dieses Scopes.\n\nExample: elements lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.elements.length);  // 2\n```\n\n### scope.plugin\n\nType: `property`\n\nDas mit dem Scope verbundene [Plugin](../plugin/).\n\nExample: plugin lesen\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.plugin.name);  // users\n```\n\n### scope.makepath(path)\n\nType: `method`\n\nLöst einen Path relativ zum Scope auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `String` Der aufgelöste Path.\n\n`?` ist der Path des Scopes, `?1` der Path des übergeordneten Scopes und `?2` der Path zwei Ebenen darüber. Gibt es diese Ebene nicht, wird der Path des Scopes verwendet.\n\nExample: makepath() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.makepath('?.name'));  // users.name\n```\n\n### scope.get([path])\n\nType: `method`\n\nLiest einen Path relativ zum Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n\nReturns: `Object` Der Wert.\n\nOhne Argument gibt die Methode das gesamte Modell zurück.\n\nExample: get() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.set(path, value, [timeout], [reset])\n\nType: `method`\n\nSchreibt einen Wert in einen Path relativ zum Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `timeout` | `Number` | no |  | Ein Wert ab `10` verzögert die Änderung um diese Anzahl von Millisekunden. Ein kleinerer Wert ist der Typ der Änderung. |\n| `reset` | `Boolean` | no |  | `true` setzt den Zustand nach einer verzögerten Änderung zurück. |\n\nExample: set() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 2);\nconsole.log(GET('users.page'));  // 2\n```\n\n### scope.push(path, value, [timeout], [reset])\n\nType: `method`\n\nFügt einem Array relativ zum Scope einen Eintrag hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n| `value` | `Object` | yes |  | Das Element. |\n| `timeout` | `Number` | no |  | Ein Wert ab `10` verzögert die Änderung um diese Anzahl von Millisekunden. Ein kleinerer Wert ist der Typ der Änderung. |\n| `reset` | `Boolean` | no |  | `true` setzt den Zustand nach einer verzögerten Änderung zurück. |\n\nExample: push() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.push('items', 'A');\nconsole.log(scope.get('items'));  // [\"A\"]\n```\n\n### scope.update([path], [timeout], [reset])\n\nType: `method`\n\nBenachrichtigt die Listener eines Paths relativ zum Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `timeout` | `Number` | no |  | Ein Wert ab `10` verzögert die Änderung um diese Anzahl von Millisekunden. Ein kleinerer Wert ist der Typ der Änderung. |\n| `reset` | `Boolean` | no |  | `true` setzt den Zustand zurück. |\n\nExample: update() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(value));  // 5\nwindow.users.page = 5;\nscope.update('page');\n```\n\n### scope.change([path])\n\nType: `method`\n\nMarkiert Komponenten auf einem Path als berührt und geändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n\nExample: change() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.change();\nconsole.log(FIND('field').config.touched);  // true\n```\n\n### scope.reset([path])\n\nType: `method`\n\nLöscht den Zustand der Komponenten auf einem Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n\nDer Zustand „berührt“ und „geändert“ wird gelöscht. Der Wert ändert sich nicht.\n\nExample: reset() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.modify('Peter');\nscope.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### scope.default([path], [timeout])\n\nType: `method`\n\nStellt den Standardwert des Scopes wieder her.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `timeout` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nDer Standardwert stammt aus dem Attribut [`default`](../ui-plugin/#default) des Elements. Eine Zahl als erstes Argument ist eine Verzögerung in Millisekunden.\n\nExample: default() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 5);\nscope.default();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.can()\n\nType: `method`\n\nGibt an, ob die Komponenten im Scope gespeichert werden können.\n\nReturns: `Boolean` Das Ergebnis.\n\nDas Ergebnis ist `true`, wenn mindestens eine Komponente berührt und keine ungültig ist. Ein Scope ohne Komponenten gibt `true` zurück.\n\nExample: can() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nFIND('field').modify('Peter');\nconsole.log(scope.can());  // true\n```\n\n### scope.errors()\n\nType: `method`\n\nGibt die berührten und ungültigen Komponenten des Scopes zurück.\n\nReturns: `Array` Die Komponenten.\n\nExample: errors() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.validate = value => !!value;\ncom.bind('touched');\ncom.validate2();\nconsole.log(scope.errors().length);  // 1\n```\n\n### scope.watch(path, callback, [init])\n\nType: `method`\n\nÜberwacht einen Path relativ zum Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n| `callback` | `Function` | yes |  | Die Funktion, die die Änderungen erhält. |\n| `init` | `Boolean` | no |  | `true` ruft den Callback sofort auf. |\n\nReturns: `Scope` Der Scope.\n\nDer Callback erhält `path`, `value` und `type`, und `this` ist der Scope.\n\nExample: watch() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(path, value));  // users.page 2\nscope.set('page', 2);\n```\n\n### scope.unwatch(path)\n\nType: `method`\n\nEntfernt die Watcher eines Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n\nReturns: `Scope` Der Scope.\n\nDie Methode entfernt alle Watcher, die dieser Scope auf dem Path hat.\n\nExample: unwatch() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', () => console.log('called'));\nscope.unwatch('page');\nscope.set('page', 2);\nconsole.log('end');  // end\n```\n\n### scope.apply()\n\nType: `method`\n\nMacht den Scope aktiv.\n\nReturns: `Scope` Der Scope.\n\nFunktionen wie `SET()` ersetzen `?` dann durch den Path dieses Scopes.\n\nExample: apply() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.apply();\nSET('?.page', 3);\nconsole.log(GET('users.page'));  // 3\n```\n\n### scope.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nFindet Komponenten innerhalb des Scopes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor der Komponente. |\n| `many` | `Boolean` | no |  | `true` gibt ein Array zurück. |\n| `callback` | `Function` | no |  | Wartet auf die Komponente und erhält sie. |\n| `timeout` | `Number` | no |  | Die längste Wartezeit in Millisekunden. |\n\nReturns: `Component|Array` Das Ergebnis.\n\nDie Argumente sind dieselben wie bei der jQuery-Erweiterung `FIND()`.\n\nExample: FIND() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.FIND('field').name);  // field\n```\n\n### scope.SETTER(selector, method, [...args])\n\nType: `method`\n\nRuft eine Methode der Komponenten innerhalb des Scopes auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor der Komponente. |\n| `method` | `String` | yes |  | Der Name der Methode. |\n| `args` | `Object` | no |  | Die Argumente. |\n\nExample: SETTER() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.SETTER('field/reconfigure', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.RECONFIGURE(selector, value)\n\nType: `method`\n\nKonfiguriert Komponenten innerhalb des Scopes neu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor der Komponente. |\n| `value` | `String|Object` | yes |  | Die Konfiguration. |\n\nExample: RECONFIGURE() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.RECONFIGURE('field', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.find(selector)\n\nType: `method`\n\nFindet verschachtelte Elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Ein Selektor oder ein Objekt aus Selektoren. |\n\nReturns: `jQuery|Object` Das Ergebnis.\n\nEin Objekt aus Selektoren liefert ein Objekt aus jQuery-Ergebnissen mit denselben Schlüsseln.\n\nExample: find() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.find('span').length);  // 1\n```\n\n### scope.closest(selector)\n\nType: `method`\n\nFindet das nächstgelegene passende Elternelement des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor. |\n\nReturns: `jQuery` Das Ergebnis.\n\nExample: closest() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.closest('body').length);  // 1\n```\n\n### scope.append(value)\n\nType: `method`\n\nFügt Inhalt am Ende des Elements hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Der Inhalt. |\n\nReturns: `jQuery` Das Element.\n\nEin Array wird zusammengefügt.\n\nExample: append() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.append('<b>A</b>');\nconsole.log(scope.find('b').text());  // A\n```\n\n### scope.event(name, [selector], callback)\n\nType: `method`\n\nHängt ein jQuery-Event an das Element an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `selector` | `String` | no |  | Der delegierte Selektor. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nReturns: `Scope` Der Scope.\n\nDie Argumente sind dieselben wie bei der jQuery-Methode `on()`.\n\nExample: event() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.event('click', 'span', () => console.log('clicked'));  // clicked\nscope.find('span').click();\n```\n\n### scope.attr(name, [value])\n\nType: `method`\n\nLiest oder schreibt 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: `String|Scope` Der Wert oder, wenn `value` übergeben wird, der Scope.\n\nExample: attr() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.attr('title', 'Users');\nconsole.log(scope.attr('title'));  // Users\n```\n\n### scope.attrd(name, [value])\n\nType: `method`\n\nLiest oder schreibt 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|Scope` Der Wert oder, wenn `value` übergeben wird, der Scope.\n\nExample: attrd() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.attrd('id', '5');\nconsole.log(scope.attr('data-id'));  // 5\n```\n\n### scope.attrd2(name)\n\nType: `method`\n\nLiest ein `data-`-Attribut vom Element oder von seinem nächstgelegenen Elternelement, das es besitzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name ohne das Präfix `data-`. |\n\nReturns: `String` Der Wert.\n\nExample: attrd2() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.attrd2('area'));  // main\n```\n\n### scope.css(name, [value])\n\nType: `method`\n\nLiest oder schreibt 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: `String|Scope` Der Wert oder, wenn `value` übergeben wird, der Scope.\n\nExample: css() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.css('display', 'block');\nconsole.log(scope.css('display'));  // block\n```\n\n### scope.autofocus([selector])\n\nType: `method`\n\nSetzt den Fokus auf das erste sichtbare Feld im Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Die Felder. |\n\nReturns: `Scope` Der Scope.\n\nAuf Mobilgeräten macht die Methode nichts.\n\nExample: autofocus() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### scope.remove()\n\nType: `method`\n\nEntfernt den Scope, sein Element und seine Komponenten.\n\nExample: remove() verwenden\n```js\nvar scope = $('ui-plugin').scope();\nscope.remove();\nconsole.log($('ui-plugin').length);  // 0\n```\n","entries":[{"type":"property","name":"path","signature":"scope.path","since":"","deprecated":false},{"type":"property","name":"id","signature":"scope.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"scope.element","since":"","deprecated":false},{"type":"property","name":"config","signature":"scope.config","since":"","deprecated":false},{"type":"property","name":"parent","signature":"scope.parent","since":"","deprecated":false},{"type":"property","name":"isolated","signature":"scope.isolated","since":"","deprecated":false},{"type":"property","name":"elements","signature":"scope.elements","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"scope.plugin","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"scope.makepath(path)","since":"","deprecated":false},{"type":"method","name":"get()","signature":"scope.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"scope.set(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"scope.push(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"scope.update([path], [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"scope.change([path])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"scope.reset([path])","since":"","deprecated":false},{"type":"method","name":"default()","signature":"scope.default([path], [timeout])","since":"","deprecated":false},{"type":"method","name":"can()","signature":"scope.can()","since":"","deprecated":false},{"type":"method","name":"errors()","signature":"scope.errors()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"scope.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"scope.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"apply()","signature":"scope.apply()","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"scope.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"scope.SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"scope.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"scope.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"scope.closest(selector)","since":"","deprecated":false},{"type":"method","name":"append()","signature":"scope.append(value)","since":"","deprecated":false},{"type":"method","name":"event()","signature":"scope.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"scope.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"scope.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"scope.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"scope.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"scope.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"scope.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T14:27:30.824Z"}
{"id":"Jammi89ej61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/scope/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Scope","summary":"Las propiedades y los métodos de un objeto scope.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/scope/\nupdated: 2026-11-18T14:27:30.824Z\n---\n\n# Scope\n\n> Las propiedades y los métodos de un objeto scope.\n\nUn objeto scope representa un elemento [`ui-plugin`](../ui-plugin/) de la página. Los paths que usas a través del objeto son relativos al path del scope. Obtén el objeto con `$(element).scope()`. En [Scopes](../../guides/scopes/) se explica el concepto.\n\n## API\n\n### scope.path\n\nType: `property`\n\nEl path absoluto del scope.\n\nExample: Leer path\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.path);  // users\n```\n\n### scope.id\n\nType: `property`\n\nEl identificador único generado del scope.\n\nEl mismo valor está disponible como `ID`.\n\nExample: Leer id\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.id === scope.ID);  // true\n```\n\n### scope.element\n\nType: `property`\n\nEl elemento del scope como objeto de jQuery.\n\nExample: Leer element\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### scope.config\n\nType: `property`\n\nLa configuración analizada del elemento.\n\nExample: Leer config\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.config.limit);  // 10\n```\n\n### scope.parent\n\nType: `property`\n\nEl scope padre.\n\nLa propiedad es `undefined` en un scope sin padre.\n\nExample: Leer parent\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.parent.path);  // users\n```\n\n### scope.isolated\n\nType: `property`\n\nIndica si el path ignora el scope padre.\n\nExample: Leer isolated\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.isolated);  // false\n```\n\n### scope.elements\n\nType: `property`\n\nLos elementos de los scopes padre y de este scope.\n\nLos elementos son nodos del DOM, y el último es el elemento de este scope.\n\nExample: Leer elements\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.elements.length);  // 2\n```\n\n### scope.plugin\n\nType: `property`\n\nEl [Plugin](../plugin/) conectado al scope.\n\nExample: Leer plugin\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.plugin.name);  // users\n```\n\n### scope.makepath(path)\n\nType: `method`\n\nResuelve un path relativo al scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `String` El path resuelto.\n\n`?` es el path del scope, `?1` es el path del scope padre y `?2` es el path dos niveles más arriba. Cuando ese nivel no existe, se usa el path del scope.\n\nExample: Usar makepath()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.makepath('?.name'));  // users.name\n```\n\n### scope.get([path])\n\nType: `method`\n\nLee un path relativo al scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n\nReturns: `Object` El valor.\n\nSin argumento, el método devuelve el modelo completo.\n\nExample: Usar get()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.set(path, value, [timeout], [reset])\n\nType: `method`\n\nEscribe un valor en un path relativo al scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n| `value` | `Object` | yes |  | El valor. |\n| `timeout` | `Number` | no |  | Un valor de `10` o más retrasa el cambio en milisegundos. Un valor inferior es el tipo del cambio. |\n| `reset` | `Boolean` | no |  | `true` restablece el estado después de un cambio retrasado. |\n\nExample: Usar set()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 2);\nconsole.log(GET('users.page'));  // 2\n```\n\n### scope.push(path, value, [timeout], [reset])\n\nType: `method`\n\nAñade un ítem a un array relativo al scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n| `value` | `Object` | yes |  | El elemento. |\n| `timeout` | `Number` | no |  | Un valor de `10` o más retrasa el cambio en milisegundos. Un valor inferior es el tipo del cambio. |\n| `reset` | `Boolean` | no |  | `true` restablece el estado después de un cambio retrasado. |\n\nExample: Usar push()\n```js\nvar scope = $('ui-plugin').scope();\nscope.push('items', 'A');\nconsole.log(scope.get('items'));  // [\"A\"]\n```\n\n### scope.update([path], [timeout], [reset])\n\nType: `method`\n\nNotifica a los listeners de un path relativo al scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `timeout` | `Number` | no |  | Un valor de `10` o más retrasa el cambio en milisegundos. Un valor inferior es el tipo del cambio. |\n| `reset` | `Boolean` | no |  | `true` restablece el estado. |\n\nExample: Usar update()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(value));  // 5\nwindow.users.page = 5;\nscope.update('page');\n```\n\n### scope.change([path])\n\nType: `method`\n\nMarca los componentes de un path como tocados y modificados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n\nExample: Usar change()\n```js\nvar scope = $('ui-plugin').scope();\nscope.change();\nconsole.log(FIND('field').config.touched);  // true\n```\n\n### scope.reset([path])\n\nType: `method`\n\nLimpia el estado de los componentes de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n\nSe limpia el estado tocado y modificado. El valor no cambia.\n\nExample: Usar reset()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.modify('Peter');\nscope.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### scope.default([path], [timeout])\n\nType: `method`\n\nRestaura el valor predeterminado del scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `timeout` | `Number` | no |  | El retardo en milisegundos. |\n\nEl valor predeterminado viene del atributo [`default`](../ui-plugin/#default) del elemento. Un número como primer argumento es un retardo en milisegundos.\n\nExample: Usar default()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 5);\nscope.default();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.can()\n\nType: `method`\n\nIndica si los componentes del scope se pueden guardar.\n\nReturns: `Boolean` El resultado.\n\nEl resultado es `true` cuando al menos un componente está tocado y ninguno es inválido. Un scope sin componentes devuelve `true`.\n\nExample: Usar can()\n```js\nvar scope = $('ui-plugin').scope();\nFIND('field').modify('Peter');\nconsole.log(scope.can());  // true\n```\n\n### scope.errors()\n\nType: `method`\n\nDevuelve los componentes tocados e inválidos del scope.\n\nReturns: `Array` Los componentes.\n\nExample: Usar errors()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.validate = value => !!value;\ncom.bind('touched');\ncom.validate2();\nconsole.log(scope.errors().length);  // 1\n```\n\n### scope.watch(path, callback, [init])\n\nType: `method`\n\nObserva un path relativo al scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n| `callback` | `Function` | yes |  | La función que recibe los cambios. |\n| `init` | `Boolean` | no |  | `true` llama al callback de inmediato. |\n\nReturns: `Scope` El scope.\n\nEl callback recibe `path`, `value` y `type`, y `this` es el scope.\n\nExample: Usar watch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(path, value));  // users.page 2\nscope.set('page', 2);\n```\n\n### scope.unwatch(path)\n\nType: `method`\n\nElimina los observadores de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n\nReturns: `Scope` El scope.\n\nEl método elimina todos los observadores que este scope tiene en el path.\n\nExample: Usar unwatch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', () => console.log('called'));\nscope.unwatch('page');\nscope.set('page', 2);\nconsole.log('end');  // end\n```\n\n### scope.apply()\n\nType: `method`\n\nActiva el scope.\n\nReturns: `Scope` El scope.\n\nFunciones como `SET()` sustituyen entonces `?` por el path de este scope.\n\nExample: Usar apply()\n```js\nvar scope = $('ui-plugin').scope();\nscope.apply();\nSET('?.page', 3);\nconsole.log(GET('users.page'));  // 3\n```\n\n### scope.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nBusca componentes dentro del scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector del componente. |\n| `many` | `Boolean` | no |  | `true` devuelve un array. |\n| `callback` | `Function` | no |  | Espera al componente y lo recibe. |\n| `timeout` | `Number` | no |  | La espera máxima en milisegundos. |\n\nReturns: `Component|Array` El resultado.\n\nLos argumentos son los mismos que en la extensión `FIND()` de jQuery.\n\nExample: Usar FIND()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.FIND('field').name);  // field\n```\n\n### scope.SETTER(selector, method, [...args])\n\nType: `method`\n\nLlama a un método de los componentes dentro del scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector del componente. |\n| `method` | `String` | yes |  | El nombre del método. |\n| `args` | `Object` | no |  | Los argumentos. |\n\nExample: Usar SETTER()\n```js\nvar scope = $('ui-plugin').scope();\nscope.SETTER('field/reconfigure', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.RECONFIGURE(selector, value)\n\nType: `method`\n\nReconfigura los componentes dentro del scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector del componente. |\n| `value` | `String|Object` | yes |  | La configuración. |\n\nExample: Usar RECONFIGURE()\n```js\nvar scope = $('ui-plugin').scope();\nscope.RECONFIGURE('field', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.find(selector)\n\nType: `method`\n\nBusca elementos anidados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un selector o un objeto de selectores. |\n\nReturns: `jQuery|Object` El resultado.\n\nUn objeto de selectores devuelve un objeto de resultados de jQuery con las mismas claves.\n\nExample: Usar find()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.find('span').length);  // 1\n```\n\n### scope.closest(selector)\n\nType: `method`\n\nBusca el padre coincidente más cercano del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector. |\n\nReturns: `jQuery` El resultado.\n\nExample: Usar closest()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.closest('body').length);  // 1\n```\n\n### scope.append(value)\n\nType: `method`\n\nAñade contenido al final del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | El contenido. |\n\nReturns: `jQuery` El elemento.\n\nSi es un array, se une.\n\nExample: Usar append()\n```js\nvar scope = $('ui-plugin').scope();\nscope.append('<b>A</b>');\nconsole.log(scope.find('b').text());  // A\n```\n\n### scope.event(name, [selector], callback)\n\nType: `method`\n\nAsocia un evento de jQuery al elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `selector` | `String` | no |  | El selector delegado. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nReturns: `Scope` El scope.\n\nLos argumentos son los mismos que en el método `on()` de jQuery.\n\nExample: Usar event()\n```js\nvar scope = $('ui-plugin').scope();\nscope.event('click', 'span', () => console.log('clicked'));  // clicked\nscope.find('span').click();\n```\n\n### scope.attr(name, [value])\n\nType: `method`\n\nLee o escribe 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: `String|Scope` El valor, o el scope cuando se pasa `value`.\n\nExample: Usar attr()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attr('title', 'Users');\nconsole.log(scope.attr('title'));  // Users\n```\n\n### scope.attrd(name, [value])\n\nType: `method`\n\nLee o escribe 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|Scope` El valor, o el scope cuando se pasa `value`.\n\nExample: Usar attrd()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attrd('id', '5');\nconsole.log(scope.attr('data-id'));  // 5\n```\n\n### scope.attrd2(name)\n\nType: `method`\n\nLee un atributo `data-` del elemento o del padre más cercano que lo tenga.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre sin el prefijo `data-`. |\n\nReturns: `String` El valor.\n\nExample: Usar attrd2()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.attrd2('area'));  // main\n```\n\n### scope.css(name, [value])\n\nType: `method`\n\nLee o escribe 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: `String|Scope` El valor, o el scope cuando se pasa `value`.\n\nExample: Usar css()\n```js\nvar scope = $('ui-plugin').scope();\nscope.css('display', 'block');\nconsole.log(scope.css('display'));  // block\n```\n\n### scope.autofocus([selector])\n\nType: `method`\n\nMueve el foco al primer campo visible del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Los campos. |\n\nReturns: `Scope` El scope.\n\nEl método no hace nada en dispositivos móviles.\n\nExample: Usar autofocus()\n```js\nvar scope = $('ui-plugin').scope();\nscope.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### scope.remove()\n\nType: `method`\n\nElimina el scope, su elemento y sus componentes.\n\nExample: Usar remove()\n```js\nvar scope = $('ui-plugin').scope();\nscope.remove();\nconsole.log($('ui-plugin').length);  // 0\n```\n","entries":[{"type":"property","name":"path","signature":"scope.path","since":"","deprecated":false},{"type":"property","name":"id","signature":"scope.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"scope.element","since":"","deprecated":false},{"type":"property","name":"config","signature":"scope.config","since":"","deprecated":false},{"type":"property","name":"parent","signature":"scope.parent","since":"","deprecated":false},{"type":"property","name":"isolated","signature":"scope.isolated","since":"","deprecated":false},{"type":"property","name":"elements","signature":"scope.elements","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"scope.plugin","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"scope.makepath(path)","since":"","deprecated":false},{"type":"method","name":"get()","signature":"scope.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"scope.set(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"scope.push(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"scope.update([path], [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"scope.change([path])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"scope.reset([path])","since":"","deprecated":false},{"type":"method","name":"default()","signature":"scope.default([path], [timeout])","since":"","deprecated":false},{"type":"method","name":"can()","signature":"scope.can()","since":"","deprecated":false},{"type":"method","name":"errors()","signature":"scope.errors()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"scope.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"scope.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"apply()","signature":"scope.apply()","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"scope.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"scope.SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"scope.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"scope.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"scope.closest(selector)","since":"","deprecated":false},{"type":"method","name":"append()","signature":"scope.append(value)","since":"","deprecated":false},{"type":"method","name":"event()","signature":"scope.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"scope.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"scope.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"scope.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"scope.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"scope.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"scope.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T14:27:30.824Z"}
{"id":"Jammi89ej61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/scope/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Scope","summary":"Les propriétés et les méthodes d'un objet scope.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/scope/\nupdated: 2026-11-18T14:27:30.824Z\n---\n\n# Scope\n\n> Les propriétés et les méthodes d'un objet scope.\n\nUn objet scope représente un élément [`ui-plugin`](../ui-plugin/) de la page. Les paths utilisés à travers l'objet sont relatifs au path du scope. Récupère l'objet avec `$(element).scope()`. [Scopes](../../guides/scopes/) explique le concept.\n\n## API\n\n### scope.path\n\nType: `property`\n\nLe path absolu du scope.\n\nExample: Lire path\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.path);  // users\n```\n\n### scope.id\n\nType: `property`\n\nL'identifiant unique généré du scope.\n\nLa même valeur est disponible dans `ID`.\n\nExample: Lire id\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.id === scope.ID);  // true\n```\n\n### scope.element\n\nType: `property`\n\nL'élément du scope sous forme d'objet jQuery.\n\nExample: Lire element\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### scope.config\n\nType: `property`\n\nLa configuration analysée de l'élément.\n\nExample: Lire config\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.config.limit);  // 10\n```\n\n### scope.parent\n\nType: `property`\n\nLe scope parent.\n\nLa propriété vaut `undefined` pour un scope sans parent.\n\nExample: Lire parent\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.parent.path);  // users\n```\n\n### scope.isolated\n\nType: `property`\n\nIndique si le path ignore le scope parent.\n\nExample: Lire isolated\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.isolated);  // false\n```\n\n### scope.elements\n\nType: `property`\n\nLes éléments des scopes parents et de ce scope.\n\nLes éléments sont des nœuds DOM, et le dernier est l'élément de ce scope.\n\nExample: Lire elements\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.elements.length);  // 2\n```\n\n### scope.plugin\n\nType: `property`\n\nLe [Plugin](../plugin/) connecté au scope.\n\nExample: Lire plugin\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.plugin.name);  // users\n```\n\n### scope.makepath(path)\n\nType: `method`\n\nRésout un path relatif au scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `String` Le path résolu.\n\n`?` est le path du scope, `?1` est le path du scope parent et `?2` est le path deux niveaux plus haut. Quand ce niveau n'existe pas, le path du scope est utilisé.\n\nExample: Utiliser makepath()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.makepath('?.name'));  // users.name\n```\n\n### scope.get([path])\n\nType: `method`\n\nLit un path relatif au scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n\nReturns: `Object` La valeur.\n\nSans argument, la méthode renvoie le modèle de données entier.\n\nExample: Utiliser get()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.set(path, value, [timeout], [reset])\n\nType: `method`\n\nÉcrit une valeur dans un path relatif au scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n| `value` | `Object` | yes |  | La valeur. |\n| `timeout` | `Number` | no |  | Une valeur de `10` ou plus retarde la modification, en millisecondes. Une valeur inférieure est le type de la modification. |\n| `reset` | `Boolean` | no |  | `true` réinitialise l'état après une modification retardée. |\n\nExample: Utiliser set()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 2);\nconsole.log(GET('users.page'));  // 2\n```\n\n### scope.push(path, value, [timeout], [reset])\n\nType: `method`\n\nAjoute un élément à un tableau relatif au scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n| `value` | `Object` | yes |  | L'élément. |\n| `timeout` | `Number` | no |  | Une valeur de `10` ou plus retarde la modification, en millisecondes. Une valeur inférieure est le type de la modification. |\n| `reset` | `Boolean` | no |  | `true` réinitialise l'état après une modification retardée. |\n\nExample: Utiliser push()\n```js\nvar scope = $('ui-plugin').scope();\nscope.push('items', 'A');\nconsole.log(scope.get('items'));  // [\"A\"]\n```\n\n### scope.update([path], [timeout], [reset])\n\nType: `method`\n\nNotifie les écouteurs d'un path relatif au scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `timeout` | `Number` | no |  | Une valeur de `10` ou plus retarde la modification, en millisecondes. Une valeur inférieure est le type de la modification. |\n| `reset` | `Boolean` | no |  | `true` réinitialise l'état. |\n\nExample: Utiliser update()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(value));  // 5\nwindow.users.page = 5;\nscope.update('page');\n```\n\n### scope.change([path])\n\nType: `method`\n\nMarque les composants d'un path comme touchés et modifiés.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n\nExample: Utiliser change()\n```js\nvar scope = $('ui-plugin').scope();\nscope.change();\nconsole.log(FIND('field').config.touched);  // true\n```\n\n### scope.reset([path])\n\nType: `method`\n\nEfface l'état des composants d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n\nL'état touché et modifié est effacé. La valeur ne change pas.\n\nExample: Utiliser reset()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.modify('Peter');\nscope.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### scope.default([path], [timeout])\n\nType: `method`\n\nRestaure la valeur par défaut du scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `timeout` | `Number` | no |  | Le délai en millisecondes. |\n\nLa valeur par défaut provient de l'attribut [`default`](../ui-plugin/#default) de l'élément. Un nombre en premier argument est un délai en millisecondes.\n\nExample: Utiliser default()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 5);\nscope.default();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.can()\n\nType: `method`\n\nIndique si les composants du scope peuvent être enregistrés.\n\nReturns: `Boolean` Le résultat.\n\nLe résultat est `true` quand au moins un composant est touché et qu'aucun n'est invalide. Un scope sans composants renvoie `true`.\n\nExample: Utiliser can()\n```js\nvar scope = $('ui-plugin').scope();\nFIND('field').modify('Peter');\nconsole.log(scope.can());  // true\n```\n\n### scope.errors()\n\nType: `method`\n\nRenvoie les composants touchés et invalides du scope.\n\nReturns: `Array` Les composants.\n\nExample: Utiliser errors()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.validate = value => !!value;\ncom.bind('touched');\ncom.validate2();\nconsole.log(scope.errors().length);  // 1\n```\n\n### scope.watch(path, callback, [init])\n\nType: `method`\n\nObserve un path relatif au scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n| `callback` | `Function` | yes |  | La fonction qui reçoit les modifications. |\n| `init` | `Boolean` | no |  | `true` appelle le callback immédiatement. |\n\nReturns: `Scope` Le scope.\n\nLe callback reçoit `path`, `value` et `type`, et `this` est le scope.\n\nExample: Utiliser watch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(path, value));  // users.page 2\nscope.set('page', 2);\n```\n\n### scope.unwatch(path)\n\nType: `method`\n\nSupprime les observateurs d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n\nReturns: `Scope` Le scope.\n\nLa méthode supprime tous les observateurs que ce scope a sur le path.\n\nExample: Utiliser unwatch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', () => console.log('called'));\nscope.unwatch('page');\nscope.set('page', 2);\nconsole.log('end');  // end\n```\n\n### scope.apply()\n\nType: `method`\n\nRend le scope actif.\n\nReturns: `Scope` Le scope.\n\nDes fonctions comme `SET()` remplacent alors `?` par le path de ce scope.\n\nExample: Utiliser apply()\n```js\nvar scope = $('ui-plugin').scope();\nscope.apply();\nSET('?.page', 3);\nconsole.log(GET('users.page'));  // 3\n```\n\n### scope.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nTrouve des composants à l'intérieur du scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur du composant. |\n| `many` | `Boolean` | no |  | `true` renvoie un tableau. |\n| `callback` | `Function` | no |  | Attend le composant et le reçoit. |\n| `timeout` | `Number` | no |  | La durée d'attente maximale en millisecondes. |\n\nReturns: `Component|Array` Le résultat.\n\nLes arguments sont les mêmes que ceux de l'extension jQuery `FIND()`.\n\nExample: Utiliser FIND()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.FIND('field').name);  // field\n```\n\n### scope.SETTER(selector, method, [...args])\n\nType: `method`\n\nAppelle une méthode des composants à l'intérieur du scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur du composant. |\n| `method` | `String` | yes |  | Le nom de la méthode. |\n| `args` | `Object` | no |  | Les arguments. |\n\nExample: Utiliser SETTER()\n```js\nvar scope = $('ui-plugin').scope();\nscope.SETTER('field/reconfigure', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.RECONFIGURE(selector, value)\n\nType: `method`\n\nReconfigure les composants à l'intérieur du scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur du composant. |\n| `value` | `String|Object` | yes |  | La configuration. |\n\nExample: Utiliser RECONFIGURE()\n```js\nvar scope = $('ui-plugin').scope();\nscope.RECONFIGURE('field', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.find(selector)\n\nType: `method`\n\nTrouve des éléments imbriqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un sélecteur ou un objet de sélecteurs. |\n\nReturns: `jQuery|Object` Le résultat.\n\nUn objet de sélecteurs renvoie un objet de résultats jQuery avec les mêmes clés.\n\nExample: Utiliser find()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.find('span').length);  // 1\n```\n\n### scope.closest(selector)\n\nType: `method`\n\nTrouve le parent correspondant le plus proche de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur. |\n\nReturns: `jQuery` Le résultat.\n\nExample: Utiliser closest()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.closest('body').length);  // 1\n```\n\n### scope.append(value)\n\nType: `method`\n\nAjoute du contenu à la fin de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Le contenu. |\n\nReturns: `jQuery` L'élément.\n\nUn tableau est concaténé.\n\nExample: Utiliser append()\n```js\nvar scope = $('ui-plugin').scope();\nscope.append('<b>A</b>');\nconsole.log(scope.find('b').text());  // A\n```\n\n### scope.event(name, [selector], callback)\n\nType: `method`\n\nAttache un événement jQuery à l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `selector` | `String` | no |  | Le sélecteur de délégation. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nReturns: `Scope` Le scope.\n\nLes arguments sont les mêmes que ceux de la méthode jQuery `on()`.\n\nExample: Utiliser event()\n```js\nvar scope = $('ui-plugin').scope();\nscope.event('click', 'span', () => console.log('clicked'));  // clicked\nscope.find('span').click();\n```\n\n### scope.attr(name, [value])\n\nType: `method`\n\nLit ou écrit 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: `String|Scope` La valeur, ou le scope quand `value` est passé.\n\nExample: Utiliser attr()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attr('title', 'Users');\nconsole.log(scope.attr('title'));  // Users\n```\n\n### scope.attrd(name, [value])\n\nType: `method`\n\nLit ou écrit 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|Scope` La valeur, ou le scope quand `value` est passé.\n\nExample: Utiliser attrd()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attrd('id', '5');\nconsole.log(scope.attr('data-id'));  // 5\n```\n\n### scope.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 sans le préfixe `data-`. |\n\nReturns: `String` La valeur.\n\nExample: Utiliser attrd2()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.attrd2('area'));  // main\n```\n\n### scope.css(name, [value])\n\nType: `method`\n\nLit ou écrit 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: `String|Scope` La valeur, ou le scope quand `value` est passé.\n\nExample: Utiliser css()\n```js\nvar scope = $('ui-plugin').scope();\nscope.css('display', 'block');\nconsole.log(scope.css('display'));  // block\n```\n\n### scope.autofocus([selector])\n\nType: `method`\n\nDéplace le focus vers le premier champ visible de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Les champs. |\n\nReturns: `Scope` Le scope.\n\nLa méthode ne fait rien sur les appareils mobiles.\n\nExample: Utiliser autofocus()\n```js\nvar scope = $('ui-plugin').scope();\nscope.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### scope.remove()\n\nType: `method`\n\nSupprime le scope, son élément et ses composants.\n\nExample: Utiliser remove()\n```js\nvar scope = $('ui-plugin').scope();\nscope.remove();\nconsole.log($('ui-plugin').length);  // 0\n```\n","entries":[{"type":"property","name":"path","signature":"scope.path","since":"","deprecated":false},{"type":"property","name":"id","signature":"scope.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"scope.element","since":"","deprecated":false},{"type":"property","name":"config","signature":"scope.config","since":"","deprecated":false},{"type":"property","name":"parent","signature":"scope.parent","since":"","deprecated":false},{"type":"property","name":"isolated","signature":"scope.isolated","since":"","deprecated":false},{"type":"property","name":"elements","signature":"scope.elements","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"scope.plugin","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"scope.makepath(path)","since":"","deprecated":false},{"type":"method","name":"get()","signature":"scope.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"scope.set(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"scope.push(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"scope.update([path], [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"scope.change([path])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"scope.reset([path])","since":"","deprecated":false},{"type":"method","name":"default()","signature":"scope.default([path], [timeout])","since":"","deprecated":false},{"type":"method","name":"can()","signature":"scope.can()","since":"","deprecated":false},{"type":"method","name":"errors()","signature":"scope.errors()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"scope.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"scope.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"apply()","signature":"scope.apply()","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"scope.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"scope.SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"scope.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"scope.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"scope.closest(selector)","since":"","deprecated":false},{"type":"method","name":"append()","signature":"scope.append(value)","since":"","deprecated":false},{"type":"method","name":"event()","signature":"scope.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"scope.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"scope.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"scope.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"scope.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"scope.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"scope.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T14:27:30.824Z"}
{"id":"Jammi89ej61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/scope/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Scope","summary":"Le proprietà e i metodi di un oggetto scope.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/scope/\nupdated: 2026-11-18T14:27:30.824Z\n---\n\n# Scope\n\n> Le proprietà e i metodi di un oggetto scope.\n\nUn oggetto scope rappresenta un elemento [`ui-plugin`](../ui-plugin/) nella pagina. I path usati tramite l'oggetto sono relativi al path dello scope. Ottieni l'oggetto con `$(element).scope()`. [Scope](../../guides/scopes/) spiega il concetto.\n\n## API\n\n### scope.path\n\nType: `property`\n\nIl path assoluto dello scope.\n\nExample: Lettura di path\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.path);  // users\n```\n\n### scope.id\n\nType: `property`\n\nL'identificatore univoco generato dello scope.\n\nLo stesso valore è disponibile come `ID`.\n\nExample: Lettura di id\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.id === scope.ID);  // true\n```\n\n### scope.element\n\nType: `property`\n\nL'elemento dello scope come oggetto jQuery.\n\nExample: Lettura di element\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### scope.config\n\nType: `property`\n\nLa configurazione analizzata dell'elemento.\n\nExample: Lettura di config\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.config.limit);  // 10\n```\n\n### scope.parent\n\nType: `property`\n\nLo scope padre.\n\nLa proprietà è `undefined` per uno scope senza padre.\n\nExample: Lettura di parent\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.parent.path);  // users\n```\n\n### scope.isolated\n\nType: `property`\n\nIndica se il path ignora lo scope padre.\n\nExample: Lettura di isolated\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.isolated);  // false\n```\n\n### scope.elements\n\nType: `property`\n\nGli elementi degli scope padre e di questo scope.\n\nGli elementi sono nodi DOM e l'ultimo è l'elemento di questo scope.\n\nExample: Lettura di elements\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.elements.length);  // 2\n```\n\n### scope.plugin\n\nType: `property`\n\nIl [Plugin](../plugin/) collegato allo scope.\n\nExample: Lettura di plugin\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.plugin.name);  // users\n```\n\n### scope.makepath(path)\n\nType: `method`\n\nRisolve un path relativo allo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `String` Il path risolto.\n\n`?` è il path dello scope, `?1` è il path dello scope padre e `?2` è il path di due livelli sopra. Quando quel livello non esiste, viene usato il path dello scope.\n\nExample: Uso di makepath()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.makepath('?.name'));  // users.name\n```\n\n### scope.get([path])\n\nType: `method`\n\nLegge un path relativo allo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n\nReturns: `Object` Il valore.\n\nSenza argomenti, il metodo restituisce l'intero modello.\n\nExample: Uso di get()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.set(path, value, [timeout], [reset])\n\nType: `method`\n\nScrive un valore in un path relativo allo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n| `value` | `Object` | yes |  | Il valore. |\n| `timeout` | `Number` | no |  | Un valore pari o superiore a `10` ritarda la modifica di quel numero di millisecondi. Un valore inferiore è il tipo della modifica. |\n| `reset` | `Boolean` | no |  | `true` reimposta lo stato dopo una modifica ritardata. |\n\nExample: Uso di set()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 2);\nconsole.log(GET('users.page'));  // 2\n```\n\n### scope.push(path, value, [timeout], [reset])\n\nType: `method`\n\nAggiunge un elemento a un array relativo allo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n| `value` | `Object` | yes |  | L'elemento. |\n| `timeout` | `Number` | no |  | Un valore pari o superiore a `10` ritarda la modifica di quel numero di millisecondi. Un valore inferiore è il tipo della modifica. |\n| `reset` | `Boolean` | no |  | `true` reimposta lo stato dopo una modifica ritardata. |\n\nExample: Uso di push()\n```js\nvar scope = $('ui-plugin').scope();\nscope.push('items', 'A');\nconsole.log(scope.get('items'));  // [\"A\"]\n```\n\n### scope.update([path], [timeout], [reset])\n\nType: `method`\n\nNotifica i listener di un path relativo allo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `timeout` | `Number` | no |  | Un valore pari o superiore a `10` ritarda la modifica di quel numero di millisecondi. Un valore inferiore è il tipo della modifica. |\n| `reset` | `Boolean` | no |  | `true` reimposta lo stato. |\n\nExample: Uso di update()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(value));  // 5\nwindow.users.page = 5;\nscope.update('page');\n```\n\n### scope.change([path])\n\nType: `method`\n\nSegna i componenti di un path come toccati e modificati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n\nExample: Uso di change()\n```js\nvar scope = $('ui-plugin').scope();\nscope.change();\nconsole.log(FIND('field').config.touched);  // true\n```\n\n### scope.reset([path])\n\nType: `method`\n\nAzzera lo stato dei componenti di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n\nLo stato di toccato e modificato viene azzerato. Il valore non cambia.\n\nExample: Uso di reset()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.modify('Peter');\nscope.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### scope.default([path], [timeout])\n\nType: `method`\n\nRipristina il valore predefinito dello scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `timeout` | `Number` | no |  | Il ritardo in millisecondi. |\n\nIl valore predefinito proviene dall'attributo [`default`](../ui-plugin/#default) dell'elemento. Un numero come primo argomento è un ritardo in millisecondi.\n\nExample: Uso di default()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 5);\nscope.default();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.can()\n\nType: `method`\n\nIndica se i componenti dello scope possono essere salvati.\n\nReturns: `Boolean` Il risultato.\n\nIl risultato è `true` quando almeno un componente è toccato e nessuno è non valido. Uno scope senza componenti restituisce `true`.\n\nExample: Uso di can()\n```js\nvar scope = $('ui-plugin').scope();\nFIND('field').modify('Peter');\nconsole.log(scope.can());  // true\n```\n\n### scope.errors()\n\nType: `method`\n\nRestituisce i componenti toccati e non validi dello scope.\n\nReturns: `Array` I componenti.\n\nExample: Uso di errors()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.validate = value => !!value;\ncom.bind('touched');\ncom.validate2();\nconsole.log(scope.errors().length);  // 1\n```\n\n### scope.watch(path, callback, [init])\n\nType: `method`\n\nOsserva un path relativo allo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n| `callback` | `Function` | yes |  | La funzione che riceve le modifiche. |\n| `init` | `Boolean` | no |  | `true` chiama subito il callback. |\n\nReturns: `Scope` Lo scope.\n\nIl callback riceve `path`, `value` e `type`, e `this` è lo scope.\n\nExample: Uso di watch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(path, value));  // users.page 2\nscope.set('page', 2);\n```\n\n### scope.unwatch(path)\n\nType: `method`\n\nRimuove gli osservatori di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n\nReturns: `Scope` Lo scope.\n\nIl metodo rimuove tutti gli osservatori che questo scope ha sul path.\n\nExample: Uso di unwatch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', () => console.log('called'));\nscope.unwatch('page');\nscope.set('page', 2);\nconsole.log('end');  // end\n```\n\n### scope.apply()\n\nType: `method`\n\nRende attivo lo scope.\n\nReturns: `Scope` Lo scope.\n\nFunzioni come `SET()` sostituiscono allora `?` con il path di questo scope.\n\nExample: Uso di apply()\n```js\nvar scope = $('ui-plugin').scope();\nscope.apply();\nSET('?.page', 3);\nconsole.log(GET('users.page'));  // 3\n```\n\n### scope.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nTrova i componenti dentro lo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore del componente. |\n| `many` | `Boolean` | no |  | `true` restituisce un array. |\n| `callback` | `Function` | no |  | Attende il componente e lo riceve. |\n| `timeout` | `Number` | no |  | L'attesa massima in millisecondi. |\n\nReturns: `Component|Array` Il risultato.\n\nGli argomenti sono gli stessi dell'estensione jQuery `FIND()`.\n\nExample: Uso di FIND()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.FIND('field').name);  // field\n```\n\n### scope.SETTER(selector, method, [...args])\n\nType: `method`\n\nChiama un metodo dei componenti dentro lo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore del componente. |\n| `method` | `String` | yes |  | Il nome del metodo. |\n| `args` | `Object` | no |  | Gli argomenti. |\n\nExample: Uso di SETTER()\n```js\nvar scope = $('ui-plugin').scope();\nscope.SETTER('field/reconfigure', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.RECONFIGURE(selector, value)\n\nType: `method`\n\nRiconfigura i componenti dentro lo scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore del componente. |\n| `value` | `String|Object` | yes |  | La configurazione. |\n\nExample: Uso di RECONFIGURE()\n```js\nvar scope = $('ui-plugin').scope();\nscope.RECONFIGURE('field', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.find(selector)\n\nType: `method`\n\nTrova gli elementi annidati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un selettore o un oggetto di selettori. |\n\nReturns: `jQuery|Object` Il risultato.\n\nUn oggetto di selettori restituisce un oggetto di risultati jQuery con le stesse chiavi.\n\nExample: Uso di find()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.find('span').length);  // 1\n```\n\n### scope.closest(selector)\n\nType: `method`\n\nTrova il genitore corrispondente più vicino all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore. |\n\nReturns: `jQuery` Il risultato.\n\nExample: Uso di closest()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.closest('body').length);  // 1\n```\n\n### scope.append(value)\n\nType: `method`\n\nAggiunge contenuto alla fine dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Il contenuto. |\n\nReturns: `jQuery` L'elemento.\n\nUn array viene unito.\n\nExample: Uso di append()\n```js\nvar scope = $('ui-plugin').scope();\nscope.append('<b>A</b>');\nconsole.log(scope.find('b').text());  // A\n```\n\n### scope.event(name, [selector], callback)\n\nType: `method`\n\nCollega un evento jQuery all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `selector` | `String` | no |  | Il selettore delegato. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nReturns: `Scope` Lo scope.\n\nGli argomenti sono gli stessi del metodo jQuery `on()`.\n\nExample: Uso di event()\n```js\nvar scope = $('ui-plugin').scope();\nscope.event('click', 'span', () => console.log('clicked'));  // clicked\nscope.find('span').click();\n```\n\n### scope.attr(name, [value])\n\nType: `method`\n\nLegge o scrive 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: `String|Scope` Il valore, oppure lo scope quando passi `value`.\n\nExample: Uso di attr()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attr('title', 'Users');\nconsole.log(scope.attr('title'));  // Users\n```\n\n### scope.attrd(name, [value])\n\nType: `method`\n\nLegge o scrive 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|Scope` Il valore, oppure lo scope quando passi `value`.\n\nExample: Uso di attrd()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attrd('id', '5');\nconsole.log(scope.attr('data-id'));  // 5\n```\n\n### scope.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 senza il prefisso `data-`. |\n\nReturns: `String` Il valore.\n\nExample: Uso di attrd2()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.attrd2('area'));  // main\n```\n\n### scope.css(name, [value])\n\nType: `method`\n\nLegge o scrive 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: `String|Scope` Il valore, oppure lo scope quando passi `value`.\n\nExample: Uso di css()\n```js\nvar scope = $('ui-plugin').scope();\nscope.css('display', 'block');\nconsole.log(scope.css('display'));  // block\n```\n\n### scope.autofocus([selector])\n\nType: `method`\n\nSposta il focus sul primo campo visibile dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | I campi. |\n\nReturns: `Scope` Lo scope.\n\nSui dispositivi mobili il metodo non fa nulla.\n\nExample: Uso di autofocus()\n```js\nvar scope = $('ui-plugin').scope();\nscope.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### scope.remove()\n\nType: `method`\n\nRimuove lo scope, il relativo elemento e i relativi componenti.\n\nExample: Uso di remove()\n```js\nvar scope = $('ui-plugin').scope();\nscope.remove();\nconsole.log($('ui-plugin').length);  // 0\n```\n","entries":[{"type":"property","name":"path","signature":"scope.path","since":"","deprecated":false},{"type":"property","name":"id","signature":"scope.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"scope.element","since":"","deprecated":false},{"type":"property","name":"config","signature":"scope.config","since":"","deprecated":false},{"type":"property","name":"parent","signature":"scope.parent","since":"","deprecated":false},{"type":"property","name":"isolated","signature":"scope.isolated","since":"","deprecated":false},{"type":"property","name":"elements","signature":"scope.elements","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"scope.plugin","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"scope.makepath(path)","since":"","deprecated":false},{"type":"method","name":"get()","signature":"scope.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"scope.set(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"scope.push(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"scope.update([path], [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"scope.change([path])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"scope.reset([path])","since":"","deprecated":false},{"type":"method","name":"default()","signature":"scope.default([path], [timeout])","since":"","deprecated":false},{"type":"method","name":"can()","signature":"scope.can()","since":"","deprecated":false},{"type":"method","name":"errors()","signature":"scope.errors()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"scope.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"scope.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"apply()","signature":"scope.apply()","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"scope.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"scope.SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"scope.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"scope.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"scope.closest(selector)","since":"","deprecated":false},{"type":"method","name":"append()","signature":"scope.append(value)","since":"","deprecated":false},{"type":"method","name":"event()","signature":"scope.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"scope.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"scope.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"scope.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"scope.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"scope.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"scope.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T14:27:30.824Z"}
{"id":"Jammi89ej61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/scope/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Scope","summary":"Vlastnosti a metódy objektu scope.","markdown":"---\ntitle: Scope\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/scope/\nupdated: 2026-11-18T14:27:30.824Z\n---\n\n# Scope\n\n> Vlastnosti a metódy objektu scope.\n\nObjekt scope predstavuje element [`ui-plugin`](../ui-plugin/) na stránke. Path použité cez tento objekt sú relatívne k path scopu. Objekt získaš pomocou `$(element).scope()`. Koncept vysvetľuje časť [Scopy](../../guides/scopes/).\n\n## API\n\n### scope.path\n\nType: `property`\n\nAbsolútna path scopu.\n\nExample: Čítanie path\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.path);  // users\n```\n\n### scope.id\n\nType: `property`\n\nJedinečný vygenerovaný identifikátor scopu.\n\nRovnaká hodnota je dostupná ako `ID`.\n\nExample: Čítanie id\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.id === scope.ID);  // true\n```\n\n### scope.element\n\nType: `property`\n\nElement scopu ako objekt jQuery.\n\nExample: Čítanie element\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### scope.config\n\nType: `property`\n\nSpracovaná konfigurácia elementu.\n\nExample: Čítanie config\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.config.limit);  // 10\n```\n\n### scope.parent\n\nType: `property`\n\nNadradený scope.\n\nPri scope bez nadradeného scopu je vlastnosť `undefined`.\n\nExample: Čítanie parent\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.parent.path);  // users\n```\n\n### scope.isolated\n\nType: `property`\n\nUrčuje, či path ignoruje nadradený scope.\n\nExample: Čítanie isolated\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.isolated);  // false\n```\n\n### scope.elements\n\nType: `property`\n\nElementy nadradených scopov a tohto scopu.\n\nElementy sú uzly DOM a posledný z nich je element tohto scopu.\n\nExample: Čítanie elements\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.elements.length);  // 2\n```\n\n### scope.plugin\n\nType: `property`\n\n[Plugin](../plugin/) pripojený k scopu.\n\nExample: Čítanie plugin\n```js\nvar scope = $('span').last().scope();\nconsole.log(scope.plugin.name);  // users\n```\n\n### scope.makepath(path)\n\nType: `method`\n\nPreloží path relatívnu k scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `String` Preložená path.\n\n`?` je path scopu, `?1` je path nadradeného scopu a `?2` je path o dve úrovne vyššie. Ak daná úroveň neexistuje, použije sa path scopu.\n\nExample: Použitie makepath()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.makepath('?.name'));  // users.name\n```\n\n### scope.get([path])\n\nType: `method`\n\nPrečíta path relatívnu k scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n\nReturns: `Object` Hodnota.\n\nBez argumentu metóda vráti celý model.\n\nExample: Použitie get()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.set(path, value, [timeout], [reset])\n\nType: `method`\n\nZapíše hodnotu na path relatívnu k scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `timeout` | `Number` | no |  | Hodnota `10` alebo vyššia oneskorí zmenu o zadaný počet milisekúnd. Nižšia hodnota je typ zmeny. |\n| `reset` | `Boolean` | no |  | `true` po oneskorenej zmene resetuje stav. |\n\nExample: Použitie set()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 2);\nconsole.log(GET('users.page'));  // 2\n```\n\n### scope.push(path, value, [timeout], [reset])\n\nType: `method`\n\nPridá položku do poľa relatívneho k scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n| `value` | `Object` | yes |  | Položka. |\n| `timeout` | `Number` | no |  | Hodnota `10` alebo vyššia oneskorí zmenu o zadaný počet milisekúnd. Nižšia hodnota je typ zmeny. |\n| `reset` | `Boolean` | no |  | `true` po oneskorenej zmene resetuje stav. |\n\nExample: Použitie push()\n```js\nvar scope = $('ui-plugin').scope();\nscope.push('items', 'A');\nconsole.log(scope.get('items'));  // [\"A\"]\n```\n\n### scope.update([path], [timeout], [reset])\n\nType: `method`\n\nUpozorní poslucháčov path relatívnej k scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `timeout` | `Number` | no |  | Hodnota `10` alebo vyššia oneskorí zmenu o zadaný počet milisekúnd. Nižšia hodnota je typ zmeny. |\n| `reset` | `Boolean` | no |  | `true` resetuje stav. |\n\nExample: Použitie update()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(value));  // 5\nwindow.users.page = 5;\nscope.update('page');\n```\n\n### scope.change([path])\n\nType: `method`\n\nOznačí komponenty na path ako dotknuté a upravené.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n\nExample: Použitie change()\n```js\nvar scope = $('ui-plugin').scope();\nscope.change();\nconsole.log(FIND('field').config.touched);  // true\n```\n\n### scope.reset([path])\n\nType: `method`\n\nVymaže stav komponentov na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n\nVymaže sa stav dotknutia a úpravy. Hodnota sa nezmení.\n\nExample: Použitie reset()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.modify('Peter');\nscope.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### scope.default([path], [timeout])\n\nType: `method`\n\nObnoví predvolenú hodnotu scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nPredvolená hodnota pochádza z atribútu [`default`](../ui-plugin/#default) elementu. Číslo ako prvý argument je oneskorenie v milisekundách.\n\nExample: Použitie default()\n```js\nvar scope = $('ui-plugin').scope();\nscope.set('page', 5);\nscope.default();\nconsole.log(scope.get('page'));  // 1\n```\n\n### scope.can()\n\nType: `method`\n\nUrčuje, či sa komponenty v scope dajú uložiť.\n\nReturns: `Boolean` Výsledok.\n\nVýsledok je `true`, keď je aspoň jeden komponent dotknutý a žiadny nie je neplatný. Scope bez komponentov vráti `true`.\n\nExample: Použitie can()\n```js\nvar scope = $('ui-plugin').scope();\nFIND('field').modify('Peter');\nconsole.log(scope.can());  // true\n```\n\n### scope.errors()\n\nType: `method`\n\nVráti dotknuté a neplatné komponenty scopu.\n\nReturns: `Array` Komponenty.\n\nExample: Použitie errors()\n```js\nvar scope = $('ui-plugin').scope();\nvar com = FIND('field');\ncom.validate = value => !!value;\ncom.bind('touched');\ncom.validate2();\nconsole.log(scope.errors().length);  // 1\n```\n\n### scope.watch(path, callback, [init])\n\nType: `method`\n\nSleduje path relatívnu k scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostáva zmeny. |\n| `init` | `Boolean` | no |  | `true` zavolá callback okamžite. |\n\nReturns: `Scope` Scope.\n\nCallback dostane `path`, `value` a `type` a `this` je scope.\n\nExample: Použitie watch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', (path, value) => console.log(path, value));  // users.page 2\nscope.set('page', 2);\n```\n\n### scope.unwatch(path)\n\nType: `method`\n\nOdstráni sledovače path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n\nReturns: `Scope` Scope.\n\nMetóda odstráni všetky sledovače, ktoré má tento scope na danej path.\n\nExample: Použitie unwatch()\n```js\nvar scope = $('ui-plugin').scope();\nscope.watch('page', () => console.log('called'));\nscope.unwatch('page');\nscope.set('page', 2);\nconsole.log('end');  // end\n```\n\n### scope.apply()\n\nType: `method`\n\nAktivuje scope.\n\nReturns: `Scope` Scope.\n\nFunkcie ako `SET()` potom nahradia `?` za path tohto scopu.\n\nExample: Použitie apply()\n```js\nvar scope = $('ui-plugin').scope();\nscope.apply();\nSET('?.page', 3);\nconsole.log(GET('users.page'));  // 3\n```\n\n### scope.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nNájde komponenty vnútri scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor komponentu. |\n| `many` | `Boolean` | no |  | `true` vráti pole. |\n| `callback` | `Function` | no |  | Počká na komponent a dostane ho. |\n| `timeout` | `Number` | no |  | Najdlhšie čakanie v milisekundách. |\n\nReturns: `Component|Array` Výsledok.\n\nArgumenty sú rovnaké ako pri rozšírení jQuery `FIND()`.\n\nExample: Použitie FIND()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.FIND('field').name);  // field\n```\n\n### scope.SETTER(selector, method, [...args])\n\nType: `method`\n\nZavolá metódu komponentov vnútri scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor komponentu. |\n| `method` | `String` | yes |  | Názov metódy. |\n| `args` | `Object` | no |  | Argumenty. |\n\nExample: Použitie SETTER()\n```js\nvar scope = $('ui-plugin').scope();\nscope.SETTER('field/reconfigure', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.RECONFIGURE(selector, value)\n\nType: `method`\n\nZmení konfiguráciu komponentov vnútri scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor komponentu. |\n| `value` | `String|Object` | yes |  | Konfigurácia. |\n\nExample: Použitie RECONFIGURE()\n```js\nvar scope = $('ui-plugin').scope();\nscope.RECONFIGURE('field', 'title:Orders');\nconsole.log(FIND('field').config.title);  // Orders\n```\n\n### scope.find(selector)\n\nType: `method`\n\nNájde vnorené elementy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Selektor alebo objekt selektorov. |\n\nReturns: `jQuery|Object` Výsledok.\n\nObjekt selektorov vráti objekt výsledkov jQuery s rovnakými kľúčmi.\n\nExample: Použitie find()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.find('span').length);  // 1\n```\n\n### scope.closest(selector)\n\nType: `method`\n\nNájde najbližší zodpovedajúci nadradený element elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor. |\n\nReturns: `jQuery` Výsledok.\n\nExample: Použitie closest()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.closest('body').length);  // 1\n```\n\n### scope.append(value)\n\nType: `method`\n\nPridá obsah na koniec elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Obsah. |\n\nReturns: `jQuery` Element.\n\nPole sa spojí.\n\nExample: Použitie append()\n```js\nvar scope = $('ui-plugin').scope();\nscope.append('<b>A</b>');\nconsole.log(scope.find('b').text());  // A\n```\n\n### scope.event(name, [selector], callback)\n\nType: `method`\n\nPripojí k elementu udalosť jQuery.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `selector` | `String` | no |  | Delegovaný selektor. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nReturns: `Scope` Scope.\n\nArgumenty sú rovnaké ako pri metóde jQuery `on()`.\n\nExample: Použitie event()\n```js\nvar scope = $('ui-plugin').scope();\nscope.event('click', 'span', () => console.log('clicked'));  // clicked\nscope.find('span').click();\n```\n\n### scope.attr(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše 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: `String|Scope` Hodnota, alebo scope, keď odovzdáš `value`.\n\nExample: Použitie attr()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attr('title', 'Users');\nconsole.log(scope.attr('title'));  // Users\n```\n\n### scope.attrd(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše 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|Scope` Hodnota, alebo scope, keď odovzdáš `value`.\n\nExample: Použitie attrd()\n```js\nvar scope = $('ui-plugin').scope();\nscope.attrd('id', '5');\nconsole.log(scope.attr('data-id'));  // 5\n```\n\n### scope.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 bez prefixu `data-`. |\n\nReturns: `String` Hodnota.\n\nExample: Použitie attrd2()\n```js\nvar scope = $('ui-plugin').scope();\nconsole.log(scope.attrd2('area'));  // main\n```\n\n### scope.css(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše vlastnosť CSS elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Vlastnosť. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Scope` Hodnota, alebo scope, keď odovzdáš `value`.\n\nExample: Použitie css()\n```js\nvar scope = $('ui-plugin').scope();\nscope.css('display', 'block');\nconsole.log(scope.css('display'));  // block\n```\n\n### scope.autofocus([selector])\n\nType: `method`\n\nPresunie fokus na prvé viditeľné pole v elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Polia. |\n\nReturns: `Scope` Scope.\n\nNa mobilných zariadeniach metóda nerobí nič.\n\nExample: Použitie autofocus()\n```js\nvar scope = $('ui-plugin').scope();\nscope.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### scope.remove()\n\nType: `method`\n\nOdstráni scope, jeho element a jeho komponenty.\n\nExample: Použitie remove()\n```js\nvar scope = $('ui-plugin').scope();\nscope.remove();\nconsole.log($('ui-plugin').length);  // 0\n```\n","entries":[{"type":"property","name":"path","signature":"scope.path","since":"","deprecated":false},{"type":"property","name":"id","signature":"scope.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"scope.element","since":"","deprecated":false},{"type":"property","name":"config","signature":"scope.config","since":"","deprecated":false},{"type":"property","name":"parent","signature":"scope.parent","since":"","deprecated":false},{"type":"property","name":"isolated","signature":"scope.isolated","since":"","deprecated":false},{"type":"property","name":"elements","signature":"scope.elements","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"scope.plugin","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"scope.makepath(path)","since":"","deprecated":false},{"type":"method","name":"get()","signature":"scope.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"scope.set(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"scope.push(path, value, [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"scope.update([path], [timeout], [reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"scope.change([path])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"scope.reset([path])","since":"","deprecated":false},{"type":"method","name":"default()","signature":"scope.default([path], [timeout])","since":"","deprecated":false},{"type":"method","name":"can()","signature":"scope.can()","since":"","deprecated":false},{"type":"method","name":"errors()","signature":"scope.errors()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"scope.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"scope.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"apply()","signature":"scope.apply()","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"scope.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"scope.SETTER(selector, method, [...args])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"scope.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"scope.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"scope.closest(selector)","since":"","deprecated":false},{"type":"method","name":"append()","signature":"scope.append(value)","since":"","deprecated":false},{"type":"method","name":"event()","signature":"scope.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"scope.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"scope.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"scope.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"scope.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"scope.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"scope.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T14:27:30.824Z"}
{"id":"JammnS4Ir61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/vbinder/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Virtual binder","summary":"The properties and methods of the objects created by VBIND() and VBINDARRAY().","markdown":"---\ntitle: Virtual binder\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/vbinder/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Virtual binder\n\n> The properties and methods of the objects created by VBIND() and VBINDARRAY().\n\nA virtual binder renders an HTML fragment from its own model, without using the global data model. `VBIND()` creates one binder, and `VBINDARRAY()` creates a list with one binder per item. Paths inside the fragment start with a dot. [Virtual bindings](../../guides/virtual-bindings/) explains the concept.\n\n## API\n\n### binder.element\n\nType: `property`\n\nThe rendered fragment as a jQuery object.\n\nAdd it to the page yourself.\n\nExample: Inserting the fragment\n```js\nbinder.element.appendTo('body');\nconsole.log(binder.element.attr('class'));  // row\n```\n\n### binder.binders\n\nType: `property`\n\nThe binders found in the fragment.\n\nSee the [`refresh()`](../ui-bind/#refresh) and [`exec()`](../ui-bind/#exec) methods.\n\nExample: Counting binders\n```js\nconsole.log(binder.binders.length);  // 1\n```\n\n### binder.value\n\nType: `property`\n\nThe current model.\n\nExample: Reading the model\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.value.name);  // Peter\n```\n\n### binder.set([path], value, [skipchecksum])\n\nType: `method`\n\nReplaces the model or changes a field of it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The path inside the model. |\n| `value` | `Object` | yes |  | The model or the value of the field. |\n| `skipchecksum` | `Boolean` | no |  | `true` skips the checksum of an item in `VBINDARRAY()`. |\n\nReturns: `VBinder` The binder.\n\nWith one argument, the value becomes the whole model. With a path, the model must already exist and the value must not be `null`.\n\nExample: Using set()\n```js\nbinder.set({ name: 'Peter' });\nbinder.set('name', 'Anna');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.get([path])\n\nType: `method`\n\nReads the model or a field of it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The path inside the model. |\n\nReturns: `Object` The value.\n\nExample: Using get()\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.get('name'));  // Peter\nconsole.log(binder.get());  // {\"name\":\"Peter\"}\n```\n\n### binder.upd([path], [skipchecksum])\n\nType: `method`\n\nRenders the fragment again.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The path inside the model. |\n| `skipchecksum` | `Boolean` | no |  | `true` skips the checksum of an item in `VBINDARRAY()`. |\n\nReturns: `VBinder` The binder.\n\nWith a path, only the binders of that path run.\n\nExample: Using upd()\n```js\nbinder.set({ name: 'Peter' });\nbinder.value.name = 'Anna';\nbinder.upd('name');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.on(name, [selector], callback)\n\nType: `method`\n\nAttaches a jQuery event to the fragment.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `selector` | `String` | no |  | The delegated selector. |\n| `callback` | `Function` | yes |  | The handler. |\n\nReturns: `VBinder` The binder.\n\nThe arguments are the same as in the jQuery `on()` method.\n\nExample: Using on()\n```js\nbinder.on('click', 'ui-bind', () => console.log('clicked'));  // clicked\nbinder.element.find('ui-bind').click();\n```\n\n### binder.remove()\n\nType: `method`\n\nRemoves the fragment and releases the binder.\n\nReturns: `Object` Always `null`.\n\nExample: Using remove()\n```js\nbinder.remove();\nconsole.log($('.row').length, binder.element);  // 0 null\n```\n\n### list.items\n\nType: `property`\n\nThe binders of a `VBINDARRAY()` list.\n\nEach item is a virtual binder with the additional properties `index` and `vbindarray`.\n\nExample: Reading the items\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log(items.items.length, items.items[1].index);  // 2 1\n```\n\n### list.set(array) or list.set(index, value)\n\nType: `method`\n\nRenders an array or changes one item.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `array` | `Array|Number` | yes |  | The array, or the index of the item. |\n| `value` | `Object` | no |  | The new item. |\n\nAn array renders the list. An index replaces the item at that position. `null` removes all rendered items.\n\nExample: Using list.set()\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nitems.set(1, { name: 'Lucia' });\nconsole.log($('#list').text());  // PeterLucia\n```\n\n### list.get([index])\n\nType: `method`\n\nReads the array or one item.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | The index of the item. |\n\nReturns: `Object|Array` The value.\n\nExample: Using list.get()\n```js\nitems.set([{ name: 'Peter' }]);\nconsole.log(items.get(0).name, items.get().length);  // Peter 1\n```\n\n### list.upd([index])\n\nType: `method`\n\nRenders the list or one item again.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | The index of the item. |\n\nReturns: `Object` The list.\n\nExample: Using list.upd()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.get(0).name = 'Anna';\nitems.upd(0);\nconsole.log($('#list').text());  // Anna\n```\n\n### list.remove()\n\nType: `method`\n\nRemoves all items and releases the list.\n\nExample: Using list.remove()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.remove();\nconsole.log($('#list').html() === '');  // true\n```\n","entries":[{"type":"property","name":"element","signature":"binder.element","since":"","deprecated":false},{"type":"property","name":"binders","signature":"binder.binders","since":"","deprecated":false},{"type":"property","name":"value","signature":"binder.value","since":"","deprecated":false},{"type":"method","name":"set()","signature":"binder.set([path], value, [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"binder.get([path])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"binder.upd([path], [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"binder.on(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"binder.remove()","since":"","deprecated":false},{"type":"property","name":"items","signature":"list.items","since":"","deprecated":false},{"type":"method","name":"list.set()","signature":"list.set(array) or list.set(index, value)","since":"","deprecated":false},{"type":"method","name":"list.get()","signature":"list.get([index])","since":"","deprecated":false},{"type":"method","name":"list.upd()","signature":"list.upd([index])","since":"","deprecated":false},{"type":"method","name":"list.remove()","signature":"list.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammnS4Ir61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/vbinder/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Virtueller Binder","summary":"Die Eigenschaften und Methoden der Objekte, die VBIND() und VBINDARRAY() erstellen.","markdown":"---\ntitle: Virtueller Binder\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/vbinder/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Virtueller Binder\n\n> Die Eigenschaften und Methoden der Objekte, die VBIND() und VBINDARRAY() erstellen.\n\nEin virtueller Binder rendert ein HTML-Fragment aus seinem eigenen Modell, ohne das globale Datenmodell zu verwenden. `VBIND()` erstellt einen Binder und `VBINDARRAY()` eine Liste mit einem Binder pro Eintrag. Paths innerhalb des Fragments beginnen mit einem Punkt. [Virtuelle Bindungen](../../guides/virtual-bindings/) erklärt das Konzept.\n\n## API\n\n### binder.element\n\nType: `property`\n\nDas gerenderte Fragment als jQuery-Objekt.\n\nFüge es selbst in die Seite ein.\n\nExample: Das Fragment einfügen\n```js\nbinder.element.appendTo('body');\nconsole.log(binder.element.attr('class'));  // row\n```\n\n### binder.binders\n\nType: `property`\n\nDie im Fragment gefundenen Binder.\n\nSiehe die Methoden [`refresh()`](../ui-bind/#refresh) und [`exec()`](../ui-bind/#exec).\n\nExample: Binder zählen\n```js\nconsole.log(binder.binders.length);  // 1\n```\n\n### binder.value\n\nType: `property`\n\nDas aktuelle Modell.\n\nExample: Das Modell lesen\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.value.name);  // Peter\n```\n\n### binder.set([path], value, [skipchecksum])\n\nType: `method`\n\nErsetzt das Modell oder ändert eines seiner Felder.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der Path innerhalb des Modells. |\n| `value` | `Object` | yes |  | Das Modell oder der Wert des Felds. |\n| `skipchecksum` | `Boolean` | no |  | `true` überspringt die Prüfsumme eines Eintrags in `VBINDARRAY()`. |\n\nReturns: `VBinder` Der Binder.\n\nMit einem Argument wird der Wert zum gesamten Modell. Mit einem Path muss das Modell bereits existieren und der Wert darf nicht `null` sein.\n\nExample: set() verwenden\n```js\nbinder.set({ name: 'Peter' });\nbinder.set('name', 'Anna');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.get([path])\n\nType: `method`\n\nLiest das Modell oder eines seiner Felder.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der Path innerhalb des Modells. |\n\nReturns: `Object` Der Wert.\n\nExample: get() verwenden\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.get('name'));  // Peter\nconsole.log(binder.get());  // {\"name\":\"Peter\"}\n```\n\n### binder.upd([path], [skipchecksum])\n\nType: `method`\n\nRendert das Fragment erneut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der Path innerhalb des Modells. |\n| `skipchecksum` | `Boolean` | no |  | `true` überspringt die Prüfsumme eines Eintrags in `VBINDARRAY()`. |\n\nReturns: `VBinder` Der Binder.\n\nMit einem Path laufen nur die Binder dieses Paths.\n\nExample: upd() verwenden\n```js\nbinder.set({ name: 'Peter' });\nbinder.value.name = 'Anna';\nbinder.upd('name');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.on(name, [selector], callback)\n\nType: `method`\n\nHängt ein jQuery-Event an das Fragment an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `selector` | `String` | no |  | Der delegierte Selektor. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nReturns: `VBinder` Der Binder.\n\nDie Argumente sind dieselben wie bei der jQuery-Methode `on()`.\n\nExample: on() verwenden\n```js\nbinder.on('click', 'ui-bind', () => console.log('clicked'));  // clicked\nbinder.element.find('ui-bind').click();\n```\n\n### binder.remove()\n\nType: `method`\n\nEntfernt das Fragment und gibt den Binder frei.\n\nReturns: `Object` Immer `null`.\n\nExample: remove() verwenden\n```js\nbinder.remove();\nconsole.log($('.row').length, binder.element);  // 0 null\n```\n\n### list.items\n\nType: `property`\n\nDie Binder einer `VBINDARRAY()`-Liste.\n\nJeder Eintrag ist ein virtueller Binder mit den zusätzlichen Eigenschaften `index` und `vbindarray`.\n\nExample: Die Einträge lesen\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log(items.items.length, items.items[1].index);  // 2 1\n```\n\n### list.set(array) or list.set(index, value)\n\nType: `method`\n\nRendert ein Array oder ändert einen Eintrag.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `array` | `Array|Number` | yes |  | Das Array oder der Index des Eintrags. |\n| `value` | `Object` | no |  | Der neue Eintrag. |\n\nEin Array rendert die Liste. Ein Index ersetzt den Eintrag an dieser Position. `null` entfernt alle gerenderten Einträge.\n\nExample: list.set() verwenden\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nitems.set(1, { name: 'Lucia' });\nconsole.log($('#list').text());  // PeterLucia\n```\n\n### list.get([index])\n\nType: `method`\n\nLiest das Array oder einen Eintrag.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | Der Index des Eintrags. |\n\nReturns: `Object|Array` Der Wert.\n\nExample: list.get() verwenden\n```js\nitems.set([{ name: 'Peter' }]);\nconsole.log(items.get(0).name, items.get().length);  // Peter 1\n```\n\n### list.upd([index])\n\nType: `method`\n\nRendert die Liste oder einen Eintrag erneut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | Der Index des Eintrags. |\n\nReturns: `Object` Die Liste.\n\nExample: list.upd() verwenden\n```js\nitems.set([{ name: 'Peter' }]);\nitems.get(0).name = 'Anna';\nitems.upd(0);\nconsole.log($('#list').text());  // Anna\n```\n\n### list.remove()\n\nType: `method`\n\nEntfernt alle Einträge und gibt die Liste frei.\n\nExample: list.remove() verwenden\n```js\nitems.set([{ name: 'Peter' }]);\nitems.remove();\nconsole.log($('#list').html() === '');  // true\n```\n","entries":[{"type":"property","name":"element","signature":"binder.element","since":"","deprecated":false},{"type":"property","name":"binders","signature":"binder.binders","since":"","deprecated":false},{"type":"property","name":"value","signature":"binder.value","since":"","deprecated":false},{"type":"method","name":"set()","signature":"binder.set([path], value, [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"binder.get([path])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"binder.upd([path], [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"binder.on(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"binder.remove()","since":"","deprecated":false},{"type":"property","name":"items","signature":"list.items","since":"","deprecated":false},{"type":"method","name":"list.set()","signature":"list.set(array) or list.set(index, value)","since":"","deprecated":false},{"type":"method","name":"list.get()","signature":"list.get([index])","since":"","deprecated":false},{"type":"method","name":"list.upd()","signature":"list.upd([index])","since":"","deprecated":false},{"type":"method","name":"list.remove()","signature":"list.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammnS4Ir61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/vbinder/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Binder virtual","summary":"Las propiedades y los métodos de los objetos creados por VBIND() y VBINDARRAY().","markdown":"---\ntitle: Binder virtual\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/vbinder/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Binder virtual\n\n> Las propiedades y los métodos de los objetos creados por VBIND() y VBINDARRAY().\n\nUn binder virtual renderiza un fragmento HTML a partir de su propio modelo, sin usar el modelo de datos global. `VBIND()` crea un binder, y `VBINDARRAY()` crea una lista con un binder por ítem. Los paths dentro del fragmento empiezan por un punto. En [Bindings virtuales](../../guides/virtual-bindings/) se explica el concepto.\n\n## API\n\n### binder.element\n\nType: `property`\n\nEl fragmento renderizado como objeto de jQuery.\n\nTienes que añadirlo tú a la página.\n\nExample: Insertar el fragmento\n```js\nbinder.element.appendTo('body');\nconsole.log(binder.element.attr('class'));  // row\n```\n\n### binder.binders\n\nType: `property`\n\nLos binders encontrados en el fragmento.\n\nConsulta los métodos [`refresh()`](../ui-bind/#refresh) y [`exec()`](../ui-bind/#exec).\n\nExample: Contar los binders\n```js\nconsole.log(binder.binders.length);  // 1\n```\n\n### binder.value\n\nType: `property`\n\nEl modelo actual.\n\nExample: Leer el modelo\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.value.name);  // Peter\n```\n\n### binder.set([path], value, [skipchecksum])\n\nType: `method`\n\nSustituye el modelo o cambia uno de sus campos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path dentro del modelo. |\n| `value` | `Object` | yes |  | El modelo o el valor del campo. |\n| `skipchecksum` | `Boolean` | no |  | `true` omite la suma de comprobación de un ítem en `VBINDARRAY()`. |\n\nReturns: `VBinder` El binder.\n\nCon un argumento, el valor pasa a ser el modelo completo. Con un path, el modelo ya debe existir y el valor no puede ser `null`.\n\nExample: Usar set()\n```js\nbinder.set({ name: 'Peter' });\nbinder.set('name', 'Anna');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.get([path])\n\nType: `method`\n\nLee el modelo o uno de sus campos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path dentro del modelo. |\n\nReturns: `Object` El valor.\n\nExample: Usar get()\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.get('name'));  // Peter\nconsole.log(binder.get());  // {\"name\":\"Peter\"}\n```\n\n### binder.upd([path], [skipchecksum])\n\nType: `method`\n\nVuelve a renderizar el fragmento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path dentro del modelo. |\n| `skipchecksum` | `Boolean` | no |  | `true` omite la suma de comprobación de un ítem en `VBINDARRAY()`. |\n\nReturns: `VBinder` El binder.\n\nCon un path, solo se ejecutan los binders de ese path.\n\nExample: Usar upd()\n```js\nbinder.set({ name: 'Peter' });\nbinder.value.name = 'Anna';\nbinder.upd('name');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.on(name, [selector], callback)\n\nType: `method`\n\nAsocia un evento de jQuery al fragmento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `selector` | `String` | no |  | El selector delegado. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nReturns: `VBinder` El binder.\n\nLos argumentos son los mismos que en el método `on()` de jQuery.\n\nExample: Usar on()\n```js\nbinder.on('click', 'ui-bind', () => console.log('clicked'));  // clicked\nbinder.element.find('ui-bind').click();\n```\n\n### binder.remove()\n\nType: `method`\n\nElimina el fragmento y libera el binder.\n\nReturns: `Object` Siempre `null`.\n\nExample: Usar remove()\n```js\nbinder.remove();\nconsole.log($('.row').length, binder.element);  // 0 null\n```\n\n### list.items\n\nType: `property`\n\nLos binders de una lista `VBINDARRAY()`.\n\nCada ítem es un binder virtual con las propiedades adicionales `index` y `vbindarray`.\n\nExample: Leer los ítems\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log(items.items.length, items.items[1].index);  // 2 1\n```\n\n### list.set(array) or list.set(index, value)\n\nType: `method`\n\nRenderiza un array o cambia un ítem.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `array` | `Array|Number` | yes |  | El array o el índice del ítem. |\n| `value` | `Object` | no |  | El nuevo ítem. |\n\nUn array renderiza la lista. Un índice sustituye el ítem de esa posición. `null` elimina todos los ítems renderizados.\n\nExample: Usar list.set()\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nitems.set(1, { name: 'Lucia' });\nconsole.log($('#list').text());  // PeterLucia\n```\n\n### list.get([index])\n\nType: `method`\n\nLee el array o un ítem.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | El índice del ítem. |\n\nReturns: `Object|Array` El valor.\n\nExample: Usar list.get()\n```js\nitems.set([{ name: 'Peter' }]);\nconsole.log(items.get(0).name, items.get().length);  // Peter 1\n```\n\n### list.upd([index])\n\nType: `method`\n\nVuelve a renderizar la lista o un ítem.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | El índice del ítem. |\n\nReturns: `Object` La lista.\n\nExample: Usar list.upd()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.get(0).name = 'Anna';\nitems.upd(0);\nconsole.log($('#list').text());  // Anna\n```\n\n### list.remove()\n\nType: `method`\n\nElimina todos los ítems y libera la lista.\n\nExample: Usar list.remove()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.remove();\nconsole.log($('#list').html() === '');  // true\n```\n","entries":[{"type":"property","name":"element","signature":"binder.element","since":"","deprecated":false},{"type":"property","name":"binders","signature":"binder.binders","since":"","deprecated":false},{"type":"property","name":"value","signature":"binder.value","since":"","deprecated":false},{"type":"method","name":"set()","signature":"binder.set([path], value, [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"binder.get([path])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"binder.upd([path], [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"binder.on(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"binder.remove()","since":"","deprecated":false},{"type":"property","name":"items","signature":"list.items","since":"","deprecated":false},{"type":"method","name":"list.set()","signature":"list.set(array) or list.set(index, value)","since":"","deprecated":false},{"type":"method","name":"list.get()","signature":"list.get([index])","since":"","deprecated":false},{"type":"method","name":"list.upd()","signature":"list.upd([index])","since":"","deprecated":false},{"type":"method","name":"list.remove()","signature":"list.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammnS4Ir61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/vbinder/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Binder virtuel","summary":"Les propriétés et les méthodes des objets créés par VBIND() et VBINDARRAY().","markdown":"---\ntitle: Binder virtuel\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/vbinder/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Binder virtuel\n\n> Les propriétés et les méthodes des objets créés par VBIND() et VBINDARRAY().\n\nUn binder virtuel effectue le rendu d'un fragment HTML à partir de son propre modèle de données, sans utiliser le modèle de données global. `VBIND()` crée un binder, et `VBINDARRAY()` crée une liste avec un binder par élément. Les paths à l'intérieur du fragment commencent par un point. [Liaisons virtuelles](../../guides/virtual-bindings/) explique le concept.\n\n## API\n\n### binder.element\n\nType: `property`\n\nLe fragment rendu sous forme d'objet jQuery.\n\nAjoute-le toi-même à la page.\n\nExample: Insérer le fragment\n```js\nbinder.element.appendTo('body');\nconsole.log(binder.element.attr('class'));  // row\n```\n\n### binder.binders\n\nType: `property`\n\nLes binders trouvés dans le fragment.\n\nConsulte les méthodes [`refresh()`](../ui-bind/#refresh) et [`exec()`](../ui-bind/#exec).\n\nExample: Compter les binders\n```js\nconsole.log(binder.binders.length);  // 1\n```\n\n### binder.value\n\nType: `property`\n\nLe modèle de données actuel.\n\nExample: Lire le modèle de données\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.value.name);  // Peter\n```\n\n### binder.set([path], value, [skipchecksum])\n\nType: `method`\n\nRemplace le modèle de données ou modifie l'un de ses champs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path à l'intérieur du modèle de données. |\n| `value` | `Object` | yes |  | Le modèle de données ou la valeur du champ. |\n| `skipchecksum` | `Boolean` | no |  | `true` ignore la somme de contrôle d'un élément dans `VBINDARRAY()`. |\n\nReturns: `VBinder` Le binder.\n\nAvec un seul argument, la valeur devient le modèle de données entier. Avec un path, le modèle de données doit déjà exister et la valeur ne doit pas être `null`.\n\nExample: Utiliser set()\n```js\nbinder.set({ name: 'Peter' });\nbinder.set('name', 'Anna');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.get([path])\n\nType: `method`\n\nLit le modèle de données ou l'un de ses champs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path à l'intérieur du modèle de données. |\n\nReturns: `Object` La valeur.\n\nExample: Utiliser get()\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.get('name'));  // Peter\nconsole.log(binder.get());  // {\"name\":\"Peter\"}\n```\n\n### binder.upd([path], [skipchecksum])\n\nType: `method`\n\nEffectue de nouveau le rendu du fragment.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path à l'intérieur du modèle de données. |\n| `skipchecksum` | `Boolean` | no |  | `true` ignore la somme de contrôle d'un élément dans `VBINDARRAY()`. |\n\nReturns: `VBinder` Le binder.\n\nAvec un path, seuls les binders de ce path s'exécutent.\n\nExample: Utiliser upd()\n```js\nbinder.set({ name: 'Peter' });\nbinder.value.name = 'Anna';\nbinder.upd('name');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.on(name, [selector], callback)\n\nType: `method`\n\nAttache un événement jQuery au fragment.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `selector` | `String` | no |  | Le sélecteur de délégation. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nReturns: `VBinder` Le binder.\n\nLes arguments sont les mêmes que ceux de la méthode jQuery `on()`.\n\nExample: Utiliser on()\n```js\nbinder.on('click', 'ui-bind', () => console.log('clicked'));  // clicked\nbinder.element.find('ui-bind').click();\n```\n\n### binder.remove()\n\nType: `method`\n\nSupprime le fragment et libère le binder.\n\nReturns: `Object` Toujours `null`.\n\nExample: Utiliser remove()\n```js\nbinder.remove();\nconsole.log($('.row').length, binder.element);  // 0 null\n```\n\n### list.items\n\nType: `property`\n\nLes binders d'une liste `VBINDARRAY()`.\n\nChaque élément est un binder virtuel doté des propriétés supplémentaires `index` et `vbindarray`.\n\nExample: Lire les éléments\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log(items.items.length, items.items[1].index);  // 2 1\n```\n\n### list.set(array) or list.set(index, value)\n\nType: `method`\n\nEffectue le rendu d'un tableau ou modifie un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `array` | `Array|Number` | yes |  | Le tableau, ou l'index de l'élément. |\n| `value` | `Object` | no |  | Le nouvel élément. |\n\nUn tableau effectue le rendu de la liste. Un index remplace l'élément à cette position. `null` supprime tous les éléments rendus.\n\nExample: Utiliser list.set()\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nitems.set(1, { name: 'Lucia' });\nconsole.log($('#list').text());  // PeterLucia\n```\n\n### list.get([index])\n\nType: `method`\n\nLit le tableau ou un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | L'index de l'élément. |\n\nReturns: `Object|Array` La valeur.\n\nExample: Utiliser list.get()\n```js\nitems.set([{ name: 'Peter' }]);\nconsole.log(items.get(0).name, items.get().length);  // Peter 1\n```\n\n### list.upd([index])\n\nType: `method`\n\nEffectue de nouveau le rendu de la liste ou d'un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | L'index de l'élément. |\n\nReturns: `Object` La liste.\n\nExample: Utiliser list.upd()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.get(0).name = 'Anna';\nitems.upd(0);\nconsole.log($('#list').text());  // Anna\n```\n\n### list.remove()\n\nType: `method`\n\nSupprime tous les éléments et libère la liste.\n\nExample: Utiliser list.remove()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.remove();\nconsole.log($('#list').html() === '');  // true\n```\n","entries":[{"type":"property","name":"element","signature":"binder.element","since":"","deprecated":false},{"type":"property","name":"binders","signature":"binder.binders","since":"","deprecated":false},{"type":"property","name":"value","signature":"binder.value","since":"","deprecated":false},{"type":"method","name":"set()","signature":"binder.set([path], value, [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"binder.get([path])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"binder.upd([path], [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"binder.on(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"binder.remove()","since":"","deprecated":false},{"type":"property","name":"items","signature":"list.items","since":"","deprecated":false},{"type":"method","name":"list.set()","signature":"list.set(array) or list.set(index, value)","since":"","deprecated":false},{"type":"method","name":"list.get()","signature":"list.get([index])","since":"","deprecated":false},{"type":"method","name":"list.upd()","signature":"list.upd([index])","since":"","deprecated":false},{"type":"method","name":"list.remove()","signature":"list.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammnS4Ir61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/vbinder/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Binder virtuale","summary":"Le proprietà e i metodi degli oggetti creati da VBIND() e VBINDARRAY().","markdown":"---\ntitle: Binder virtuale\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/vbinder/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Binder virtuale\n\n> Le proprietà e i metodi degli oggetti creati da VBIND() e VBINDARRAY().\n\nUn binder virtuale esegue il rendering di un frammento HTML a partire dal proprio modello, senza usare il modello dei dati globale. `VBIND()` crea un binder e `VBINDARRAY()` crea un elenco con un binder per ogni elemento. I path dentro il frammento iniziano con un punto. [Associazioni virtuali](../../guides/virtual-bindings/) spiega il concetto.\n\n## API\n\n### binder.element\n\nType: `property`\n\nIl frammento renderizzato come oggetto jQuery.\n\nAggiungilo tu alla pagina.\n\nExample: Inserire il frammento\n```js\nbinder.element.appendTo('body');\nconsole.log(binder.element.attr('class'));  // row\n```\n\n### binder.binders\n\nType: `property`\n\nI binder trovati nel frammento.\n\nVedi i metodi [`refresh()`](../ui-bind/#refresh) ed [`exec()`](../ui-bind/#exec).\n\nExample: Contare i binder\n```js\nconsole.log(binder.binders.length);  // 1\n```\n\n### binder.value\n\nType: `property`\n\nIl modello corrente.\n\nExample: Leggere il modello\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.value.name);  // Peter\n```\n\n### binder.set([path], value, [skipchecksum])\n\nType: `method`\n\nSostituisce il modello o ne modifica un campo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path dentro il modello. |\n| `value` | `Object` | yes |  | Il modello o il valore del campo. |\n| `skipchecksum` | `Boolean` | no |  | `true` salta il checksum di un elemento in `VBINDARRAY()`. |\n\nReturns: `VBinder` Il binder.\n\nCon un solo argomento, il valore diventa l'intero modello. Con un path, il modello deve già esistere e il valore non deve essere `null`.\n\nExample: Uso di set()\n```js\nbinder.set({ name: 'Peter' });\nbinder.set('name', 'Anna');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.get([path])\n\nType: `method`\n\nLegge il modello o un suo campo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path dentro il modello. |\n\nReturns: `Object` Il valore.\n\nExample: Uso di get()\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.get('name'));  // Peter\nconsole.log(binder.get());  // {\"name\":\"Peter\"}\n```\n\n### binder.upd([path], [skipchecksum])\n\nType: `method`\n\nEsegue di nuovo il rendering del frammento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path dentro il modello. |\n| `skipchecksum` | `Boolean` | no |  | `true` salta il checksum di un elemento in `VBINDARRAY()`. |\n\nReturns: `VBinder` Il binder.\n\nCon un path, vengono eseguiti solo i binder di quel path.\n\nExample: Uso di upd()\n```js\nbinder.set({ name: 'Peter' });\nbinder.value.name = 'Anna';\nbinder.upd('name');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.on(name, [selector], callback)\n\nType: `method`\n\nCollega un evento jQuery al frammento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `selector` | `String` | no |  | Il selettore delegato. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nReturns: `VBinder` Il binder.\n\nGli argomenti sono gli stessi del metodo jQuery `on()`.\n\nExample: Uso di on()\n```js\nbinder.on('click', 'ui-bind', () => console.log('clicked'));  // clicked\nbinder.element.find('ui-bind').click();\n```\n\n### binder.remove()\n\nType: `method`\n\nRimuove il frammento e rilascia il binder.\n\nReturns: `Object` Sempre `null`.\n\nExample: Uso di remove()\n```js\nbinder.remove();\nconsole.log($('.row').length, binder.element);  // 0 null\n```\n\n### list.items\n\nType: `property`\n\nI binder di un elenco `VBINDARRAY()`.\n\nOgni elemento è un binder virtuale con le proprietà aggiuntive `index` e `vbindarray`.\n\nExample: Leggere gli elementi\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log(items.items.length, items.items[1].index);  // 2 1\n```\n\n### list.set(array) or list.set(index, value)\n\nType: `method`\n\nEsegue il rendering di un array o modifica un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `array` | `Array|Number` | yes |  | L'array o l'indice dell'elemento. |\n| `value` | `Object` | no |  | Il nuovo elemento. |\n\nUn array esegue il rendering dell'elenco. Un indice sostituisce l'elemento in quella posizione. `null` rimuove tutti gli elementi renderizzati.\n\nExample: Uso di list.set()\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nitems.set(1, { name: 'Lucia' });\nconsole.log($('#list').text());  // PeterLucia\n```\n\n### list.get([index])\n\nType: `method`\n\nLegge l'array o un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | L'indice dell'elemento. |\n\nReturns: `Object|Array` Il valore.\n\nExample: Uso di list.get()\n```js\nitems.set([{ name: 'Peter' }]);\nconsole.log(items.get(0).name, items.get().length);  // Peter 1\n```\n\n### list.upd([index])\n\nType: `method`\n\nEsegue di nuovo il rendering dell'elenco o di un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | L'indice dell'elemento. |\n\nReturns: `Object` L'elenco.\n\nExample: Uso di list.upd()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.get(0).name = 'Anna';\nitems.upd(0);\nconsole.log($('#list').text());  // Anna\n```\n\n### list.remove()\n\nType: `method`\n\nRimuove tutti gli elementi e rilascia l'elenco.\n\nExample: Uso di list.remove()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.remove();\nconsole.log($('#list').html() === '');  // true\n```\n","entries":[{"type":"property","name":"element","signature":"binder.element","since":"","deprecated":false},{"type":"property","name":"binders","signature":"binder.binders","since":"","deprecated":false},{"type":"property","name":"value","signature":"binder.value","since":"","deprecated":false},{"type":"method","name":"set()","signature":"binder.set([path], value, [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"binder.get([path])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"binder.upd([path], [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"binder.on(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"binder.remove()","since":"","deprecated":false},{"type":"property","name":"items","signature":"list.items","since":"","deprecated":false},{"type":"method","name":"list.set()","signature":"list.set(array) or list.set(index, value)","since":"","deprecated":false},{"type":"method","name":"list.get()","signature":"list.get([index])","since":"","deprecated":false},{"type":"method","name":"list.upd()","signature":"list.upd([index])","since":"","deprecated":false},{"type":"method","name":"list.remove()","signature":"list.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammnS4Ir61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/vbinder/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Virtuálny binder","summary":"Vlastnosti a metódy objektov vytvorených funkciami VBIND() a VBINDARRAY().","markdown":"---\ntitle: \"Virtuálny binder\"\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/vbinder/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Virtuálny binder\n\n> Vlastnosti a metódy objektov vytvorených funkciami VBIND() a VBINDARRAY().\n\nVirtuálny binder vykreslí fragment HTML z vlastného modelu bez použitia globálneho dátového modelu. `VBIND()` vytvorí jeden binder a `VBINDARRAY()` vytvorí zoznam s jedným binderom na položku. Path vo fragmente sa začínajú bodkou. Koncept vysvetľuje časť [Virtuálne väzby](../../guides/virtual-bindings/).\n\n## API\n\n### binder.element\n\nType: `property`\n\nVykreslený fragment ako objekt jQuery.\n\nNa stránku ho musíš pridať vlastnoručne.\n\nExample: Vloženie fragmentu\n```js\nbinder.element.appendTo('body');\nconsole.log(binder.element.attr('class'));  // row\n```\n\n### binder.binders\n\nType: `property`\n\nBindery nájdené vo fragmente.\n\nPozri metódy [`refresh()`](../ui-bind/#refresh) a [`exec()`](../ui-bind/#exec).\n\nExample: Spočítanie binderov\n```js\nconsole.log(binder.binders.length);  // 1\n```\n\n### binder.value\n\nType: `property`\n\nAktuálny model.\n\nExample: Čítanie modelu\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.value.name);  // Peter\n```\n\n### binder.set([path], value, [skipchecksum])\n\nType: `method`\n\nNahradí model alebo zmení jeho pole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Path v rámci modelu. |\n| `value` | `Object` | yes |  | Model alebo hodnota poľa. |\n| `skipchecksum` | `Boolean` | no |  | `true` preskočí kontrolný súčet položky vo `VBINDARRAY()`. |\n\nReturns: `VBinder` Binder.\n\nPri jednom argumente sa hodnota stane celým modelom. Pri zadanej path už musí model existovať a hodnota nesmie byť `null`.\n\nExample: Použitie set()\n```js\nbinder.set({ name: 'Peter' });\nbinder.set('name', 'Anna');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.get([path])\n\nType: `method`\n\nPrečíta model alebo jeho pole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Path v rámci modelu. |\n\nReturns: `Object` Hodnota.\n\nExample: Použitie get()\n```js\nbinder.set({ name: 'Peter' });\nconsole.log(binder.get('name'));  // Peter\nconsole.log(binder.get());  // {\"name\":\"Peter\"}\n```\n\n### binder.upd([path], [skipchecksum])\n\nType: `method`\n\nZnova vykreslí fragment.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Path v rámci modelu. |\n| `skipchecksum` | `Boolean` | no |  | `true` preskočí kontrolný súčet položky vo `VBINDARRAY()`. |\n\nReturns: `VBinder` Binder.\n\nPri zadanej path sa spustia iba bindery tejto path.\n\nExample: Použitie upd()\n```js\nbinder.set({ name: 'Peter' });\nbinder.value.name = 'Anna';\nbinder.upd('name');\nconsole.log(binder.element.text());  // Anna\n```\n\n### binder.on(name, [selector], callback)\n\nType: `method`\n\nPripojí k fragmentu udalosť jQuery.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `selector` | `String` | no |  | Delegovaný selektor. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nReturns: `VBinder` Binder.\n\nArgumenty sú rovnaké ako pri metóde jQuery `on()`.\n\nExample: Použitie on()\n```js\nbinder.on('click', 'ui-bind', () => console.log('clicked'));  // clicked\nbinder.element.find('ui-bind').click();\n```\n\n### binder.remove()\n\nType: `method`\n\nOdstráni fragment a uvoľní binder.\n\nReturns: `Object` Vždy `null`.\n\nExample: Použitie remove()\n```js\nbinder.remove();\nconsole.log($('.row').length, binder.element);  // 0 null\n```\n\n### list.items\n\nType: `property`\n\nBindery zoznamu `VBINDARRAY()`.\n\nKaždá položka je virtuálny binder s ďalšími vlastnosťami `index` a `vbindarray`.\n\nExample: Čítanie položiek\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nconsole.log(items.items.length, items.items[1].index);  // 2 1\n```\n\n### list.set(array) or list.set(index, value)\n\nType: `method`\n\nVykreslí pole alebo zmení jednu položku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `array` | `Array|Number` | yes |  | Pole alebo index položky. |\n| `value` | `Object` | no |  | Nová položka. |\n\nPole vykreslí zoznam. Index nahradí položku na danej pozícii. `null` odstráni všetky vykreslené položky.\n\nExample: Použitie list.set()\n```js\nitems.set([{ name: 'Peter' }, { name: 'Anna' }]);\nitems.set(1, { name: 'Lucia' });\nconsole.log($('#list').text());  // PeterLucia\n```\n\n### list.get([index])\n\nType: `method`\n\nPrečíta pole alebo jednu položku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | Index položky. |\n\nReturns: `Object|Array` Hodnota.\n\nExample: Použitie list.get()\n```js\nitems.set([{ name: 'Peter' }]);\nconsole.log(items.get(0).name, items.get().length);  // Peter 1\n```\n\n### list.upd([index])\n\nType: `method`\n\nZnova vykreslí zoznam alebo jednu položku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `index` | `Number` | no |  | Index položky. |\n\nReturns: `Object` Zoznam.\n\nExample: Použitie list.upd()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.get(0).name = 'Anna';\nitems.upd(0);\nconsole.log($('#list').text());  // Anna\n```\n\n### list.remove()\n\nType: `method`\n\nOdstráni všetky položky a uvoľní zoznam.\n\nExample: Použitie list.remove()\n```js\nitems.set([{ name: 'Peter' }]);\nitems.remove();\nconsole.log($('#list').html() === '');  // true\n```\n","entries":[{"type":"property","name":"element","signature":"binder.element","since":"","deprecated":false},{"type":"property","name":"binders","signature":"binder.binders","since":"","deprecated":false},{"type":"property","name":"value","signature":"binder.value","since":"","deprecated":false},{"type":"method","name":"set()","signature":"binder.set([path], value, [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"binder.get([path])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"binder.upd([path], [skipchecksum])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"binder.on(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"binder.remove()","since":"","deprecated":false},{"type":"property","name":"items","signature":"list.items","since":"","deprecated":false},{"type":"method","name":"list.set()","signature":"list.set(array) or list.set(index, value)","since":"","deprecated":false},{"type":"method","name":"list.get()","signature":"list.get([index])","since":"","deprecated":false},{"type":"method","name":"list.upd()","signature":"list.upd([index])","since":"","deprecated":false},{"type":"method","name":"list.remove()","signature":"list.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammld28r61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"ui-component","summary":"The attributes, configuration keys, methods and CSS classes of the ui-component element.","markdown":"---\ntitle: ui-component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-component\n\n> The attributes, configuration keys, methods and CSS classes of the ui-component element.\n\nThe `<ui-component>` element places a component declared with `COMPONENT()` in the page. Its attributes select the component, bind it to a path and configure it. [Using components](../../guides/using-components/) explains how to work with the element, and the instance it creates is described in [Component](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nSelects the component to create.\n\nThe attribute accepts these forms:\n\n| Value | Meaning |\n| --- | --- |\n| `box` | The component declared as `box`. |\n| `box@2` | The component declared as `box@2`. |\n| `box\\|panel` | The first of the listed components that is declared. |\n| `box,panel` | One instance of each component on the same element. |\n| `lazy box` | The instance is created on the first `SETTER()` call for `box`. |\n\nAn element without `name` is ignored.\n\nExample: A component bound to a path\n```html\n<ui-component name=\"hello\" path=\"common.user\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        self.setter = function(value) {\n            self.text('Hello ' + value);\n        };\n    });\n    SET('common.user', 'Peter');\n</script>\n```\n\nExample: The first declared component wins\n```html\n<ui-component name=\"missing|hello\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        console.log(self.name);  // hello\n    });\n</script>\n```\n\nExample: A lazy component\n```html\n<ui-component name=\"lazy dialog\"></ui-component>\n\n<script>\n    COMPONENT('dialog', function(self) {\n        self.show = function(title) {\n            console.log('show', title);  // show Welcome\n        };\n    });\n\n    // The first SETTER() call creates the instance\n    setTimeout(() => SETTER('dialog/show', 'Welcome'), 500);\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nBinds the component to a path of the data model.\n\nThe value of the path is passed to the [`setter`](../component/#setter) delegate. The attribute accepts these forms:\n\n| Value | Meaning |\n| --- | --- |\n| `form.name` | An absolute path. |\n| `?.name` | A path relative to the closest [`ui-plugin`](../ui-plugin/). |\n| `?` | The path of the closest `<ui-plugin>`. |\n| `*name` | A path inside `DEF.pathcommon`, which is `common.` by default. |\n| `%name` | A temporary path. |\n| `@key` | Reads the value stored with [`data()`](../component/#data) of the parent component. |\n| `form.name --> expression` | Transforms the value with an expression that receives `value`. |\n\nA component without `path` is not bound to the data model. More about the syntax is in [Paths](../../guides/paths/).\n\nExample: Path forms\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"show\" path=\"?.name\"></ui-component>\n</ui-plugin>\n<ui-component name=\"show\" path=\"*title\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('show', function(self) {\n        console.log(self.path);\n    });\n</script>\n```\n\nExample: Transforming the value\n```html\n<ui-component name=\"upper\" path=\"form.name --> (value || '').toUpperCase()\"></ui-component>\n\n<script>\n    COMPONENT('upper', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'peter');\n</script>\n```\n\nExample: Reading data of the parent component\n```html\n<ui-component name=\"card\">\n    <ui-component name=\"label\" path=\"@title\"></ui-component>\n</ui-component>\n\n<script>\n    COMPONENT('card', function(self) {\n        self.make = function() {\n            self.data('title', 'Orders');\n        };\n    });\n    COMPONENT('label', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    setTimeout(() => FIND('card').data('title', 'Invoices'), 500);\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nSets the initial configuration of the instance.\n\nThe value is a list of `key:value` pairs separated by semicolons. Numbers and booleans are converted to their types. The attribute is read once, when the instance is created. To change the configuration later, call [`reconfigure()`](#reconfigure).\n\nThe configuration is merged in this order: the default of `COMPONENT()`, this attribute and then the rules of `CONFIG()`.\n\nExample: Typed values\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;visible:true\"></ui-component>\n\n<script>\n    COMPONENT('box', 'limit:5;color:red', function(self, config) {\n        console.log(config.title, config.limit, config.visible, config.color);  // Orders 10 true red\n    });\n</script>\n```\n\n### config=\"=key:path\"\n\nType: `type`\n\nA key that starts with `=` reads its value from a path and follows its changes.\n\nThe value of `=key:path` is read from the path. When the path changes, the instance receives the new value through the [`configure`](../component/#configure) delegate.\n\nExample: A watched key\n```html\n<ui-component name=\"box\" config=\"=title:common.title\"></ui-component>\n\n<script>\n    SET('common.title', 'First');\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.title', 'Second'), 500);\n</script>\n```\n\n### config=\"=path\"\n\nType: `type`\n\nA value that starts with `=` and has no colon loads the whole configuration from a path.\n\nThe path must contain an object. The instance is reconfigured each time the path changes.\n\nExample: Reading an object\n```html\n<ui-component name=\"box\" config=\"=common.options\"></ui-component>\n\n<script>\n    SET('common.options', { title: 'Orders' });\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.options', { title: 'Invoices' }), 500);\n</script>\n```\n\n### config=\"%variable\"\n\nType: `type`\n\nA value that starts with `%` uses a global variable as the configuration object.\n\nThe instance works directly with the object stored in `window`.\n\nExample: Using a global object\n```html\n<ui-component name=\"box\" config=\"%boxoptions\"></ui-component>\n\n<script>\n    window.boxoptions = { title: 'Orders' };\n    COMPONENT('box', function(self, config) {\n        console.log(config.title, config === window.boxoptions);  // Orders true\n    });\n</script>\n```\n\n### config=\"key:@xs=value,@lg=value\"\n\nType: `type`\n\nA value can differ per display size or per light and dark appearance.\n\nWrite the alternatives as `@name=value` separated by commas. The names are `xs`, `sm`, `md`, `lg`, `dark` and `light`. The value that matches the current display is used. If the current size has no value, the closest defined size is used.\n\nExample: A value per display size\n```html\n<ui-component name=\"grid\" config=\"columns:@xs=1,@sm=2,@md=3,@lg=4\"></ui-component>\n\n<script>\n    COMPONENT('grid', function(self, config) {\n        console.log(WIDTH(), config.columns);  // xs 1\n    });\n</script>\n```\n\n### $id:identifier\n\nType: `config`\n\nSets the identifier of the instance.\n\nThe identifier is stored in [`id`](../component/#id) and can be used in selectors such as `#users`.\n\nExample: Finding an instance by its identifier\n```html\n<ui-component name=\"box\" config=\"$id:users\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(FIND('#users').name), 500);  // box\n</script>\n```\n\n### $type:type\n\nType: `config`\n\nSets the data type of the instance.\n\nThe type is stored in [`type`](../component/#type) and is passed to parsers and formatters.\n\nExample: Setting the type\n```html\n<ui-component name=\"box\" config=\"$type:number\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = () => console.log(self.type);  // number\n    });\n</script>\n```\n\n### $class:classes\n\nType: `config`\n\nToggles CSS classes on the element.\n\nExample: Adding a class\n```html\n<ui-component name=\"box\" config=\"$class:highlighted\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### $assign:path\n\nType: `config`\n\nWrites the instance to a path.\n\nThe path is set to `null` when the instance is destroyed.\n\nExample: Keeping a reference\n```html\n<ui-component name=\"box\" config=\"$assign:common.box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(GET('common.box').name), 500);  // box\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nCalls a function when the instance is ready.\n\nThe function receives the instance, and `this` is the instance too.\n\nExample: An initialization function\n```html\n<ui-component name=\"box\" config=\"$init:common.onbox\"></ui-component>\n\n<script>\n    window.common = { onbox: instance => console.log('ready', instance.name) };  // ready box\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nCalls a function each time the instance receives a value.\n\nThe function receives `value`, `path` and `type`, and `this` is the instance.\n\nExample: Observing values\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$setter:common.onvalue\"></ui-component>\n\n<script>\n    window.common = { onvalue: value => value && console.log(value) };  // Peter\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### $state:path\n\nType: `config`\n\nCalls a function each time the state of the instance changes.\n\nThe function receives `type` and `what`, the same arguments as the [`state`](../component/#state) delegate.\n\nExample: Observing the state\n```html\n<ui-component name=\"box\" config=\"$state:common.onstate\"></ui-component>\n\n<script>\n    window.common = { onstate: (type, what) => console.log(type, what) };  // 0 3\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $noscope:true\n\nType: `config`\n\nKeeps the path outside the closest `<ui-plugin>`.\n\nThe `?` character in the path is not replaced.\n\nExample: Ignoring the scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" config=\"$noscope:true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### $bindvisible:true\n\nType: `config`\n\nDelays values until the element is visible.\n\nIt has the same effect as calling [`bindvisible()`](../component/#bindvisible) in the declaration.\n\nExample: Waiting for a visible element\n```html\n<div id=\"tab\" style=\"display:none\">\n    <ui-component name=\"box\" path=\"form.name\" config=\"$bindvisible:true\"></ui-component>\n</div>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value) {\n            value && console.log('received', value);  // received Peter\n        };\n    });\n    SET('form.name', 'Peter');\n    setTimeout(() => $('#tab').show(), 500);\n</script>\n```\n\n### $url:url\n\nType: `config`\n\nImports the component when it is not declared.\n\nThe URL is passed to `IMPORT()`. It runs once per URL.\n\nExample: Importing a missing component\n```html\n<ui-component name=\"remote\" config=\"$url:/components/remote.html\"></ui-component>\n```\n\n### $realtime:false\n\nType: `config`\n\nSelects when an input with `data-jc-bind` writes its value.\n\nWith `true` the value is written while the user types. With `false` it is written on the `change` event.\n\nExample: Writing on change\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$realtime:false\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var input = $('input').val('Peter').trigger('input');\n        setTimeout(function() {\n            console.log(GET('form.name') || 'empty');  // empty\n            input.trigger('change');\n            console.log(GET('form.name'));  // Peter\n        }, 300);\n    }, 500);\n</script>\n```\n\n### $delay:milliseconds\n\nType: `config`\n\nSets the delay of realtime binding in milliseconds.\n\nThe default value is `DEF.delaykeypress`, which is `200`.\n\nExample: A shorter delay\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$delay:20\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        $('input').val('Peter').trigger('input');\n        setTimeout(() => console.log(GET('form.name')), 60);  // Peter\n    }, 500);\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nSets the default value of the path.\n\nThe attribute contains a JavaScript expression. The value is written when the path is `undefined`, and [`default()`](../component/#default) restores it.\n\nExample: A default value\n```html\n<ui-component name=\"box\" path=\"form.name\" default=\"'Anonymous'\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    setTimeout(() => console.log(GET('form.name')), 500);  // Anonymous\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCreates a scope directly on the element.\n\nThe value is the path of the scope. It works like wrapping the element in a [`ui-plugin`](../ui-plugin/).\n\nExample: A scope on the element\n```html\n<ui-component name=\"box\" plugin=\"users\" path=\"?.name\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // users.name\n    });\n</script>\n```\n\n### data-jc-path=\"path\"\n\nType: `property`\n\nSets the path and takes priority over the `path` attribute.\n\nExample: Overriding the path\n```html\n<ui-component name=\"box\" path=\"form.a\" data-jc-path=\"form.b\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // form.b\n    });\n</script>\n```\n\n### data-jc-config=\"key:value\"\n\nType: `property`\n\nSets the configuration and takes priority over the `config` attribute.\n\nExample: Overriding the configuration\n```html\n<ui-component name=\"box\" config=\"title:A\" data-jc-config=\"title:B\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        console.log(config.title);  // B\n    });\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nToggles CSS classes when the instance is ready.\n\nSeparate several classes with a space.\n\nExample: A class added after the initialization\n```html\n<ui-component name=\"box\" data-jc-class=\"ready\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### data-jc-noscope=\"true\"\n\nType: `property`\n\nKeeps the path outside the closest `<ui-plugin>`.\n\nIt has the same effect as the [`$noscope`](#x-noscope) key.\n\nExample: Ignoring the scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" data-jc-noscope=\"true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### element.get()\n\nType: `method`\n\nReturns the value of the bound path.\n\nReturns: `Object` The value of the path.\n\nExample: Reading the value\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.get());  // Peter\n```\n\n### element.set(value, [type])\n\nType: `method`\n\nWrites a value to the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The new value. |\n| `type` | `Number` | no |  | The type of the update passed to the setter. |\n\nThe instance is marked as modified.\n\nExample: Writing a value\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.update([type])\n\nType: `method`\n\nNotifies the bound path with its current value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | The type of the update passed to the setter. |\n\nThe instance is marked as modified.\n\nExample: Refreshing after a direct change\n```js\nvar element = document.querySelector('ui-component');\nwindow.form.name = 'Anna';\nelement.update();\nsetTimeout(() => console.log(element.textContent), 50);  // Anna\n```\n\n### element.modify(value, [type])\n\nType: `method`\n\nWrites a value through the parsers of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The new value. |\n| `type` | `Number` | no | `2` | The type of the update. |\n\nIt calls [`modify()`](../component/#modify) of the instance.\n\nExample: Writing a parsed value\n```js\nvar element = document.querySelector('ui-component');\nelement.modify('  Anna  ');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.reconfigure([value], [init], [noemit])\n\nType: `method`\n\nChanges the configuration of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | no |  | The new configuration. |\n| `init` | `Boolean` | no |  | Passes `init` to the `configure` delegate. |\n| `noemit` | `Boolean` | no |  | Skips the `configure` delegate. |\n\nWithout a value, the method reads the `config` attribute again.\n\nExample: Changing a key\n```js\nvar element = document.querySelector('ui-component');\nelement.reconfigure('title:Invoices');\nconsole.log(element.config.title);  // Invoices\n```\n\n### element.reset()\n\nType: `method`\n\nClears the invalid and modified state of the instance.\n\nExample: Clearing the state\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nelement.reset();\nconsole.log(element.config.modified);  // false\n```\n\n### element.config\n\nType: `property`\n\nThe configuration object of the instance.\n\nThe property exists when the instance has been created.\n\nExample: Reading the configuration\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.config.title);  // Orders\n```\n\n### element.setter = function(value, path, type)\n\nType: `delegate`\n\nA function on the DOM element that receives each value.\n\nAssign it to the element. It runs after the `setter` delegate of the instance with the same arguments.\n\nExample: Observing values from outside\n```js\nvar element = document.querySelector('ui-component');\nelement.setter = function(value, path, type) {\n    console.log(value, path, type);  // Anna form.name 1\n};\nSET('form.name', 'Anna');\n```\n\n### element.state = function(config)\n\nType: `delegate`\n\nA function on the DOM element that runs when the state changes.\n\nThe function receives the configuration object of the instance.\n\nExample: Observing the state from outside\n```js\nvar element = document.querySelector('ui-component');\nelement.state = function(config) {\n    console.log(config.touched);  // true\n};\nFIND('demo').bind('touched');\n```\n\n### element.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nA function on the DOM element that receives configuration changes.\n\nThe function receives the same arguments as the [`configure`](../component/#configure) delegate.\n\nExample: Observing the configuration\n```js\nvar element = document.querySelector('ui-component');\nelement.configure = function(key, value, init, prev) {\n    console.log(key, value, prev);  // title Invoices Orders\n};\nelement.reconfigure('title:Invoices');\n```\n\n### $(element).on('component', callback)\n\nType: `event`\n\nA jQuery event triggered on the element when the instance is ready.\n\nThe event is triggered once.\n\nExample: Waiting for the instance\n```html\n<ui-component name=\"box\" id=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    $('#box').on('component', () => console.log('ready'));  // ready\n</script>\n```\n\n### .ui-modified\n\nType: `class`\n\nPresent while the value of the instance is modified.\n\nIt follows `config.modified`.\n\nExample: The modified class\n```js\nvar com = FIND('demo');\ncom.bind('modified');\nconsole.log(com.element.hclass('ui-modified'));  // true\n```\n\n### .ui-touched\n\nType: `class`\n\nPresent after the user has interacted with the instance.\n\nIt follows `config.touched`.\n\nExample: The touched class\n```js\nvar com = FIND('demo');\ncom.bind('touched');\nconsole.log(com.element.hclass('ui-touched'));  // true\n```\n\n### .ui-invalid\n\nType: `class`\n\nPresent while the value of the instance is invalid.\n\nIt follows `config.invalid`, which is set by the [`validate`](../component/#validate) delegate.\n\nExample: The invalid class\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.validate = value => !!value;\n    });\n</script>\n```\n\n### .ui-disabled\n\nType: `class`\n\nPresent while the instance is disabled.\n\nIt follows `config.disabled`. The [`disabled`](../ui-bind/#disabled) command of `<ui-bind>` sets the key.\n\nExample: The disabled class\n```html\n<ui-bind path=\"form.locked\" config=\"disabled:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n\n<script>\n    COMPONENT('box', function(self) {});\n    SET('form.locked', true);\n</script>\n```\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":"type","name":"Configuration from a path","signature":"config=\"=key:path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a path","signature":"config=\"=path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a global variable","signature":"config=\"%variable\"","since":"","deprecated":false},{"type":"type","name":"Responsive configuration","signature":"config=\"key:@xs=value,@lg=value\"","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:identifier","since":"","deprecated":false},{"type":"config","name":"$type","signature":"$type:type","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:classes","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","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":"$state","signature":"$state:path","since":"","deprecated":false},{"type":"config","name":"$noscope","signature":"$noscope:true","since":"","deprecated":false},{"type":"config","name":"$bindvisible","signature":"$bindvisible:true","since":"","deprecated":false},{"type":"config","name":"$url","signature":"$url:url","since":"","deprecated":false},{"type":"config","name":"$realtime","signature":"$realtime:false","since":"","deprecated":false},{"type":"config","name":"$delay","signature":"$delay:milliseconds","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-path","signature":"data-jc-path=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-config","signature":"data-jc-config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-noscope","signature":"data-jc-noscope=\"true\"","since":"","deprecated":false},{"type":"method","name":"get()","signature":"element.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"element.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"element.update([type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"element.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"element.reconfigure([value], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"element.reset()","since":"","deprecated":false},{"type":"property","name":"element.config","signature":"element.config","since":"","deprecated":false},{"type":"delegate","name":"element.setter","signature":"element.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"element.state","signature":"element.state = function(config)","since":"","deprecated":false},{"type":"delegate","name":"element.configure","signature":"element.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"event","name":"component","signature":"$(element).on('component', callback)","since":"","deprecated":false},{"type":"class","name":"ui-modified","signature":".ui-modified","since":"","deprecated":false},{"type":"class","name":"ui-touched","signature":".ui-touched","since":"","deprecated":false},{"type":"class","name":"ui-invalid","signature":".ui-invalid","since":"","deprecated":false},{"type":"class","name":"ui-disabled","signature":".ui-disabled","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammld28r61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"ui-component","summary":"Die Attribute, Konfigurationsschlüssel, Methoden und CSS-Klassen des Elements ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-component\n\n> Die Attribute, Konfigurationsschlüssel, Methoden und CSS-Klassen des Elements ui-component.\n\nDas Element `<ui-component>` platziert eine mit `COMPONENT()` deklarierte Komponente auf der Seite. Seine Attribute wählen die Komponente aus, binden sie an einen Path und konfigurieren sie. [Komponenten verwenden](../../guides/using-components/) erklärt den Umgang mit dem Element, und die dabei erzeugte Instanz ist unter [Komponente](../component/) beschrieben.\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nWählt die zu erstellende Komponente aus.\n\nDas Attribut akzeptiert diese Formen:\n\n| Wert | Bedeutung |\n| --- | --- |\n| `box` | Die als `box` deklarierte Komponente. |\n| `box@2` | Die als `box@2` deklarierte Komponente. |\n| `box\\|panel` | Die erste der aufgeführten Komponenten, die deklariert ist. |\n| `box,panel` | Je eine Instanz jeder Komponente auf demselben Element. |\n| `lazy box` | Die Instanz wird beim ersten `SETTER()`-Aufruf für `box` erstellt. |\n\nEin Element ohne `name` wird ignoriert.\n\nExample: Eine an einen Path gebundene Komponente\n```html\n<ui-component name=\"hello\" path=\"common.user\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        self.setter = function(value) {\n            self.text('Hello ' + value);\n        };\n    });\n    SET('common.user', 'Peter');\n</script>\n```\n\nExample: Die erste deklarierte Komponente gewinnt\n```html\n<ui-component name=\"missing|hello\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        console.log(self.name);  // hello\n    });\n</script>\n```\n\nExample: Eine Lazy-Komponente\n```html\n<ui-component name=\"lazy dialog\"></ui-component>\n\n<script>\n    COMPONENT('dialog', function(self) {\n        self.show = function(title) {\n            console.log('show', title);  // show Welcome\n        };\n    });\n\n    // The first SETTER() call creates the instance\n    setTimeout(() => SETTER('dialog/show', 'Welcome'), 500);\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nBindet die Komponente an einen Path des Datenmodells.\n\nDer Wert des Paths wird an den Delegate [`setter`](../component/#setter) übergeben. Das Attribut akzeptiert diese Formen:\n\n| Wert | Bedeutung |\n| --- | --- |\n| `form.name` | Ein absoluter Path. |\n| `?.name` | Ein Path relativ zum nächstgelegenen [`ui-plugin`](../ui-plugin/). |\n| `?` | Der Path des nächstgelegenen `<ui-plugin>`. |\n| `*name` | Ein Path innerhalb von `DEF.pathcommon`, standardmäßig `common.`. |\n| `%name` | Ein temporärer Path. |\n| `@key` | Liest den Wert, der mit [`data()`](../component/#data) der übergeordneten Komponente gespeichert wurde. |\n| `form.name --> expression` | Wandelt den Wert mit einem Ausdruck um, der `value` erhält. |\n\nEine Komponente ohne `path` ist nicht an das Datenmodell gebunden. Mehr zur Syntax findest du unter [Paths](../../guides/paths/).\n\nExample: Path-Formen\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"show\" path=\"?.name\"></ui-component>\n</ui-plugin>\n<ui-component name=\"show\" path=\"*title\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('show', function(self) {\n        console.log(self.path);\n    });\n</script>\n```\n\nExample: Den Wert umwandeln\n```html\n<ui-component name=\"upper\" path=\"form.name --> (value || '').toUpperCase()\"></ui-component>\n\n<script>\n    COMPONENT('upper', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'peter');\n</script>\n```\n\nExample: Daten der übergeordneten Komponente lesen\n```html\n<ui-component name=\"card\">\n    <ui-component name=\"label\" path=\"@title\"></ui-component>\n</ui-component>\n\n<script>\n    COMPONENT('card', function(self) {\n        self.make = function() {\n            self.data('title', 'Orders');\n        };\n    });\n    COMPONENT('label', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    setTimeout(() => FIND('card').data('title', 'Invoices'), 500);\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLegt die Anfangskonfiguration der Instanz fest.\n\nDer Wert ist eine Liste von `key:value`-Paaren, getrennt durch Semikolons. Zahlen und boolesche Werte werden in ihre Typen umgewandelt. Das Attribut wird einmal gelesen, wenn die Instanz erstellt wird. Um die Konfiguration später zu ändern, rufst du [`reconfigure()`](#reconfigure) auf.\n\nDie Konfiguration wird in dieser Reihenfolge zusammengeführt: der Standard aus `COMPONENT()`, dieses Attribut und danach die Regeln aus `CONFIG()`.\n\nExample: Typisierte Werte\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;visible:true\"></ui-component>\n\n<script>\n    COMPONENT('box', 'limit:5;color:red', function(self, config) {\n        console.log(config.title, config.limit, config.visible, config.color);  // Orders 10 true red\n    });\n</script>\n```\n\n### config=\"=key:path\"\n\nType: `type`\n\nEin Schlüssel, der mit `=` beginnt, liest seinen Wert aus einem Path und folgt dessen Änderungen.\n\nDer Wert von `=key:path` wird aus dem Path gelesen. Ändert sich der Path, erhält die Instanz den neuen Wert über den Delegate [`configure`](../component/#configure).\n\nExample: Ein überwachter Schlüssel\n```html\n<ui-component name=\"box\" config=\"=title:common.title\"></ui-component>\n\n<script>\n    SET('common.title', 'First');\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.title', 'Second'), 500);\n</script>\n```\n\n### config=\"=path\"\n\nType: `type`\n\nEin Wert, der mit `=` beginnt und keinen Doppelpunkt enthält, lädt die gesamte Konfiguration aus einem Path.\n\nDer Path muss ein Objekt enthalten. Die Instanz wird bei jeder Änderung des Paths neu konfiguriert.\n\nExample: Ein Objekt lesen\n```html\n<ui-component name=\"box\" config=\"=common.options\"></ui-component>\n\n<script>\n    SET('common.options', { title: 'Orders' });\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.options', { title: 'Invoices' }), 500);\n</script>\n```\n\n### config=\"%variable\"\n\nType: `type`\n\nEin Wert, der mit `%` beginnt, verwendet eine globale Variable als Konfigurationsobjekt.\n\nDie Instanz arbeitet direkt mit dem in `window` gespeicherten Objekt.\n\nExample: Ein globales Objekt verwenden\n```html\n<ui-component name=\"box\" config=\"%boxoptions\"></ui-component>\n\n<script>\n    window.boxoptions = { title: 'Orders' };\n    COMPONENT('box', function(self, config) {\n        console.log(config.title, config === window.boxoptions);  // Orders true\n    });\n</script>\n```\n\n### config=\"key:@xs=value,@lg=value\"\n\nType: `type`\n\nEin Wert kann sich je nach Anzeigegröße oder heller und dunkler Darstellung unterscheiden.\n\nSchreibe die Alternativen als `@name=value`, getrennt durch Kommas. Die Namen sind `xs`, `sm`, `md`, `lg`, `dark` und `light`. Verwendet wird der Wert, der zur aktuellen Anzeige passt. Hat die aktuelle Größe keinen Wert, gilt die nächstgelegene definierte Größe.\n\nExample: Ein Wert pro Anzeigegröße\n```html\n<ui-component name=\"grid\" config=\"columns:@xs=1,@sm=2,@md=3,@lg=4\"></ui-component>\n\n<script>\n    COMPONENT('grid', function(self, config) {\n        console.log(WIDTH(), config.columns);  // xs 1\n    });\n</script>\n```\n\n### $id:identifier\n\nType: `config`\n\nLegt die Kennung der Instanz fest.\n\nDie Kennung wird in [`id`](../component/#id) gespeichert und lässt sich in Selektoren wie `#users` verwenden.\n\nExample: Eine Instanz über ihre Kennung finden\n```html\n<ui-component name=\"box\" config=\"$id:users\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(FIND('#users').name), 500);  // box\n</script>\n```\n\n### $type:type\n\nType: `config`\n\nLegt den Datentyp der Instanz fest.\n\nDer Typ wird in [`type`](../component/#type) gespeichert und an Parser und Formatter übergeben.\n\nExample: Den Typ festlegen\n```html\n<ui-component name=\"box\" config=\"$type:number\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = () => console.log(self.type);  // number\n    });\n</script>\n```\n\n### $class:classes\n\nType: `config`\n\nSchaltet CSS-Klassen auf dem Element um.\n\nExample: Klasse hinzufügen\n```html\n<ui-component name=\"box\" config=\"$class:highlighted\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### $assign:path\n\nType: `config`\n\nSchreibt die Instanz in einen Path.\n\nDer Path wird auf `null` gesetzt, wenn die Instanz zerstört wird.\n\nExample: Eine Referenz behalten\n```html\n<ui-component name=\"box\" config=\"$assign:common.box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(GET('common.box').name), 500);  // box\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nRuft eine Funktion auf, wenn die Instanz bereit ist.\n\nDie Funktion erhält die Instanz, und auch `this` ist die Instanz.\n\nExample: Eine Initialisierungsfunktion\n```html\n<ui-component name=\"box\" config=\"$init:common.onbox\"></ui-component>\n\n<script>\n    window.common = { onbox: instance => console.log('ready', instance.name) };  // ready box\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nRuft jedes Mal eine Funktion auf, wenn die Instanz einen Wert erhält.\n\nDie Funktion erhält `value`, `path` und `type`, und `this` ist die Instanz.\n\nExample: Werte beobachten\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$setter:common.onvalue\"></ui-component>\n\n<script>\n    window.common = { onvalue: value => value && console.log(value) };  // Peter\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### $state:path\n\nType: `config`\n\nRuft jedes Mal eine Funktion auf, wenn sich der Zustand der Instanz ändert.\n\nDie Funktion erhält `type` und `what`, also dieselben Argumente wie der Delegate [`state`](../component/#state).\n\nExample: Den Zustand beobachten\n```html\n<ui-component name=\"box\" config=\"$state:common.onstate\"></ui-component>\n\n<script>\n    window.common = { onstate: (type, what) => console.log(type, what) };  // 0 3\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $noscope:true\n\nType: `config`\n\nHält den Path außerhalb des nächstgelegenen `<ui-plugin>`.\n\nDas Zeichen `?` im Path wird nicht ersetzt.\n\nExample: Den Scope ignorieren\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" config=\"$noscope:true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### $bindvisible:true\n\nType: `config`\n\nVerzögert Werte, bis das Element sichtbar ist.\n\nDas hat dieselbe Wirkung wie der Aufruf von [`bindvisible()`](../component/#bindvisible) in der Deklaration.\n\nExample: Auf ein sichtbares Element warten\n```html\n<div id=\"tab\" style=\"display:none\">\n    <ui-component name=\"box\" path=\"form.name\" config=\"$bindvisible:true\"></ui-component>\n</div>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value) {\n            value && console.log('received', value);  // received Peter\n        };\n    });\n    SET('form.name', 'Peter');\n    setTimeout(() => $('#tab').show(), 500);\n</script>\n```\n\n### $url:url\n\nType: `config`\n\nImportiert die Komponente, wenn sie nicht deklariert ist.\n\nDie URL wird an `IMPORT()` übergeben. Der Import läuft einmal pro URL.\n\nExample: Eine fehlende Komponente importieren\n```html\n<ui-component name=\"remote\" config=\"$url:/components/remote.html\"></ui-component>\n```\n\n### $realtime:false\n\nType: `config`\n\nLegt fest, wann ein Eingabefeld mit `data-jc-bind` seinen Wert schreibt.\n\nMit `true` wird der Wert geschrieben, während die Person tippt. Mit `false` wird er beim Event `change` geschrieben.\n\nExample: Bei Änderung schreiben\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$realtime:false\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var input = $('input').val('Peter').trigger('input');\n        setTimeout(function() {\n            console.log(GET('form.name') || 'empty');  // empty\n            input.trigger('change');\n            console.log(GET('form.name'));  // Peter\n        }, 300);\n    }, 500);\n</script>\n```\n\n### $delay:milliseconds\n\nType: `config`\n\nLegt die Verzögerung der Echtzeit-Bindung in Millisekunden fest.\n\nDer Standardwert ist `DEF.delaykeypress`, also `200`.\n\nExample: Eine kürzere Verzögerung\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$delay:20\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        $('input').val('Peter').trigger('input');\n        setTimeout(() => console.log(GET('form.name')), 60);  // Peter\n    }, 500);\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nLegt den Standardwert des Paths fest.\n\nDas Attribut enthält einen JavaScript-Ausdruck. Der Wert wird geschrieben, wenn der Path `undefined` ist, und [`default()`](../component/#default) stellt ihn wieder her.\n\nExample: Ein Standardwert\n```html\n<ui-component name=\"box\" path=\"form.name\" default=\"'Anonymous'\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    setTimeout(() => console.log(GET('form.name')), 500);  // Anonymous\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nErstellt einen Scope direkt auf dem Element.\n\nDer Wert ist der Path des Scopes. Das funktioniert so, als würdest du das Element in ein [`ui-plugin`](../ui-plugin/) einschließen.\n\nExample: Ein Scope auf dem Element\n```html\n<ui-component name=\"box\" plugin=\"users\" path=\"?.name\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // users.name\n    });\n</script>\n```\n\n### data-jc-path=\"path\"\n\nType: `property`\n\nLegt den Path fest und hat Vorrang vor dem Attribut `path`.\n\nExample: Den Path überschreiben\n```html\n<ui-component name=\"box\" path=\"form.a\" data-jc-path=\"form.b\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // form.b\n    });\n</script>\n```\n\n### data-jc-config=\"key:value\"\n\nType: `property`\n\nLegt die Konfiguration fest und hat Vorrang vor dem Attribut `config`.\n\nExample: Die Konfiguration überschreiben\n```html\n<ui-component name=\"box\" config=\"title:A\" data-jc-config=\"title:B\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        console.log(config.title);  // B\n    });\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nSchaltet CSS-Klassen um, wenn die Instanz bereit ist.\n\nTrenne mehrere Klassen durch ein Leerzeichen.\n\nExample: Eine nach der Initialisierung hinzugefügte Klasse\n```html\n<ui-component name=\"box\" data-jc-class=\"ready\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### data-jc-noscope=\"true\"\n\nType: `property`\n\nHält den Path außerhalb des nächstgelegenen `<ui-plugin>`.\n\nDas hat dieselbe Wirkung wie der Schlüssel [`$noscope`](#x-noscope).\n\nExample: Den Scope ignorieren\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" data-jc-noscope=\"true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### element.get()\n\nType: `method`\n\nGibt den Wert des gebundenen Paths zurück.\n\nReturns: `Object` Der Wert des Paths.\n\nExample: Den Wert lesen\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.get());  // Peter\n```\n\n### element.set(value, [type])\n\nType: `method`\n\nSchreibt einen Wert in den gebundenen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ der Aktualisierung. |\n\nDie Instanz wird als geändert markiert.\n\nExample: Einen Wert schreiben\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.update([type])\n\nType: `method`\n\nBenachrichtigt den gebundenen Path mit seinem aktuellen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ der Aktualisierung. |\n\nDie Instanz wird als geändert markiert.\n\nExample: Nach einer direkten Änderung aktualisieren\n```js\nvar element = document.querySelector('ui-component');\nwindow.form.name = 'Anna';\nelement.update();\nsetTimeout(() => console.log(element.textContent), 50);  // Anna\n```\n\n### element.modify(value, [type])\n\nType: `method`\n\nSchreibt einen Wert über die Parser der Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `type` | `Number` | no | `2` | Der Typ der Aktualisierung. |\n\nDie Methode ruft [`modify()`](../component/#modify) der Instanz auf.\n\nExample: Einen geparsten Wert schreiben\n```js\nvar element = document.querySelector('ui-component');\nelement.modify('  Anna  ');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.reconfigure([value], [init], [noemit])\n\nType: `method`\n\nÄndert die Konfiguration der Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | no |  | Die neue Konfiguration. |\n| `init` | `Boolean` | no |  | Übergibt `init` an den Delegate `configure`. |\n| `noemit` | `Boolean` | no |  | Überspringt den Delegate `configure`. |\n\nOhne Wert liest die Methode das Attribut `config` erneut.\n\nExample: Einen Schlüssel ändern\n```js\nvar element = document.querySelector('ui-component');\nelement.reconfigure('title:Invoices');\nconsole.log(element.config.title);  // Invoices\n```\n\n### element.reset()\n\nType: `method`\n\nLöscht den Zustand „ungültig“ und „geändert“ der Instanz.\n\nExample: Den Zustand löschen\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nelement.reset();\nconsole.log(element.config.modified);  // false\n```\n\n### element.config\n\nType: `property`\n\nDas Konfigurationsobjekt der Instanz.\n\nDie Eigenschaft existiert, sobald die Instanz erstellt wurde.\n\nExample: Die Konfiguration lesen\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.config.title);  // Orders\n```\n\n### element.setter = function(value, path, type)\n\nType: `delegate`\n\nEine Funktion auf dem DOM-Element, die jeden Wert erhält.\n\nWeise sie dem Element zu. Die Funktion läuft nach dem Delegate `setter` der Instanz und erhält dieselben Argumente.\n\nExample: Werte von außen beobachten\n```js\nvar element = document.querySelector('ui-component');\nelement.setter = function(value, path, type) {\n    console.log(value, path, type);  // Anna form.name 1\n};\nSET('form.name', 'Anna');\n```\n\n### element.state = function(config)\n\nType: `delegate`\n\nEine Funktion auf dem DOM-Element, die bei einer Zustandsänderung läuft.\n\nDie Funktion erhält das Konfigurationsobjekt der Instanz.\n\nExample: Den Zustand von außen beobachten\n```js\nvar element = document.querySelector('ui-component');\nelement.state = function(config) {\n    console.log(config.touched);  // true\n};\nFIND('demo').bind('touched');\n```\n\n### element.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nEine Funktion auf dem DOM-Element, die Konfigurationsänderungen erhält.\n\nDie Funktion erhält dieselben Argumente wie der Delegate [`configure`](../component/#configure).\n\nExample: Die Konfiguration beobachten\n```js\nvar element = document.querySelector('ui-component');\nelement.configure = function(key, value, init, prev) {\n    console.log(key, value, prev);  // title Invoices Orders\n};\nelement.reconfigure('title:Invoices');\n```\n\n### $(element).on('component', callback)\n\nType: `event`\n\nEin jQuery-Event, das auf dem Element ausgelöst wird, wenn die Instanz bereit ist.\n\nDas Event wird einmal ausgelöst.\n\nExample: Auf die Instanz warten\n```html\n<ui-component name=\"box\" id=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    $('#box').on('component', () => console.log('ready'));  // ready\n</script>\n```\n\n### .ui-modified\n\nType: `class`\n\nVorhanden, solange der Wert der Instanz geändert ist.\n\nDie Klasse folgt `config.modified`.\n\nExample: Die Klasse für geänderte Werte\n```js\nvar com = FIND('demo');\ncom.bind('modified');\nconsole.log(com.element.hclass('ui-modified'));  // true\n```\n\n### .ui-touched\n\nType: `class`\n\nVorhanden, nachdem mit der Instanz interagiert wurde.\n\nDie Klasse folgt `config.touched`.\n\nExample: Die Klasse für berührte Instanzen\n```js\nvar com = FIND('demo');\ncom.bind('touched');\nconsole.log(com.element.hclass('ui-touched'));  // true\n```\n\n### .ui-invalid\n\nType: `class`\n\nVorhanden, solange der Wert der Instanz ungültig ist.\n\nDie Klasse folgt `config.invalid`, das vom Delegate [`validate`](../component/#validate) gesetzt wird.\n\nExample: Die Klasse für ungültige Werte\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.validate = value => !!value;\n    });\n</script>\n```\n\n### .ui-disabled\n\nType: `class`\n\nVorhanden, solange die Instanz deaktiviert ist.\n\nDie Klasse folgt `config.disabled`. Der Befehl [`disabled`](../ui-bind/#disabled) von `<ui-bind>` setzt den Schlüssel.\n\nExample: Die Klasse für deaktivierte Instanzen\n```html\n<ui-bind path=\"form.locked\" config=\"disabled:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n\n<script>\n    COMPONENT('box', function(self) {});\n    SET('form.locked', true);\n</script>\n```\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":"type","name":"Configuration from a path","signature":"config=\"=key:path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a path","signature":"config=\"=path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a global variable","signature":"config=\"%variable\"","since":"","deprecated":false},{"type":"type","name":"Responsive configuration","signature":"config=\"key:@xs=value,@lg=value\"","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:identifier","since":"","deprecated":false},{"type":"config","name":"$type","signature":"$type:type","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:classes","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","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":"$state","signature":"$state:path","since":"","deprecated":false},{"type":"config","name":"$noscope","signature":"$noscope:true","since":"","deprecated":false},{"type":"config","name":"$bindvisible","signature":"$bindvisible:true","since":"","deprecated":false},{"type":"config","name":"$url","signature":"$url:url","since":"","deprecated":false},{"type":"config","name":"$realtime","signature":"$realtime:false","since":"","deprecated":false},{"type":"config","name":"$delay","signature":"$delay:milliseconds","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-path","signature":"data-jc-path=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-config","signature":"data-jc-config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-noscope","signature":"data-jc-noscope=\"true\"","since":"","deprecated":false},{"type":"method","name":"get()","signature":"element.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"element.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"element.update([type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"element.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"element.reconfigure([value], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"element.reset()","since":"","deprecated":false},{"type":"property","name":"element.config","signature":"element.config","since":"","deprecated":false},{"type":"delegate","name":"element.setter","signature":"element.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"element.state","signature":"element.state = function(config)","since":"","deprecated":false},{"type":"delegate","name":"element.configure","signature":"element.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"event","name":"component","signature":"$(element).on('component', callback)","since":"","deprecated":false},{"type":"class","name":"ui-modified","signature":".ui-modified","since":"","deprecated":false},{"type":"class","name":"ui-touched","signature":".ui-touched","since":"","deprecated":false},{"type":"class","name":"ui-invalid","signature":".ui-invalid","since":"","deprecated":false},{"type":"class","name":"ui-disabled","signature":".ui-disabled","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammld28r61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"ui-component","summary":"Los atributos, las claves de configuración, los métodos y las clases CSS del elemento ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-component\n\n> Los atributos, las claves de configuración, los métodos y las clases CSS del elemento ui-component.\n\nEl elemento `<ui-component>` coloca en la página un componente declarado con `COMPONENT()`. Sus atributos seleccionan el componente, lo enlazan a un path y lo configuran. En [Usar componentes](../../guides/using-components/) se explica cómo trabajar con el elemento, y la instancia que crea se describe en [Componente](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nSelecciona el componente que se va a crear.\n\nEl atributo admite estas formas:\n\n| Valor | Significado |\n| --- | --- |\n| `box` | El componente declarado como `box`. |\n| `box@2` | El componente declarado como `box@2`. |\n| `box\\|panel` | El primero de los componentes indicados que esté declarado. |\n| `box,panel` | Una instancia de cada componente en el mismo elemento. |\n| `lazy box` | La instancia se crea en la primera llamada a `SETTER()` para `box`. |\n\nUn elemento sin `name` se ignora.\n\nExample: Un componente enlazado a un path\n```html\n<ui-component name=\"hello\" path=\"common.user\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        self.setter = function(value) {\n            self.text('Hello ' + value);\n        };\n    });\n    SET('common.user', 'Peter');\n</script>\n```\n\nExample: Gana el primer componente declarado\n```html\n<ui-component name=\"missing|hello\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        console.log(self.name);  // hello\n    });\n</script>\n```\n\nExample: Un componente lazy\n```html\n<ui-component name=\"lazy dialog\"></ui-component>\n\n<script>\n    COMPONENT('dialog', function(self) {\n        self.show = function(title) {\n            console.log('show', title);  // show Welcome\n        };\n    });\n\n    // The first SETTER() call creates the instance\n    setTimeout(() => SETTER('dialog/show', 'Welcome'), 500);\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nEnlaza el componente a un path del modelo de datos.\n\nEl valor del path se pasa al delegate [`setter`](../component/#setter). El atributo admite estas formas:\n\n| Valor | Significado |\n| --- | --- |\n| `form.name` | Un path absoluto. |\n| `?.name` | Un path relativo al [`ui-plugin`](../ui-plugin/) más cercano. |\n| `?` | El path del `<ui-plugin>` más cercano. |\n| `*name` | Un path dentro de `DEF.pathcommon`, que de forma predeterminada es `common.`. |\n| `%name` | Un path temporal. |\n| `@key` | Lee el valor guardado con [`data()`](../component/#data) del componente padre. |\n| `form.name --> expression` | Transforma el valor con una expresión que recibe `value`. |\n\nUn componente sin `path` no está enlazado al modelo de datos. Encontrarás más sobre la sintaxis en [Paths](../../guides/paths/).\n\nExample: Formas del path\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"show\" path=\"?.name\"></ui-component>\n</ui-plugin>\n<ui-component name=\"show\" path=\"*title\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('show', function(self) {\n        console.log(self.path);\n    });\n</script>\n```\n\nExample: Transformar el valor\n```html\n<ui-component name=\"upper\" path=\"form.name --> (value || '').toUpperCase()\"></ui-component>\n\n<script>\n    COMPONENT('upper', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'peter');\n</script>\n```\n\nExample: Leer datos del componente padre\n```html\n<ui-component name=\"card\">\n    <ui-component name=\"label\" path=\"@title\"></ui-component>\n</ui-component>\n\n<script>\n    COMPONENT('card', function(self) {\n        self.make = function() {\n            self.data('title', 'Orders');\n        };\n    });\n    COMPONENT('label', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    setTimeout(() => FIND('card').data('title', 'Invoices'), 500);\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nDefine la configuración inicial de la instancia.\n\nEl valor es una lista de pares `key:value` separados por punto y coma. Los números y los booleanos se convierten a sus tipos. El atributo se lee una sola vez, al crear la instancia. Para cambiar la configuración más adelante, llama a [`reconfigure()`](#reconfigure).\n\nLa configuración se combina en este orden: el valor predeterminado de `COMPONENT()`, este atributo y, por último, las reglas de `CONFIG()`.\n\nExample: Valores con tipo\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;visible:true\"></ui-component>\n\n<script>\n    COMPONENT('box', 'limit:5;color:red', function(self, config) {\n        console.log(config.title, config.limit, config.visible, config.color);  // Orders 10 true red\n    });\n</script>\n```\n\n### config=\"=key:path\"\n\nType: `type`\n\nUna clave que empieza por `=` lee su valor de un path y sigue sus cambios.\n\nEl valor de `=key:path` se lee del path. Cuando el path cambia, la instancia recibe el nuevo valor a través del delegate [`configure`](../component/#configure).\n\nExample: Una clave observada\n```html\n<ui-component name=\"box\" config=\"=title:common.title\"></ui-component>\n\n<script>\n    SET('common.title', 'First');\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.title', 'Second'), 500);\n</script>\n```\n\n### config=\"=path\"\n\nType: `type`\n\nUn valor que empieza por `=` y no tiene dos puntos carga toda la configuración desde un path.\n\nEl path debe contener un objeto. La instancia se reconfigura cada vez que cambia el path.\n\nExample: Leer un objeto\n```html\n<ui-component name=\"box\" config=\"=common.options\"></ui-component>\n\n<script>\n    SET('common.options', { title: 'Orders' });\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.options', { title: 'Invoices' }), 500);\n</script>\n```\n\n### config=\"%variable\"\n\nType: `type`\n\nUn valor que empieza por `%` usa una variable global como objeto de configuración.\n\nLa instancia trabaja directamente con el objeto guardado en `window`.\n\nExample: Usar un objeto global\n```html\n<ui-component name=\"box\" config=\"%boxoptions\"></ui-component>\n\n<script>\n    window.boxoptions = { title: 'Orders' };\n    COMPONENT('box', function(self, config) {\n        console.log(config.title, config === window.boxoptions);  // Orders true\n    });\n</script>\n```\n\n### config=\"key:@xs=value,@lg=value\"\n\nType: `type`\n\nUn valor puede variar según el tamaño de pantalla o la apariencia clara u oscura.\n\nEscribe las alternativas como `@name=value` separadas por comas. Los nombres son `xs`, `sm`, `md`, `lg`, `dark` y `light`. Se usa el valor que coincide con la pantalla actual. Si el tamaño actual no tiene valor, se usa el tamaño definido más cercano.\n\nExample: Un valor por tamaño de pantalla\n```html\n<ui-component name=\"grid\" config=\"columns:@xs=1,@sm=2,@md=3,@lg=4\"></ui-component>\n\n<script>\n    COMPONENT('grid', function(self, config) {\n        console.log(WIDTH(), config.columns);  // xs 1\n    });\n</script>\n```\n\n### $id:identifier\n\nType: `config`\n\nDefine el identificador de la instancia.\n\nEl identificador se guarda en [`id`](../component/#id) y se puede usar en selectores como `#users`.\n\nExample: Buscar una instancia por su identificador\n```html\n<ui-component name=\"box\" config=\"$id:users\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(FIND('#users').name), 500);  // box\n</script>\n```\n\n### $type:type\n\nType: `config`\n\nDefine el tipo de datos de la instancia.\n\nEl tipo se guarda en [`type`](../component/#type) y se pasa a los parsers y formatters.\n\nExample: Definir el tipo\n```html\n<ui-component name=\"box\" config=\"$type:number\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = () => console.log(self.type);  // number\n    });\n</script>\n```\n\n### $class:classes\n\nType: `config`\n\nAlterna clases CSS en el elemento.\n\nExample: Añadir una clase\n```html\n<ui-component name=\"box\" config=\"$class:highlighted\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### $assign:path\n\nType: `config`\n\nEscribe la instancia en un path.\n\nEl path se pone a `null` cuando se destruye la instancia.\n\nExample: Conservar una referencia\n```html\n<ui-component name=\"box\" config=\"$assign:common.box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(GET('common.box').name), 500);  // box\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nLlama a una función cuando la instancia está lista.\n\nLa función recibe la instancia, y `this` también es la instancia.\n\nExample: Una función de inicialización\n```html\n<ui-component name=\"box\" config=\"$init:common.onbox\"></ui-component>\n\n<script>\n    window.common = { onbox: instance => console.log('ready', instance.name) };  // ready box\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nLlama a una función cada vez que la instancia recibe un valor.\n\nLa función recibe `value`, `path` y `type`, y `this` es la instancia.\n\nExample: Observar los valores\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$setter:common.onvalue\"></ui-component>\n\n<script>\n    window.common = { onvalue: value => value && console.log(value) };  // Peter\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### $state:path\n\nType: `config`\n\nLlama a una función cada vez que cambia el estado de la instancia.\n\nLa función recibe `type` y `what`, los mismos argumentos que el delegate [`state`](../component/#state).\n\nExample: Observar el estado\n```html\n<ui-component name=\"box\" config=\"$state:common.onstate\"></ui-component>\n\n<script>\n    window.common = { onstate: (type, what) => console.log(type, what) };  // 0 3\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $noscope:true\n\nType: `config`\n\nMantiene el path fuera del `<ui-plugin>` más cercano.\n\nEl carácter `?` del path no se sustituye.\n\nExample: Ignorar el scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" config=\"$noscope:true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### $bindvisible:true\n\nType: `config`\n\nRetrasa los valores hasta que el elemento sea visible.\n\nTiene el mismo efecto que llamar a [`bindvisible()`](../component/#bindvisible) en la declaración.\n\nExample: Esperar a que el elemento sea visible\n```html\n<div id=\"tab\" style=\"display:none\">\n    <ui-component name=\"box\" path=\"form.name\" config=\"$bindvisible:true\"></ui-component>\n</div>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value) {\n            value && console.log('received', value);  // received Peter\n        };\n    });\n    SET('form.name', 'Peter');\n    setTimeout(() => $('#tab').show(), 500);\n</script>\n```\n\n### $url:url\n\nType: `config`\n\nImporta el componente cuando no está declarado.\n\nLa URL se pasa a `IMPORT()`. Se ejecuta una vez por URL.\n\nExample: Importar un componente que falta\n```html\n<ui-component name=\"remote\" config=\"$url:/components/remote.html\"></ui-component>\n```\n\n### $realtime:false\n\nType: `config`\n\nDetermina cuándo escribe su valor un input con `data-jc-bind`.\n\nCon `true`, el valor se escribe mientras el usuario teclea. Con `false`, se escribe en el evento `change`.\n\nExample: Escribir al cambiar\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$realtime:false\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var input = $('input').val('Peter').trigger('input');\n        setTimeout(function() {\n            console.log(GET('form.name') || 'empty');  // empty\n            input.trigger('change');\n            console.log(GET('form.name'));  // Peter\n        }, 300);\n    }, 500);\n</script>\n```\n\n### $delay:milliseconds\n\nType: `config`\n\nDefine el retardo del binding en tiempo real en milisegundos.\n\nEl valor predeterminado es `DEF.delaykeypress`, que es `200`.\n\nExample: Un retardo más corto\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$delay:20\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        $('input').val('Peter').trigger('input');\n        setTimeout(() => console.log(GET('form.name')), 60);  // Peter\n    }, 500);\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nDefine el valor predeterminado del path.\n\nEl atributo contiene una expresión de JavaScript. El valor se escribe cuando el path es `undefined`, y [`default()`](../component/#default) lo restaura.\n\nExample: Un valor predeterminado\n```html\n<ui-component name=\"box\" path=\"form.name\" default=\"'Anonymous'\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    setTimeout(() => console.log(GET('form.name')), 500);  // Anonymous\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un scope directamente en el elemento.\n\nEl valor es el path del scope. Funciona como envolver el elemento en un [`ui-plugin`](../ui-plugin/).\n\nExample: Un scope en el elemento\n```html\n<ui-component name=\"box\" plugin=\"users\" path=\"?.name\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // users.name\n    });\n</script>\n```\n\n### data-jc-path=\"path\"\n\nType: `property`\n\nDefine el path y tiene prioridad sobre el atributo `path`.\n\nExample: Sobrescribir el path\n```html\n<ui-component name=\"box\" path=\"form.a\" data-jc-path=\"form.b\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // form.b\n    });\n</script>\n```\n\n### data-jc-config=\"key:value\"\n\nType: `property`\n\nDefine la configuración y tiene prioridad sobre el atributo `config`.\n\nExample: Sobrescribir la configuración\n```html\n<ui-component name=\"box\" config=\"title:A\" data-jc-config=\"title:B\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        console.log(config.title);  // B\n    });\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nAlterna clases CSS cuando la instancia está lista.\n\nSepara varias clases con un espacio.\n\nExample: Una clase añadida después de la inicialización\n```html\n<ui-component name=\"box\" data-jc-class=\"ready\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### data-jc-noscope=\"true\"\n\nType: `property`\n\nMantiene el path fuera del `<ui-plugin>` más cercano.\n\nTiene el mismo efecto que la clave [`$noscope`](#x-noscope).\n\nExample: Ignorar el scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" data-jc-noscope=\"true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### element.get()\n\nType: `method`\n\nDevuelve el valor del path enlazado.\n\nReturns: `Object` El valor del path.\n\nExample: Leer el valor\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.get());  // Peter\n```\n\n### element.set(value, [type])\n\nType: `method`\n\nEscribe un valor en el path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `type` | `Number` | no |  | El tipo de la actualización que se pasa al setter. |\n\nLa instancia se marca como modificada.\n\nExample: Escribir un valor\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.update([type])\n\nType: `method`\n\nNotifica al path enlazado con su valor actual.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | El tipo de la actualización que se pasa al setter. |\n\nLa instancia se marca como modificada.\n\nExample: Refrescar después de un cambio directo\n```js\nvar element = document.querySelector('ui-component');\nwindow.form.name = 'Anna';\nelement.update();\nsetTimeout(() => console.log(element.textContent), 50);  // Anna\n```\n\n### element.modify(value, [type])\n\nType: `method`\n\nEscribe un valor a través de los parsers de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `type` | `Number` | no | `2` | El tipo de la actualización. |\n\nLlama a [`modify()`](../component/#modify) de la instancia.\n\nExample: Escribir un valor analizado\n```js\nvar element = document.querySelector('ui-component');\nelement.modify('  Anna  ');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.reconfigure([value], [init], [noemit])\n\nType: `method`\n\nCambia la configuración de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | no |  | La configuración nueva. |\n| `init` | `Boolean` | no |  | Pasa `init` al delegate `configure`. |\n| `noemit` | `Boolean` | no |  | Omite el delegate `configure`. |\n\nSin valor, el método vuelve a leer el atributo `config`.\n\nExample: Cambiar una clave\n```js\nvar element = document.querySelector('ui-component');\nelement.reconfigure('title:Invoices');\nconsole.log(element.config.title);  // Invoices\n```\n\n### element.reset()\n\nType: `method`\n\nLimpia el estado inválido y modificado de la instancia.\n\nExample: Limpiar el estado\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nelement.reset();\nconsole.log(element.config.modified);  // false\n```\n\n### element.config\n\nType: `property`\n\nEl objeto de configuración de la instancia.\n\nLa propiedad existe cuando la instancia ya se ha creado.\n\nExample: Leer la configuración\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.config.title);  // Orders\n```\n\n### element.setter = function(value, path, type)\n\nType: `delegate`\n\nUna función en el elemento del DOM que recibe cada valor.\n\nAsígnala al elemento. Se ejecuta después del delegate `setter` de la instancia, con los mismos argumentos.\n\nExample: Observar los valores desde fuera\n```js\nvar element = document.querySelector('ui-component');\nelement.setter = function(value, path, type) {\n    console.log(value, path, type);  // Anna form.name 1\n};\nSET('form.name', 'Anna');\n```\n\n### element.state = function(config)\n\nType: `delegate`\n\nUna función en el elemento del DOM que se ejecuta cuando cambia el estado.\n\nLa función recibe el objeto de configuración de la instancia.\n\nExample: Observar el estado desde fuera\n```js\nvar element = document.querySelector('ui-component');\nelement.state = function(config) {\n    console.log(config.touched);  // true\n};\nFIND('demo').bind('touched');\n```\n\n### element.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nUna función en el elemento del DOM que recibe los cambios de configuración.\n\nLa función recibe los mismos argumentos que el delegate [`configure`](../component/#configure).\n\nExample: Observar la configuración\n```js\nvar element = document.querySelector('ui-component');\nelement.configure = function(key, value, init, prev) {\n    console.log(key, value, prev);  // title Invoices Orders\n};\nelement.reconfigure('title:Invoices');\n```\n\n### $(element).on('component', callback)\n\nType: `event`\n\nUn evento de jQuery que se dispara en el elemento cuando la instancia está lista.\n\nEl evento se dispara una sola vez.\n\nExample: Esperar a la instancia\n```html\n<ui-component name=\"box\" id=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    $('#box').on('component', () => console.log('ready'));  // ready\n</script>\n```\n\n### .ui-modified\n\nType: `class`\n\nPresente mientras el valor de la instancia está modificado.\n\nRefleja `config.modified`.\n\nExample: La clase modified\n```js\nvar com = FIND('demo');\ncom.bind('modified');\nconsole.log(com.element.hclass('ui-modified'));  // true\n```\n\n### .ui-touched\n\nType: `class`\n\nPresente después de que el usuario haya interactuado con la instancia.\n\nRefleja `config.touched`.\n\nExample: La clase touched\n```js\nvar com = FIND('demo');\ncom.bind('touched');\nconsole.log(com.element.hclass('ui-touched'));  // true\n```\n\n### .ui-invalid\n\nType: `class`\n\nPresente mientras el valor de la instancia es inválido.\n\nRefleja `config.invalid`, que define el delegate [`validate`](../component/#validate).\n\nExample: La clase invalid\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.validate = value => !!value;\n    });\n</script>\n```\n\n### .ui-disabled\n\nType: `class`\n\nPresente mientras la instancia está desactivada.\n\nRefleja `config.disabled`. El comando [`disabled`](../ui-bind/#disabled) de `<ui-bind>` define la clave.\n\nExample: La clase disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n\n<script>\n    COMPONENT('box', function(self) {});\n    SET('form.locked', true);\n</script>\n```\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":"type","name":"Configuration from a path","signature":"config=\"=key:path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a path","signature":"config=\"=path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a global variable","signature":"config=\"%variable\"","since":"","deprecated":false},{"type":"type","name":"Responsive configuration","signature":"config=\"key:@xs=value,@lg=value\"","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:identifier","since":"","deprecated":false},{"type":"config","name":"$type","signature":"$type:type","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:classes","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","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":"$state","signature":"$state:path","since":"","deprecated":false},{"type":"config","name":"$noscope","signature":"$noscope:true","since":"","deprecated":false},{"type":"config","name":"$bindvisible","signature":"$bindvisible:true","since":"","deprecated":false},{"type":"config","name":"$url","signature":"$url:url","since":"","deprecated":false},{"type":"config","name":"$realtime","signature":"$realtime:false","since":"","deprecated":false},{"type":"config","name":"$delay","signature":"$delay:milliseconds","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-path","signature":"data-jc-path=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-config","signature":"data-jc-config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-noscope","signature":"data-jc-noscope=\"true\"","since":"","deprecated":false},{"type":"method","name":"get()","signature":"element.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"element.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"element.update([type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"element.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"element.reconfigure([value], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"element.reset()","since":"","deprecated":false},{"type":"property","name":"element.config","signature":"element.config","since":"","deprecated":false},{"type":"delegate","name":"element.setter","signature":"element.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"element.state","signature":"element.state = function(config)","since":"","deprecated":false},{"type":"delegate","name":"element.configure","signature":"element.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"event","name":"component","signature":"$(element).on('component', callback)","since":"","deprecated":false},{"type":"class","name":"ui-modified","signature":".ui-modified","since":"","deprecated":false},{"type":"class","name":"ui-touched","signature":".ui-touched","since":"","deprecated":false},{"type":"class","name":"ui-invalid","signature":".ui-invalid","since":"","deprecated":false},{"type":"class","name":"ui-disabled","signature":".ui-disabled","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammld28r61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"ui-component","summary":"Les attributs, les clés de configuration, les méthodes et les classes CSS de l'élément ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-component\n\n> Les attributs, les clés de configuration, les méthodes et les classes CSS de l'élément ui-component.\n\nL'élément `<ui-component>` place dans la page un composant déclaré avec `COMPONENT()`. Ses attributs sélectionnent le composant, le lient à un path et le configurent. [Utiliser les composants](../../guides/using-components/) explique comment travailler avec l'élément, et l'instance qu'il crée est décrite dans [Composant](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nSélectionne le composant à créer.\n\nL'attribut accepte ces formes :\n\n| Valeur | Signification |\n| --- | --- |\n| `box` | Le composant déclaré sous le nom `box`. |\n| `box@2` | Le composant déclaré sous le nom `box@2`. |\n| `box\\|panel` | Le premier composant déclaré parmi ceux de la liste. |\n| `box,panel` | Une instance de chaque composant sur le même élément. |\n| `lazy box` | L'instance est créée au premier appel de `SETTER()` pour `box`. |\n\nUn élément sans `name` est ignoré.\n\nExample: Un composant lié à un path\n```html\n<ui-component name=\"hello\" path=\"common.user\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        self.setter = function(value) {\n            self.text('Hello ' + value);\n        };\n    });\n    SET('common.user', 'Peter');\n</script>\n```\n\nExample: Le premier composant déclaré l'emporte\n```html\n<ui-component name=\"missing|hello\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        console.log(self.name);  // hello\n    });\n</script>\n```\n\nExample: Un composant différé\n```html\n<ui-component name=\"lazy dialog\"></ui-component>\n\n<script>\n    COMPONENT('dialog', function(self) {\n        self.show = function(title) {\n            console.log('show', title);  // show Welcome\n        };\n    });\n\n    // The first SETTER() call creates the instance\n    setTimeout(() => SETTER('dialog/show', 'Welcome'), 500);\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nLie le composant à un path du modèle de données.\n\nLa valeur du path est passée au delegate [`setter`](../component/#setter). L'attribut accepte ces formes :\n\n| Valeur | Signification |\n| --- | --- |\n| `form.name` | Un path absolu. |\n| `?.name` | Un path relatif au [`ui-plugin`](../ui-plugin/) le plus proche. |\n| `?` | Le path du `<ui-plugin>` le plus proche. |\n| `*name` | Un path à l'intérieur de `DEF.pathcommon`, qui vaut `common.` par défaut. |\n| `%name` | Un path temporaire. |\n| `@key` | Lit la valeur stockée avec [`data()`](../component/#data) du composant parent. |\n| `form.name --> expression` | Transforme la valeur avec une expression qui reçoit `value`. |\n\nUn composant sans `path` n'est pas lié au modèle de données. Tu trouveras plus de détails sur la syntaxe dans [Paths](../../guides/paths/).\n\nExample: Formes de path\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"show\" path=\"?.name\"></ui-component>\n</ui-plugin>\n<ui-component name=\"show\" path=\"*title\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('show', function(self) {\n        console.log(self.path);\n    });\n</script>\n```\n\nExample: Transformer la valeur\n```html\n<ui-component name=\"upper\" path=\"form.name --> (value || '').toUpperCase()\"></ui-component>\n\n<script>\n    COMPONENT('upper', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'peter');\n</script>\n```\n\nExample: Lire les données du composant parent\n```html\n<ui-component name=\"card\">\n    <ui-component name=\"label\" path=\"@title\"></ui-component>\n</ui-component>\n\n<script>\n    COMPONENT('card', function(self) {\n        self.make = function() {\n            self.data('title', 'Orders');\n        };\n    });\n    COMPONENT('label', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    setTimeout(() => FIND('card').data('title', 'Invoices'), 500);\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nDéfinit la configuration initiale de l'instance.\n\nLa valeur est une liste de paires `key:value` séparées par des points-virgules. Les nombres et les booléens sont convertis dans leur type. L'attribut est lu une seule fois, à la création de l'instance. Pour modifier la configuration plus tard, appelle [`reconfigure()`](#reconfigure).\n\nLa configuration est fusionnée dans cet ordre : la valeur par défaut de `COMPONENT()`, cet attribut, puis les règles de `CONFIG()`.\n\nExample: Valeurs typées\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;visible:true\"></ui-component>\n\n<script>\n    COMPONENT('box', 'limit:5;color:red', function(self, config) {\n        console.log(config.title, config.limit, config.visible, config.color);  // Orders 10 true red\n    });\n</script>\n```\n\n### config=\"=key:path\"\n\nType: `type`\n\nUne clé qui commence par `=` lit sa valeur depuis un path et suit ses modifications.\n\nLa valeur de `=key:path` est lue depuis le path. Quand le path change, l'instance reçoit la nouvelle valeur via le delegate [`configure`](../component/#configure).\n\nExample: Une clé observée\n```html\n<ui-component name=\"box\" config=\"=title:common.title\"></ui-component>\n\n<script>\n    SET('common.title', 'First');\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.title', 'Second'), 500);\n</script>\n```\n\n### config=\"=path\"\n\nType: `type`\n\nUne valeur qui commence par `=` et ne contient pas de deux-points charge toute la configuration depuis un path.\n\nLe path doit contenir un objet. L'instance est reconfigurée chaque fois que le path change.\n\nExample: Lire un objet\n```html\n<ui-component name=\"box\" config=\"=common.options\"></ui-component>\n\n<script>\n    SET('common.options', { title: 'Orders' });\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.options', { title: 'Invoices' }), 500);\n</script>\n```\n\n### config=\"%variable\"\n\nType: `type`\n\nUne valeur qui commence par `%` utilise une variable globale comme objet de configuration.\n\nL'instance travaille directement avec l'objet stocké dans `window`.\n\nExample: Utiliser un objet global\n```html\n<ui-component name=\"box\" config=\"%boxoptions\"></ui-component>\n\n<script>\n    window.boxoptions = { title: 'Orders' };\n    COMPONENT('box', function(self, config) {\n        console.log(config.title, config === window.boxoptions);  // Orders true\n    });\n</script>\n```\n\n### config=\"key:@xs=value,@lg=value\"\n\nType: `type`\n\nUne valeur peut varier selon la taille d'affichage ou l'apparence claire ou sombre.\n\nÉcris les variantes sous la forme `@name=value`, séparées par des virgules. Les noms sont `xs`, `sm`, `md`, `lg`, `dark` et `light`. La valeur qui correspond à l'affichage actuel est utilisée. Si la taille actuelle n'a pas de valeur, c'est la taille définie la plus proche qui s'applique.\n\nExample: Une valeur par taille d'affichage\n```html\n<ui-component name=\"grid\" config=\"columns:@xs=1,@sm=2,@md=3,@lg=4\"></ui-component>\n\n<script>\n    COMPONENT('grid', function(self, config) {\n        console.log(WIDTH(), config.columns);  // xs 1\n    });\n</script>\n```\n\n### $id:identifier\n\nType: `config`\n\nDéfinit l'identifiant de l'instance.\n\nL'identifiant est stocké dans [`id`](../component/#id) et peut être utilisé dans des sélecteurs comme `#users`.\n\nExample: Trouver une instance par son identifiant\n```html\n<ui-component name=\"box\" config=\"$id:users\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(FIND('#users').name), 500);  // box\n</script>\n```\n\n### $type:type\n\nType: `config`\n\nDéfinit le type de données de l'instance.\n\nLe type est stocké dans [`type`](../component/#type) et passé aux parseurs et aux formateurs.\n\nExample: Définir le type\n```html\n<ui-component name=\"box\" config=\"$type:number\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = () => console.log(self.type);  // number\n    });\n</script>\n```\n\n### $class:classes\n\nType: `config`\n\nBascule des classes CSS sur l'élément.\n\nExample: Ajouter une classe\n```html\n<ui-component name=\"box\" config=\"$class:highlighted\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### $assign:path\n\nType: `config`\n\nÉcrit l'instance dans un path.\n\nLe path reçoit `null` quand l'instance est détruite.\n\nExample: Conserver une référence\n```html\n<ui-component name=\"box\" config=\"$assign:common.box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(GET('common.box').name), 500);  // box\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nAppelle une fonction quand l'instance est prête.\n\nLa fonction reçoit l'instance, et `this` est aussi l'instance.\n\nExample: Une fonction d'initialisation\n```html\n<ui-component name=\"box\" config=\"$init:common.onbox\"></ui-component>\n\n<script>\n    window.common = { onbox: instance => console.log('ready', instance.name) };  // ready box\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nAppelle une fonction chaque fois que l'instance reçoit une valeur.\n\nLa fonction reçoit `value`, `path` et `type`, et `this` est l'instance.\n\nExample: Observer les valeurs\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$setter:common.onvalue\"></ui-component>\n\n<script>\n    window.common = { onvalue: value => value && console.log(value) };  // Peter\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### $state:path\n\nType: `config`\n\nAppelle une fonction chaque fois que l'état de l'instance change.\n\nLa fonction reçoit `type` et `what`, les mêmes arguments que le delegate [`state`](../component/#state).\n\nExample: Observer l'état\n```html\n<ui-component name=\"box\" config=\"$state:common.onstate\"></ui-component>\n\n<script>\n    window.common = { onstate: (type, what) => console.log(type, what) };  // 0 3\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $noscope:true\n\nType: `config`\n\nGarde le path en dehors du `<ui-plugin>` le plus proche.\n\nLe caractère `?` du path n'est pas remplacé.\n\nExample: Ignorer le scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" config=\"$noscope:true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### $bindvisible:true\n\nType: `config`\n\nRetarde les valeurs jusqu'à ce que l'élément soit visible.\n\nL'effet est le même que l'appel de [`bindvisible()`](../component/#bindvisible) dans la déclaration.\n\nExample: Attendre un élément visible\n```html\n<div id=\"tab\" style=\"display:none\">\n    <ui-component name=\"box\" path=\"form.name\" config=\"$bindvisible:true\"></ui-component>\n</div>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value) {\n            value && console.log('received', value);  // received Peter\n        };\n    });\n    SET('form.name', 'Peter');\n    setTimeout(() => $('#tab').show(), 500);\n</script>\n```\n\n### $url:url\n\nType: `config`\n\nImporte le composant quand il n'est pas déclaré.\n\nL'URL est passée à `IMPORT()`. L'importation s'exécute une fois par URL.\n\nExample: Importer un composant manquant\n```html\n<ui-component name=\"remote\" config=\"$url:/components/remote.html\"></ui-component>\n```\n\n### $realtime:false\n\nType: `config`\n\nChoisit à quel moment un champ avec `data-jc-bind` écrit sa valeur.\n\nAvec `true`, la valeur est écrite pendant la saisie de l'utilisateur. Avec `false`, elle est écrite lors de l'événement `change`.\n\nExample: Écrire lors du changement\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$realtime:false\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var input = $('input').val('Peter').trigger('input');\n        setTimeout(function() {\n            console.log(GET('form.name') || 'empty');  // empty\n            input.trigger('change');\n            console.log(GET('form.name'));  // Peter\n        }, 300);\n    }, 500);\n</script>\n```\n\n### $delay:milliseconds\n\nType: `config`\n\nDéfinit le délai de la liaison en temps réel, en millisecondes.\n\nLa valeur par défaut est `DEF.delaykeypress`, qui vaut `200`.\n\nExample: Un délai plus court\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$delay:20\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        $('input').val('Peter').trigger('input');\n        setTimeout(() => console.log(GET('form.name')), 60);  // Peter\n    }, 500);\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nDéfinit la valeur par défaut du path.\n\nL'attribut contient une expression JavaScript. La valeur est écrite quand le path vaut `undefined`, et [`default()`](../component/#default) la restaure.\n\nExample: Une valeur par défaut\n```html\n<ui-component name=\"box\" path=\"form.name\" default=\"'Anonymous'\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    setTimeout(() => console.log(GET('form.name')), 500);  // Anonymous\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrée un scope directement sur l'élément.\n\nLa valeur est le path du scope. Cela revient à envelopper l'élément dans un [`ui-plugin`](../ui-plugin/).\n\nExample: Un scope sur l'élément\n```html\n<ui-component name=\"box\" plugin=\"users\" path=\"?.name\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // users.name\n    });\n</script>\n```\n\n### data-jc-path=\"path\"\n\nType: `property`\n\nDéfinit le path et a la priorité sur l'attribut `path`.\n\nExample: Remplacer le path\n```html\n<ui-component name=\"box\" path=\"form.a\" data-jc-path=\"form.b\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // form.b\n    });\n</script>\n```\n\n### data-jc-config=\"key:value\"\n\nType: `property`\n\nDéfinit la configuration et a la priorité sur l'attribut `config`.\n\nExample: Remplacer la configuration\n```html\n<ui-component name=\"box\" config=\"title:A\" data-jc-config=\"title:B\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        console.log(config.title);  // B\n    });\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nBascule des classes CSS quand l'instance est prête.\n\nSépare plusieurs classes par un espace.\n\nExample: Une classe ajoutée après l'initialisation\n```html\n<ui-component name=\"box\" data-jc-class=\"ready\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### data-jc-noscope=\"true\"\n\nType: `property`\n\nGarde le path en dehors du `<ui-plugin>` le plus proche.\n\nL'effet est le même que celui de la clé [`$noscope`](#x-noscope).\n\nExample: Ignorer le scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" data-jc-noscope=\"true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### element.get()\n\nType: `method`\n\nRenvoie la valeur du path lié.\n\nReturns: `Object` La valeur du path.\n\nExample: Lire la valeur\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.get());  // Peter\n```\n\n### element.set(value, [type])\n\nType: `method`\n\nÉcrit une valeur dans le path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `type` | `Number` | no |  | Le type de la mise à jour passé au setter. |\n\nL'instance est marquée comme modifiée.\n\nExample: Écrire une valeur\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.update([type])\n\nType: `method`\n\nNotifie le path lié avec sa valeur actuelle.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Le type de la mise à jour passé au setter. |\n\nL'instance est marquée comme modifiée.\n\nExample: Rafraîchir après une modification directe\n```js\nvar element = document.querySelector('ui-component');\nwindow.form.name = 'Anna';\nelement.update();\nsetTimeout(() => console.log(element.textContent), 50);  // Anna\n```\n\n### element.modify(value, [type])\n\nType: `method`\n\nÉcrit une valeur en passant par les parseurs de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `type` | `Number` | no | `2` | Le type de la mise à jour. |\n\nElle appelle [`modify()`](../component/#modify) de l'instance.\n\nExample: Écrire une valeur analysée\n```js\nvar element = document.querySelector('ui-component');\nelement.modify('  Anna  ');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.reconfigure([value], [init], [noemit])\n\nType: `method`\n\nModifie la configuration de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | no |  | La nouvelle configuration. |\n| `init` | `Boolean` | no |  | Passe `init` au delegate `configure`. |\n| `noemit` | `Boolean` | no |  | Ignore le delegate `configure`. |\n\nSans valeur, la méthode relit l'attribut `config`.\n\nExample: Modifier une clé\n```js\nvar element = document.querySelector('ui-component');\nelement.reconfigure('title:Invoices');\nconsole.log(element.config.title);  // Invoices\n```\n\n### element.reset()\n\nType: `method`\n\nEfface l'état invalide et modifié de l'instance.\n\nExample: Effacer l'état\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nelement.reset();\nconsole.log(element.config.modified);  // false\n```\n\n### element.config\n\nType: `property`\n\nL'objet de configuration de l'instance.\n\nLa propriété existe une fois l'instance créée.\n\nExample: Lire la configuration\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.config.title);  // Orders\n```\n\n### element.setter = function(value, path, type)\n\nType: `delegate`\n\nUne fonction sur l'élément DOM qui reçoit chaque valeur.\n\nAssigne-la à l'élément. Elle s'exécute après le delegate `setter` de l'instance, avec les mêmes arguments.\n\nExample: Observer les valeurs depuis l'extérieur\n```js\nvar element = document.querySelector('ui-component');\nelement.setter = function(value, path, type) {\n    console.log(value, path, type);  // Anna form.name 1\n};\nSET('form.name', 'Anna');\n```\n\n### element.state = function(config)\n\nType: `delegate`\n\nUne fonction sur l'élément DOM qui s'exécute quand l'état change.\n\nLa fonction reçoit l'objet de configuration de l'instance.\n\nExample: Observer l'état depuis l'extérieur\n```js\nvar element = document.querySelector('ui-component');\nelement.state = function(config) {\n    console.log(config.touched);  // true\n};\nFIND('demo').bind('touched');\n```\n\n### element.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nUne fonction sur l'élément DOM qui reçoit les modifications de configuration.\n\nLa fonction reçoit les mêmes arguments que le delegate [`configure`](../component/#configure).\n\nExample: Observer la configuration\n```js\nvar element = document.querySelector('ui-component');\nelement.configure = function(key, value, init, prev) {\n    console.log(key, value, prev);  // title Invoices Orders\n};\nelement.reconfigure('title:Invoices');\n```\n\n### $(element).on('component', callback)\n\nType: `event`\n\nUn événement jQuery déclenché sur l'élément quand l'instance est prête.\n\nL'événement est déclenché une seule fois.\n\nExample: Attendre l'instance\n```html\n<ui-component name=\"box\" id=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    $('#box').on('component', () => console.log('ready'));  // ready\n</script>\n```\n\n### .ui-modified\n\nType: `class`\n\nPrésente tant que la valeur de l'instance est modifiée.\n\nElle suit `config.modified`.\n\nExample: La classe modified\n```js\nvar com = FIND('demo');\ncom.bind('modified');\nconsole.log(com.element.hclass('ui-modified'));  // true\n```\n\n### .ui-touched\n\nType: `class`\n\nPrésente une fois que l'utilisateur a interagi avec l'instance.\n\nElle suit `config.touched`.\n\nExample: La classe touched\n```js\nvar com = FIND('demo');\ncom.bind('touched');\nconsole.log(com.element.hclass('ui-touched'));  // true\n```\n\n### .ui-invalid\n\nType: `class`\n\nPrésente tant que la valeur de l'instance est invalide.\n\nElle suit `config.invalid`, défini par le delegate [`validate`](../component/#validate).\n\nExample: La classe invalid\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.validate = value => !!value;\n    });\n</script>\n```\n\n### .ui-disabled\n\nType: `class`\n\nPrésente tant que l'instance est désactivée.\n\nElle suit `config.disabled`. La commande [`disabled`](../ui-bind/#disabled) de `<ui-bind>` définit la clé.\n\nExample: La classe disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n\n<script>\n    COMPONENT('box', function(self) {});\n    SET('form.locked', true);\n</script>\n```\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":"type","name":"Configuration from a path","signature":"config=\"=key:path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a path","signature":"config=\"=path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a global variable","signature":"config=\"%variable\"","since":"","deprecated":false},{"type":"type","name":"Responsive configuration","signature":"config=\"key:@xs=value,@lg=value\"","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:identifier","since":"","deprecated":false},{"type":"config","name":"$type","signature":"$type:type","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:classes","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","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":"$state","signature":"$state:path","since":"","deprecated":false},{"type":"config","name":"$noscope","signature":"$noscope:true","since":"","deprecated":false},{"type":"config","name":"$bindvisible","signature":"$bindvisible:true","since":"","deprecated":false},{"type":"config","name":"$url","signature":"$url:url","since":"","deprecated":false},{"type":"config","name":"$realtime","signature":"$realtime:false","since":"","deprecated":false},{"type":"config","name":"$delay","signature":"$delay:milliseconds","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-path","signature":"data-jc-path=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-config","signature":"data-jc-config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-noscope","signature":"data-jc-noscope=\"true\"","since":"","deprecated":false},{"type":"method","name":"get()","signature":"element.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"element.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"element.update([type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"element.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"element.reconfigure([value], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"element.reset()","since":"","deprecated":false},{"type":"property","name":"element.config","signature":"element.config","since":"","deprecated":false},{"type":"delegate","name":"element.setter","signature":"element.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"element.state","signature":"element.state = function(config)","since":"","deprecated":false},{"type":"delegate","name":"element.configure","signature":"element.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"event","name":"component","signature":"$(element).on('component', callback)","since":"","deprecated":false},{"type":"class","name":"ui-modified","signature":".ui-modified","since":"","deprecated":false},{"type":"class","name":"ui-touched","signature":".ui-touched","since":"","deprecated":false},{"type":"class","name":"ui-invalid","signature":".ui-invalid","since":"","deprecated":false},{"type":"class","name":"ui-disabled","signature":".ui-disabled","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammld28r61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"ui-component","summary":"Gli attributi, le chiavi di configurazione, i metodi e le classi CSS dell'elemento ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-component\n\n> Gli attributi, le chiavi di configurazione, i metodi e le classi CSS dell'elemento ui-component.\n\nL'elemento `<ui-component>` inserisce nella pagina un componente dichiarato con `COMPONENT()`. I suoi attributi selezionano il componente, lo associano a un path e lo configurano. [Uso dei componenti](../../guides/using-components/) spiega come lavorare con l'elemento, e l'istanza che crea è descritta in [Componente](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nSeleziona il componente da creare.\n\nL'attributo accetta queste forme:\n\n| Valore | Significato |\n| --- | --- |\n| `box` | Il componente dichiarato come `box`. |\n| `box@2` | Il componente dichiarato come `box@2`. |\n| `box\\|panel` | Il primo dei componenti elencati che risulta dichiarato. |\n| `box,panel` | Un'istanza di ciascun componente sullo stesso elemento. |\n| `lazy box` | L'istanza viene creata alla prima chiamata di `SETTER()` per `box`. |\n\nUn elemento senza `name` viene ignorato.\n\nExample: Un componente associato a un path\n```html\n<ui-component name=\"hello\" path=\"common.user\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        self.setter = function(value) {\n            self.text('Hello ' + value);\n        };\n    });\n    SET('common.user', 'Peter');\n</script>\n```\n\nExample: Vince il primo componente dichiarato\n```html\n<ui-component name=\"missing|hello\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        console.log(self.name);  // hello\n    });\n</script>\n```\n\nExample: Un componente lazy\n```html\n<ui-component name=\"lazy dialog\"></ui-component>\n\n<script>\n    COMPONENT('dialog', function(self) {\n        self.show = function(title) {\n            console.log('show', title);  // show Welcome\n        };\n    });\n\n    // The first SETTER() call creates the instance\n    setTimeout(() => SETTER('dialog/show', 'Welcome'), 500);\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nAssocia il componente a un path del modello dei dati.\n\nIl valore del path viene passato al delegate [`setter`](../component/#setter). L'attributo accetta queste forme:\n\n| Valore | Significato |\n| --- | --- |\n| `form.name` | Un path assoluto. |\n| `?.name` | Un path relativo al [`ui-plugin`](../ui-plugin/) più vicino. |\n| `?` | Il path del `<ui-plugin>` più vicino. |\n| `*name` | Un path dentro `DEF.pathcommon`, che per impostazione predefinita è `common.`. |\n| `%name` | Un path temporaneo. |\n| `@key` | Legge il valore memorizzato con [`data()`](../component/#data) del componente padre. |\n| `form.name --> expression` | Trasforma il valore con un'espressione che riceve `value`. |\n\nUn componente senza `path` non è associato al modello dei dati. Trovi altri dettagli sulla sintassi in [Path](../../guides/paths/).\n\nExample: Forme del path\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"show\" path=\"?.name\"></ui-component>\n</ui-plugin>\n<ui-component name=\"show\" path=\"*title\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('show', function(self) {\n        console.log(self.path);\n    });\n</script>\n```\n\nExample: Trasformare il valore\n```html\n<ui-component name=\"upper\" path=\"form.name --> (value || '').toUpperCase()\"></ui-component>\n\n<script>\n    COMPONENT('upper', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'peter');\n</script>\n```\n\nExample: Leggere i dati del componente padre\n```html\n<ui-component name=\"card\">\n    <ui-component name=\"label\" path=\"@title\"></ui-component>\n</ui-component>\n\n<script>\n    COMPONENT('card', function(self) {\n        self.make = function() {\n            self.data('title', 'Orders');\n        };\n    });\n    COMPONENT('label', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    setTimeout(() => FIND('card').data('title', 'Invoices'), 500);\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nImposta la configurazione iniziale dell'istanza.\n\nIl valore è un elenco di coppie `key:value` separate da punti e virgola. Numeri e booleani vengono convertiti nei rispettivi tipi. L'attributo viene letto una sola volta, quando viene creata l'istanza. Per cambiare la configurazione in seguito, chiama [`reconfigure()`](#reconfigure).\n\nLa configurazione viene unita in questo ordine: il valore predefinito di `COMPONENT()`, questo attributo e infine le regole di `CONFIG()`.\n\nExample: Valori tipizzati\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;visible:true\"></ui-component>\n\n<script>\n    COMPONENT('box', 'limit:5;color:red', function(self, config) {\n        console.log(config.title, config.limit, config.visible, config.color);  // Orders 10 true red\n    });\n</script>\n```\n\n### config=\"=key:path\"\n\nType: `type`\n\nUna chiave che inizia con `=` legge il proprio valore da un path e ne segue le modifiche.\n\nIl valore di `=key:path` viene letto dal path. Quando il path cambia, l'istanza riceve il nuovo valore tramite il delegate [`configure`](../component/#configure).\n\nExample: Una chiave osservata\n```html\n<ui-component name=\"box\" config=\"=title:common.title\"></ui-component>\n\n<script>\n    SET('common.title', 'First');\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.title', 'Second'), 500);\n</script>\n```\n\n### config=\"=path\"\n\nType: `type`\n\nUn valore che inizia con `=` e non ha due punti carica l'intera configurazione da un path.\n\nIl path deve contenere un oggetto. L'istanza viene riconfigurata ogni volta che il path cambia.\n\nExample: Leggere un oggetto\n```html\n<ui-component name=\"box\" config=\"=common.options\"></ui-component>\n\n<script>\n    SET('common.options', { title: 'Orders' });\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.options', { title: 'Invoices' }), 500);\n</script>\n```\n\n### config=\"%variable\"\n\nType: `type`\n\nUn valore che inizia con `%` usa una variabile globale come oggetto di configurazione.\n\nL'istanza lavora direttamente con l'oggetto memorizzato in `window`.\n\nExample: Usare un oggetto globale\n```html\n<ui-component name=\"box\" config=\"%boxoptions\"></ui-component>\n\n<script>\n    window.boxoptions = { title: 'Orders' };\n    COMPONENT('box', function(self, config) {\n        console.log(config.title, config === window.boxoptions);  // Orders true\n    });\n</script>\n```\n\n### config=\"key:@xs=value,@lg=value\"\n\nType: `type`\n\nUn valore può variare in base alle dimensioni dello schermo o all'aspetto chiaro e scuro.\n\nScrivi le alternative come `@name=value` separate da virgole. I nomi sono `xs`, `sm`, `md`, `lg`, `dark` e `light`. Viene usato il valore che corrisponde allo schermo corrente. Se le dimensioni correnti non hanno un valore, viene usata la dimensione definita più vicina.\n\nExample: Un valore per ogni dimensione dello schermo\n```html\n<ui-component name=\"grid\" config=\"columns:@xs=1,@sm=2,@md=3,@lg=4\"></ui-component>\n\n<script>\n    COMPONENT('grid', function(self, config) {\n        console.log(WIDTH(), config.columns);  // xs 1\n    });\n</script>\n```\n\n### $id:identifier\n\nType: `config`\n\nImposta l'identificatore dell'istanza.\n\nL'identificatore viene memorizzato in [`id`](../component/#id) e puoi usarlo in selettori come `#users`.\n\nExample: Trovare un'istanza tramite il suo identificatore\n```html\n<ui-component name=\"box\" config=\"$id:users\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(FIND('#users').name), 500);  // box\n</script>\n```\n\n### $type:type\n\nType: `config`\n\nImposta il tipo di dati dell'istanza.\n\nIl tipo viene memorizzato in [`type`](../component/#type) e viene passato a parser e formatter.\n\nExample: Impostare il tipo\n```html\n<ui-component name=\"box\" config=\"$type:number\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = () => console.log(self.type);  // number\n    });\n</script>\n```\n\n### $class:classes\n\nType: `config`\n\nAttiva o disattiva le classi CSS sull'elemento.\n\nExample: Aggiungere una classe\n```html\n<ui-component name=\"box\" config=\"$class:highlighted\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### $assign:path\n\nType: `config`\n\nScrive l'istanza in un path.\n\nIl path viene impostato a `null` quando l'istanza viene distrutta.\n\nExample: Conservare un riferimento\n```html\n<ui-component name=\"box\" config=\"$assign:common.box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(GET('common.box').name), 500);  // box\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nChiama una funzione quando l'istanza è pronta.\n\nLa funzione riceve l'istanza, e anche `this` è l'istanza.\n\nExample: Una funzione di inizializzazione\n```html\n<ui-component name=\"box\" config=\"$init:common.onbox\"></ui-component>\n\n<script>\n    window.common = { onbox: instance => console.log('ready', instance.name) };  // ready box\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nChiama una funzione ogni volta che l'istanza riceve un valore.\n\nLa funzione riceve `value`, `path` e `type`, e `this` è l'istanza.\n\nExample: Osservare i valori\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$setter:common.onvalue\"></ui-component>\n\n<script>\n    window.common = { onvalue: value => value && console.log(value) };  // Peter\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### $state:path\n\nType: `config`\n\nChiama una funzione ogni volta che lo stato dell'istanza cambia.\n\nLa funzione riceve `type` e `what`, gli stessi argomenti del delegate [`state`](../component/#state).\n\nExample: Osservare lo stato\n```html\n<ui-component name=\"box\" config=\"$state:common.onstate\"></ui-component>\n\n<script>\n    window.common = { onstate: (type, what) => console.log(type, what) };  // 0 3\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $noscope:true\n\nType: `config`\n\nMantiene il path fuori dal `<ui-plugin>` più vicino.\n\nIl carattere `?` nel path non viene sostituito.\n\nExample: Ignorare lo scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" config=\"$noscope:true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### $bindvisible:true\n\nType: `config`\n\nRitarda i valori finché l'elemento non è visibile.\n\nHa lo stesso effetto di chiamare [`bindvisible()`](../component/#bindvisible) nella dichiarazione.\n\nExample: Attendere un elemento visibile\n```html\n<div id=\"tab\" style=\"display:none\">\n    <ui-component name=\"box\" path=\"form.name\" config=\"$bindvisible:true\"></ui-component>\n</div>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value) {\n            value && console.log('received', value);  // received Peter\n        };\n    });\n    SET('form.name', 'Peter');\n    setTimeout(() => $('#tab').show(), 500);\n</script>\n```\n\n### $url:url\n\nType: `config`\n\nImporta il componente quando non è dichiarato.\n\nL'URL viene passato a `IMPORT()`. Viene eseguito una sola volta per ogni URL.\n\nExample: Importare un componente mancante\n```html\n<ui-component name=\"remote\" config=\"$url:/components/remote.html\"></ui-component>\n```\n\n### $realtime:false\n\nType: `config`\n\nStabilisce quando un input con `data-jc-bind` scrive il proprio valore.\n\nCon `true` il valore viene scritto mentre l'utente digita. Con `false` viene scritto all'evento `change`.\n\nExample: Scrivere all'evento change\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$realtime:false\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var input = $('input').val('Peter').trigger('input');\n        setTimeout(function() {\n            console.log(GET('form.name') || 'empty');  // empty\n            input.trigger('change');\n            console.log(GET('form.name'));  // Peter\n        }, 300);\n    }, 500);\n</script>\n```\n\n### $delay:milliseconds\n\nType: `config`\n\nImposta il ritardo dell'associazione in tempo reale in millisecondi.\n\nIl valore predefinito è `DEF.delaykeypress`, cioè `200`.\n\nExample: Un ritardo più breve\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$delay:20\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        $('input').val('Peter').trigger('input');\n        setTimeout(() => console.log(GET('form.name')), 60);  // Peter\n    }, 500);\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nImposta il valore predefinito del path.\n\nL'attributo contiene un'espressione JavaScript. Il valore viene scritto quando il path è `undefined`, e [`default()`](../component/#default) lo ripristina.\n\nExample: Un valore predefinito\n```html\n<ui-component name=\"box\" path=\"form.name\" default=\"'Anonymous'\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    setTimeout(() => console.log(GET('form.name')), 500);  // Anonymous\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea uno scope direttamente sull'elemento.\n\nIl valore è il path dello scope. Funziona come se avvolgessi l'elemento in un [`ui-plugin`](../ui-plugin/).\n\nExample: Uno scope sull'elemento\n```html\n<ui-component name=\"box\" plugin=\"users\" path=\"?.name\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // users.name\n    });\n</script>\n```\n\n### data-jc-path=\"path\"\n\nType: `property`\n\nImposta il path e ha la priorità sull'attributo `path`.\n\nExample: Sovrascrivere il path\n```html\n<ui-component name=\"box\" path=\"form.a\" data-jc-path=\"form.b\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // form.b\n    });\n</script>\n```\n\n### data-jc-config=\"key:value\"\n\nType: `property`\n\nImposta la configurazione e ha la priorità sull'attributo `config`.\n\nExample: Sovrascrivere la configurazione\n```html\n<ui-component name=\"box\" config=\"title:A\" data-jc-config=\"title:B\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        console.log(config.title);  // B\n    });\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nAttiva o disattiva le classi CSS quando l'istanza è pronta.\n\nSepara più classi con uno spazio.\n\nExample: Una classe aggiunta dopo l'inizializzazione\n```html\n<ui-component name=\"box\" data-jc-class=\"ready\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### data-jc-noscope=\"true\"\n\nType: `property`\n\nMantiene il path fuori dal `<ui-plugin>` più vicino.\n\nHa lo stesso effetto della chiave [`$noscope`](#x-noscope).\n\nExample: Ignorare lo scope\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" data-jc-noscope=\"true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### element.get()\n\nType: `method`\n\nRestituisce il valore del path associato.\n\nReturns: `Object` Il valore del path.\n\nExample: Leggere il valore\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.get());  // Peter\n```\n\n### element.set(value, [type])\n\nType: `method`\n\nScrive un valore nel path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `type` | `Number` | no |  | Il tipo dell'aggiornamento passato al setter. |\n\nL'istanza viene segnata come modificata.\n\nExample: Scrivere un valore\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.update([type])\n\nType: `method`\n\nNotifica il path associato con il suo valore corrente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Il tipo dell'aggiornamento passato al setter. |\n\nL'istanza viene segnata come modificata.\n\nExample: Aggiornare dopo una modifica diretta\n```js\nvar element = document.querySelector('ui-component');\nwindow.form.name = 'Anna';\nelement.update();\nsetTimeout(() => console.log(element.textContent), 50);  // Anna\n```\n\n### element.modify(value, [type])\n\nType: `method`\n\nScrive un valore tramite i parser dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `type` | `Number` | no | `2` | Il tipo dell'aggiornamento. |\n\nChiama [`modify()`](../component/#modify) dell'istanza.\n\nExample: Scrivere un valore analizzato\n```js\nvar element = document.querySelector('ui-component');\nelement.modify('  Anna  ');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.reconfigure([value], [init], [noemit])\n\nType: `method`\n\nCambia la configurazione dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | no |  | La nuova configurazione. |\n| `init` | `Boolean` | no |  | Passa `init` al delegate `configure`. |\n| `noemit` | `Boolean` | no |  | Salta il delegate `configure`. |\n\nSenza un valore, il metodo legge di nuovo l'attributo `config`.\n\nExample: Cambiare una chiave\n```js\nvar element = document.querySelector('ui-component');\nelement.reconfigure('title:Invoices');\nconsole.log(element.config.title);  // Invoices\n```\n\n### element.reset()\n\nType: `method`\n\nAzzera lo stato di non valido e modificato dell'istanza.\n\nExample: Azzerare lo stato\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nelement.reset();\nconsole.log(element.config.modified);  // false\n```\n\n### element.config\n\nType: `property`\n\nL'oggetto di configurazione dell'istanza.\n\nLa proprietà esiste quando l'istanza è stata creata.\n\nExample: Leggere la configurazione\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.config.title);  // Orders\n```\n\n### element.setter = function(value, path, type)\n\nType: `delegate`\n\nUna funzione sull'elemento DOM che riceve ogni valore.\n\nAssegnala all'elemento. Viene eseguita dopo il delegate `setter` dell'istanza, con gli stessi argomenti.\n\nExample: Osservare i valori dall'esterno\n```js\nvar element = document.querySelector('ui-component');\nelement.setter = function(value, path, type) {\n    console.log(value, path, type);  // Anna form.name 1\n};\nSET('form.name', 'Anna');\n```\n\n### element.state = function(config)\n\nType: `delegate`\n\nUna funzione sull'elemento DOM che viene eseguita quando lo stato cambia.\n\nLa funzione riceve l'oggetto di configurazione dell'istanza.\n\nExample: Osservare lo stato dall'esterno\n```js\nvar element = document.querySelector('ui-component');\nelement.state = function(config) {\n    console.log(config.touched);  // true\n};\nFIND('demo').bind('touched');\n```\n\n### element.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nUna funzione sull'elemento DOM che riceve le modifiche della configurazione.\n\nLa funzione riceve gli stessi argomenti del delegate [`configure`](../component/#configure).\n\nExample: Osservare la configurazione\n```js\nvar element = document.querySelector('ui-component');\nelement.configure = function(key, value, init, prev) {\n    console.log(key, value, prev);  // title Invoices Orders\n};\nelement.reconfigure('title:Invoices');\n```\n\n### $(element).on('component', callback)\n\nType: `event`\n\nUn evento jQuery attivato sull'elemento quando l'istanza è pronta.\n\nL'evento viene attivato una sola volta.\n\nExample: Attendere l'istanza\n```html\n<ui-component name=\"box\" id=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    $('#box').on('component', () => console.log('ready'));  // ready\n</script>\n```\n\n### .ui-modified\n\nType: `class`\n\nPresente finché il valore dell'istanza risulta modificato.\n\nSegue `config.modified`.\n\nExample: La classe modified\n```js\nvar com = FIND('demo');\ncom.bind('modified');\nconsole.log(com.element.hclass('ui-modified'));  // true\n```\n\n### .ui-touched\n\nType: `class`\n\nPresente dopo che l'utente ha interagito con l'istanza.\n\nSegue `config.touched`.\n\nExample: La classe touched\n```js\nvar com = FIND('demo');\ncom.bind('touched');\nconsole.log(com.element.hclass('ui-touched'));  // true\n```\n\n### .ui-invalid\n\nType: `class`\n\nPresente finché il valore dell'istanza non è valido.\n\nSegue `config.invalid`, impostato dal delegate [`validate`](../component/#validate).\n\nExample: La classe invalid\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.validate = value => !!value;\n    });\n</script>\n```\n\n### .ui-disabled\n\nType: `class`\n\nPresente finché l'istanza è disabilitata.\n\nSegue `config.disabled`. Il comando [`disabled`](../ui-bind/#disabled) di `<ui-bind>` imposta la chiave.\n\nExample: La classe disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n\n<script>\n    COMPONENT('box', function(self) {});\n    SET('form.locked', true);\n</script>\n```\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":"type","name":"Configuration from a path","signature":"config=\"=key:path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a path","signature":"config=\"=path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a global variable","signature":"config=\"%variable\"","since":"","deprecated":false},{"type":"type","name":"Responsive configuration","signature":"config=\"key:@xs=value,@lg=value\"","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:identifier","since":"","deprecated":false},{"type":"config","name":"$type","signature":"$type:type","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:classes","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","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":"$state","signature":"$state:path","since":"","deprecated":false},{"type":"config","name":"$noscope","signature":"$noscope:true","since":"","deprecated":false},{"type":"config","name":"$bindvisible","signature":"$bindvisible:true","since":"","deprecated":false},{"type":"config","name":"$url","signature":"$url:url","since":"","deprecated":false},{"type":"config","name":"$realtime","signature":"$realtime:false","since":"","deprecated":false},{"type":"config","name":"$delay","signature":"$delay:milliseconds","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-path","signature":"data-jc-path=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-config","signature":"data-jc-config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-noscope","signature":"data-jc-noscope=\"true\"","since":"","deprecated":false},{"type":"method","name":"get()","signature":"element.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"element.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"element.update([type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"element.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"element.reconfigure([value], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"element.reset()","since":"","deprecated":false},{"type":"property","name":"element.config","signature":"element.config","since":"","deprecated":false},{"type":"delegate","name":"element.setter","signature":"element.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"element.state","signature":"element.state = function(config)","since":"","deprecated":false},{"type":"delegate","name":"element.configure","signature":"element.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"event","name":"component","signature":"$(element).on('component', callback)","since":"","deprecated":false},{"type":"class","name":"ui-modified","signature":".ui-modified","since":"","deprecated":false},{"type":"class","name":"ui-touched","signature":".ui-touched","since":"","deprecated":false},{"type":"class","name":"ui-invalid","signature":".ui-invalid","since":"","deprecated":false},{"type":"class","name":"ui-disabled","signature":".ui-disabled","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammld28r61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"ui-component","summary":"Atribúty, konfiguračné kľúče, metódy a triedy CSS elementu ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-component\n\n> Atribúty, konfiguračné kľúče, metódy a triedy CSS elementu ui-component.\n\nElement `<ui-component>` umiestni na stránku komponent deklarovaný pomocou `COMPONENT()`. Jeho atribúty vyberajú komponent, viažu ho na path a konfigurujú ho. Ako s elementom pracovať, vysvetľuje časť [Používanie komponentov](../../guides/using-components/) a inštanciu, ktorú vytvorí, popisuje časť [Komponent](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nVyberie komponent, ktorý sa má vytvoriť.\n\nAtribút prijíma tieto tvary:\n\n| Hodnota | Význam |\n| --- | --- |\n| `box` | Komponent deklarovaný ako `box`. |\n| `box@2` | Komponent deklarovaný ako `box@2`. |\n| `box\\|panel` | Prvý z uvedených komponentov, ktorý je deklarovaný. |\n| `box,panel` | Jedna inštancia každého komponentu na tom istom elemente. |\n| `lazy box` | Inštancia sa vytvorí pri prvom volaní `SETTER()` pre `box`. |\n\nElement bez `name` sa ignoruje.\n\nExample: Komponent viazaný na path\n```html\n<ui-component name=\"hello\" path=\"common.user\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        self.setter = function(value) {\n            self.text('Hello ' + value);\n        };\n    });\n    SET('common.user', 'Peter');\n</script>\n```\n\nExample: Vyhráva prvý deklarovaný komponent\n```html\n<ui-component name=\"missing|hello\"></ui-component>\n\n<script>\n    COMPONENT('hello', function(self) {\n        console.log(self.name);  // hello\n    });\n</script>\n```\n\nExample: Lazy komponent\n```html\n<ui-component name=\"lazy dialog\"></ui-component>\n\n<script>\n    COMPONENT('dialog', function(self) {\n        self.show = function(title) {\n            console.log('show', title);  // show Welcome\n        };\n    });\n\n    // The first SETTER() call creates the instance\n    setTimeout(() => SETTER('dialog/show', 'Welcome'), 500);\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nNaviaže komponent na path dátového modelu.\n\nHodnota na path sa odovzdá do delegate [`setter`](../component/#setter). Atribút prijíma tieto tvary:\n\n| Hodnota | Význam |\n| --- | --- |\n| `form.name` | Absolútna path. |\n| `?.name` | Path relatívna k najbližšiemu [`ui-plugin`](../ui-plugin/). |\n| `?` | Path najbližšieho `<ui-plugin>`. |\n| `*name` | Path v rámci `DEF.pathcommon`, čo je predvolene `common.`. |\n| `%name` | Dočasná path. |\n| `@key` | Prečíta hodnotu uloženú pomocou [`data()`](../component/#data) nadradeného komponentu. |\n| `form.name --> expression` | Transformuje hodnotu výrazom, ktorý dostane `value`. |\n\nKomponent bez `path` nie je viazaný na dátový model. Viac o syntaxi nájdeš v časti [Path](../../guides/paths/).\n\nExample: Tvary path\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"show\" path=\"?.name\"></ui-component>\n</ui-plugin>\n<ui-component name=\"show\" path=\"*title\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('show', function(self) {\n        console.log(self.path);\n    });\n</script>\n```\n\nExample: Transformácia hodnoty\n```html\n<ui-component name=\"upper\" path=\"form.name --> (value || '').toUpperCase()\"></ui-component>\n\n<script>\n    COMPONENT('upper', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'peter');\n</script>\n```\n\nExample: Čítanie údajov nadradeného komponentu\n```html\n<ui-component name=\"card\">\n    <ui-component name=\"label\" path=\"@title\"></ui-component>\n</ui-component>\n\n<script>\n    COMPONENT('card', function(self) {\n        self.make = function() {\n            self.data('title', 'Orders');\n        };\n    });\n    COMPONENT('label', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    setTimeout(() => FIND('card').data('title', 'Invoices'), 500);\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nNastaví počiatočnú konfiguráciu inštancie.\n\nHodnota je zoznam dvojíc `key:value` oddelených bodkočiarkami. Čísla a logické hodnoty sa prevedú na svoje typy. Atribút sa prečíta raz, pri vytvorení inštancie. Ak chceš konfiguráciu zmeniť neskôr, zavolaj [`reconfigure()`](#reconfigure).\n\nKonfigurácia sa zlučuje v tomto poradí: predvolené hodnoty z `COMPONENT()`, tento atribút a potom pravidlá z `CONFIG()`.\n\nExample: Typované hodnoty\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;visible:true\"></ui-component>\n\n<script>\n    COMPONENT('box', 'limit:5;color:red', function(self, config) {\n        console.log(config.title, config.limit, config.visible, config.color);  // Orders 10 true red\n    });\n</script>\n```\n\n### config=\"=key:path\"\n\nType: `type`\n\nKľúč, ktorý sa začína na `=`, číta svoju hodnotu z path a sleduje jej zmeny.\n\nHodnota `=key:path` sa číta z path. Keď sa path zmení, inštancia dostane novú hodnotu cez delegate [`configure`](../component/#configure).\n\nExample: Sledovaný kľúč\n```html\n<ui-component name=\"box\" config=\"=title:common.title\"></ui-component>\n\n<script>\n    SET('common.title', 'First');\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.title', 'Second'), 500);\n</script>\n```\n\n### config=\"=path\"\n\nType: `type`\n\nHodnota, ktorá sa začína na `=` a nemá dvojbodku, načíta celú konfiguráciu z path.\n\nPath musí obsahovať objekt. Inštancia sa prekonfiguruje pri každej zmene path.\n\nExample: Čítanie objektu\n```html\n<ui-component name=\"box\" config=\"=common.options\"></ui-component>\n\n<script>\n    SET('common.options', { title: 'Orders' });\n    COMPONENT('box', function(self, config) {\n        self.configure = function(key, value) {\n            key === 'title' && self.text(value);\n        };\n    });\n    setTimeout(() => SET('common.options', { title: 'Invoices' }), 500);\n</script>\n```\n\n### config=\"%variable\"\n\nType: `type`\n\nHodnota, ktorá sa začína na `%`, použije ako konfiguračný objekt globálnu premennú.\n\nInštancia pracuje priamo s objektom uloženým vo `window`.\n\nExample: Použitie globálneho objektu\n```html\n<ui-component name=\"box\" config=\"%boxoptions\"></ui-component>\n\n<script>\n    window.boxoptions = { title: 'Orders' };\n    COMPONENT('box', function(self, config) {\n        console.log(config.title, config === window.boxoptions);  // Orders true\n    });\n</script>\n```\n\n### config=\"key:@xs=value,@lg=value\"\n\nType: `type`\n\nHodnota sa môže líšiť podľa veľkosti displeja alebo podľa svetlého a tmavého vzhľadu.\n\nAlternatívy zapíš ako `@name=value` oddelené čiarkami. Názvy sú `xs`, `sm`, `md`, `lg`, `dark` a `light`. Použije sa hodnota, ktorá zodpovedá aktuálnemu displeju. Ak aktuálna veľkosť nemá hodnotu, použije sa najbližšia definovaná veľkosť.\n\nExample: Hodnota podľa veľkosti displeja\n```html\n<ui-component name=\"grid\" config=\"columns:@xs=1,@sm=2,@md=3,@lg=4\"></ui-component>\n\n<script>\n    COMPONENT('grid', function(self, config) {\n        console.log(WIDTH(), config.columns);  // xs 1\n    });\n</script>\n```\n\n### $id:identifier\n\nType: `config`\n\nNastaví identifikátor inštancie.\n\nIdentifikátor sa uloží do [`id`](../component/#id) a môžeš ho použiť v selektoroch, ako je `#users`.\n\nExample: Vyhľadanie inštancie podľa identifikátora\n```html\n<ui-component name=\"box\" config=\"$id:users\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(FIND('#users').name), 500);  // box\n</script>\n```\n\n### $type:type\n\nType: `config`\n\nNastaví dátový typ inštancie.\n\nTyp sa uloží do [`type`](../component/#type) a odovzdáva sa parserom a formátovačom.\n\nExample: Nastavenie typu\n```html\n<ui-component name=\"box\" config=\"$type:number\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = () => console.log(self.type);  // number\n    });\n</script>\n```\n\n### $class:classes\n\nType: `config`\n\nPrepína triedy CSS na elemente.\n\nExample: Pridanie triedy\n```html\n<ui-component name=\"box\" config=\"$class:highlighted\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### $assign:path\n\nType: `config`\n\nZapíše inštanciu na path.\n\nPri zničení inštancie sa path nastaví na `null`.\n\nExample: Uchovanie odkazu\n```html\n<ui-component name=\"box\" config=\"$assign:common.box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(() => console.log(GET('common.box').name), 500);  // box\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nZavolá funkciu, keď je inštancia pripravená.\n\nFunkcia dostane inštanciu a aj `this` je inštancia.\n\nExample: Inicializačná funkcia\n```html\n<ui-component name=\"box\" config=\"$init:common.onbox\"></ui-component>\n\n<script>\n    window.common = { onbox: instance => console.log('ready', instance.name) };  // ready box\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nZavolá funkciu vždy, keď inštancia dostane hodnotu.\n\nFunkcia dostane `value`, `path` a `type` a `this` je inštancia.\n\nExample: Sledovanie hodnôt\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$setter:common.onvalue\"></ui-component>\n\n<script>\n    window.common = { onvalue: value => value && console.log(value) };  // Peter\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### $state:path\n\nType: `config`\n\nZavolá funkciu pri každej zmene stavu inštancie.\n\nFunkcia dostane `type` a `what`, teda rovnaké argumenty ako delegate [`state`](../component/#state).\n\nExample: Sledovanie stavu\n```html\n<ui-component name=\"box\" config=\"$state:common.onstate\"></ui-component>\n\n<script>\n    window.common = { onstate: (type, what) => console.log(type, what) };  // 0 3\n    COMPONENT('box', function(self) {});\n</script>\n```\n\n### $noscope:true\n\nType: `config`\n\nPonechá path mimo najbližšieho `<ui-plugin>`.\n\nZnak `?` v path sa nenahrádza.\n\nExample: Ignorovanie scopu\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" config=\"$noscope:true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### $bindvisible:true\n\nType: `config`\n\nOdloží hodnoty, kým nebude element viditeľný.\n\nMá rovnaký účinok ako volanie [`bindvisible()`](../component/#bindvisible) v deklarácii.\n\nExample: Čakanie na viditeľný element\n```html\n<div id=\"tab\" style=\"display:none\">\n    <ui-component name=\"box\" path=\"form.name\" config=\"$bindvisible:true\"></ui-component>\n</div>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value) {\n            value && console.log('received', value);  // received Peter\n        };\n    });\n    SET('form.name', 'Peter');\n    setTimeout(() => $('#tab').show(), 500);\n</script>\n```\n\n### $url:url\n\nType: `config`\n\nImportuje komponent, keď nie je deklarovaný.\n\nURL sa odovzdá do `IMPORT()`. Spustí sa raz pre každú URL.\n\nExample: Import chýbajúceho komponentu\n```html\n<ui-component name=\"remote\" config=\"$url:/components/remote.html\"></ui-component>\n```\n\n### $realtime:false\n\nType: `config`\n\nUrčuje, kedy vstupné pole s `data-jc-bind` zapíše svoju hodnotu.\n\nPri `true` sa hodnota zapisuje počas písania používateľa. Pri `false` sa zapíše pri udalosti `change`.\n\nExample: Zápis pri zmene\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$realtime:false\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var input = $('input').val('Peter').trigger('input');\n        setTimeout(function() {\n            console.log(GET('form.name') || 'empty');  // empty\n            input.trigger('change');\n            console.log(GET('form.name'));  // Peter\n        }, 300);\n    }, 500);\n</script>\n```\n\n### $delay:milliseconds\n\nType: `config`\n\nNastaví oneskorenie väzby v reálnom čase v milisekundách.\n\nPredvolená hodnota je `DEF.delaykeypress`, čo je `200`.\n\nExample: Kratšie oneskorenie\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$delay:20\">\n    <input data-jc-bind />\n</ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        $('input').val('Peter').trigger('input');\n        setTimeout(() => console.log(GET('form.name')), 60);  // Peter\n    }, 500);\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nNastaví predvolenú hodnotu path.\n\nAtribút obsahuje výraz JavaScriptu. Hodnota sa zapíše, keď je path `undefined`, a [`default()`](../component/#default) ju obnoví.\n\nExample: Predvolená hodnota\n```html\n<ui-component name=\"box\" path=\"form.name\" default=\"'Anonymous'\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function() {};\n    });\n    setTimeout(() => console.log(GET('form.name')), 500);  // Anonymous\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nVytvorí scope priamo na elemente.\n\nHodnota je path scopu. Funguje to, ako keby si element obalil do [`ui-plugin`](../ui-plugin/).\n\nExample: Scope na elemente\n```html\n<ui-component name=\"box\" plugin=\"users\" path=\"?.name\"></ui-component>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // users.name\n    });\n</script>\n```\n\n### data-jc-path=\"path\"\n\nType: `property`\n\nNastaví path a má prednosť pred atribútom `path`.\n\nExample: Prepísanie path\n```html\n<ui-component name=\"box\" path=\"form.a\" data-jc-path=\"form.b\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // form.b\n    });\n</script>\n```\n\n### data-jc-config=\"key:value\"\n\nType: `property`\n\nNastaví konfiguráciu a má prednosť pred atribútom `config`.\n\nExample: Prepísanie konfigurácie\n```html\n<ui-component name=\"box\" config=\"title:A\" data-jc-config=\"title:B\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        console.log(config.title);  // B\n    });\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nPrepne triedy CSS, keď je inštancia pripravená.\n\nViacero tried oddeľ medzerou.\n\nExample: Trieda pridaná po inicializácii\n```html\n<ui-component name=\"box\" data-jc-class=\"ready\"></ui-component>\n<script>COMPONENT('box', function(self) {});</script>\n```\n\n### data-jc-noscope=\"true\"\n\nType: `property`\n\nPonechá path mimo najbližšieho `<ui-plugin>`.\n\nMá rovnaký účinok ako kľúč [`$noscope`](#x-noscope).\n\nExample: Ignorovanie scopu\n```html\n<ui-plugin path=\"users\">\n    <ui-component name=\"box\" path=\"?.name\" data-jc-noscope=\"true\"></ui-component>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', function(self) {\n        console.log(self.path);  // ?.name\n    });\n</script>\n```\n\n### element.get()\n\nType: `method`\n\nVráti hodnotu na naviazanej path.\n\nReturns: `Object` Hodnota na path.\n\nExample: Čítanie hodnoty\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.get());  // Peter\n```\n\n### element.set(value, [type])\n\nType: `method`\n\nZapíše hodnotu na naviazanú path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `type` | `Number` | no |  | Typ aktualizácie odovzdaný setteru. |\n\nInštancia sa označí ako upravená.\n\nExample: Zápis hodnoty\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.update([type])\n\nType: `method`\n\nUpozorní naviazanú path s jej aktuálnou hodnotou.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Typ aktualizácie odovzdaný setteru. |\n\nInštancia sa označí ako upravená.\n\nExample: Obnovenie po priamej zmene\n```js\nvar element = document.querySelector('ui-component');\nwindow.form.name = 'Anna';\nelement.update();\nsetTimeout(() => console.log(element.textContent), 50);  // Anna\n```\n\n### element.modify(value, [type])\n\nType: `method`\n\nZapíše hodnotu cez parsery inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `type` | `Number` | no | `2` | Typ aktualizácie. |\n\nVolá [`modify()`](../component/#modify) inštancie.\n\nExample: Zápis spracovanej hodnoty\n```js\nvar element = document.querySelector('ui-component');\nelement.modify('  Anna  ');\nconsole.log(GET('form.name'));  // Anna\n```\n\n### element.reconfigure([value], [init], [noemit])\n\nType: `method`\n\nZmení konfiguráciu inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | no |  | Nová konfigurácia. |\n| `init` | `Boolean` | no |  | Odovzdá `init` do delegate `configure`. |\n| `noemit` | `Boolean` | no |  | Preskočí delegate `configure`. |\n\nBez hodnoty metóda znova prečíta atribút `config`.\n\nExample: Zmena kľúča\n```js\nvar element = document.querySelector('ui-component');\nelement.reconfigure('title:Invoices');\nconsole.log(element.config.title);  // Invoices\n```\n\n### element.reset()\n\nType: `method`\n\nVymaže stav neplatnosti a úpravy inštancie.\n\nExample: Vymazanie stavu\n```js\nvar element = document.querySelector('ui-component');\nelement.set('Anna');\nelement.reset();\nconsole.log(element.config.modified);  // false\n```\n\n### element.config\n\nType: `property`\n\nKonfiguračný objekt inštancie.\n\nVlastnosť existuje po vytvorení inštancie.\n\nExample: Čítanie konfigurácie\n```js\nvar element = document.querySelector('ui-component');\nconsole.log(element.config.title);  // Orders\n```\n\n### element.setter = function(value, path, type)\n\nType: `delegate`\n\nFunkcia na elemente DOM, ktorá dostáva každú hodnotu.\n\nPriraď ju elementu. Spustí sa po delegate `setter` inštancie s rovnakými argumentmi.\n\nExample: Sledovanie hodnôt zvonka\n```js\nvar element = document.querySelector('ui-component');\nelement.setter = function(value, path, type) {\n    console.log(value, path, type);  // Anna form.name 1\n};\nSET('form.name', 'Anna');\n```\n\n### element.state = function(config)\n\nType: `delegate`\n\nFunkcia na elemente DOM, ktorá sa spustí pri zmene stavu.\n\nFunkcia dostane konfiguračný objekt inštancie.\n\nExample: Sledovanie stavu zvonka\n```js\nvar element = document.querySelector('ui-component');\nelement.state = function(config) {\n    console.log(config.touched);  // true\n};\nFIND('demo').bind('touched');\n```\n\n### element.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nFunkcia na elemente DOM, ktorá dostáva zmeny konfigurácie.\n\nFunkcia dostane rovnaké argumenty ako delegate [`configure`](../component/#configure).\n\nExample: Sledovanie konfigurácie\n```js\nvar element = document.querySelector('ui-component');\nelement.configure = function(key, value, init, prev) {\n    console.log(key, value, prev);  // title Invoices Orders\n};\nelement.reconfigure('title:Invoices');\n```\n\n### $(element).on('component', callback)\n\nType: `event`\n\nUdalosť jQuery vyvolaná na elemente, keď je inštancia pripravená.\n\nUdalosť sa vyvolá raz.\n\nExample: Čakanie na inštanciu\n```html\n<ui-component name=\"box\" id=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {});\n    $('#box').on('component', () => console.log('ready'));  // ready\n</script>\n```\n\n### .ui-modified\n\nType: `class`\n\nJe prítomná, kým je hodnota inštancie upravená.\n\nRiadi sa hodnotou `config.modified`.\n\nExample: Trieda modified\n```js\nvar com = FIND('demo');\ncom.bind('modified');\nconsole.log(com.element.hclass('ui-modified'));  // true\n```\n\n### .ui-touched\n\nType: `class`\n\nJe prítomná po tom, ako používateľ s inštanciou interagoval.\n\nRiadi sa hodnotou `config.touched`.\n\nExample: Trieda touched\n```js\nvar com = FIND('demo');\ncom.bind('touched');\nconsole.log(com.element.hclass('ui-touched'));  // true\n```\n\n### .ui-invalid\n\nType: `class`\n\nJe prítomná, kým je hodnota inštancie neplatná.\n\nRiadi sa hodnotou `config.invalid`, ktorú nastavuje delegate [`validate`](../component/#validate).\n\nExample: Trieda invalid\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.validate = value => !!value;\n    });\n</script>\n```\n\n### .ui-disabled\n\nType: `class`\n\nJe prítomná, kým je inštancia zakázaná.\n\nRiadi sa hodnotou `config.disabled`. Tento kľúč nastavuje príkaz [`disabled`](../ui-bind/#disabled) elementu `<ui-bind>`.\n\nExample: Trieda disabled\n```html\n<ui-bind path=\"form.locked\" config=\"disabled:value\">\n    <ui-component name=\"box\"></ui-component>\n</ui-bind>\n\n<script>\n    COMPONENT('box', function(self) {});\n    SET('form.locked', true);\n</script>\n```\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":"type","name":"Configuration from a path","signature":"config=\"=key:path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a path","signature":"config=\"=path\"","since":"","deprecated":false},{"type":"type","name":"Configuration object from a global variable","signature":"config=\"%variable\"","since":"","deprecated":false},{"type":"type","name":"Responsive configuration","signature":"config=\"key:@xs=value,@lg=value\"","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:identifier","since":"","deprecated":false},{"type":"config","name":"$type","signature":"$type:type","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:classes","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","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":"$state","signature":"$state:path","since":"","deprecated":false},{"type":"config","name":"$noscope","signature":"$noscope:true","since":"","deprecated":false},{"type":"config","name":"$bindvisible","signature":"$bindvisible:true","since":"","deprecated":false},{"type":"config","name":"$url","signature":"$url:url","since":"","deprecated":false},{"type":"config","name":"$realtime","signature":"$realtime:false","since":"","deprecated":false},{"type":"config","name":"$delay","signature":"$delay:milliseconds","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-path","signature":"data-jc-path=\"path\"","since":"","deprecated":false},{"type":"property","name":"data-jc-config","signature":"data-jc-config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-noscope","signature":"data-jc-noscope=\"true\"","since":"","deprecated":false},{"type":"method","name":"get()","signature":"element.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"element.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"element.update([type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"element.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"element.reconfigure([value], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"element.reset()","since":"","deprecated":false},{"type":"property","name":"element.config","signature":"element.config","since":"","deprecated":false},{"type":"delegate","name":"element.setter","signature":"element.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"element.state","signature":"element.state = function(config)","since":"","deprecated":false},{"type":"delegate","name":"element.configure","signature":"element.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"event","name":"component","signature":"$(element).on('component', callback)","since":"","deprecated":false},{"type":"class","name":"ui-modified","signature":".ui-modified","since":"","deprecated":false},{"type":"class","name":"ui-touched","signature":".ui-touched","since":"","deprecated":false},{"type":"class","name":"ui-invalid","signature":".ui-invalid","since":"","deprecated":false},{"type":"class","name":"ui-disabled","signature":".ui-disabled","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUh2gM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Component","summary":"The delegates, properties and methods of a component instance.","markdown":"---\ntitle: Component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Component\n\n> The delegates, properties and methods of a component instance.\n\nA component instance is the object passed to the declaration of `COMPONENT()`. It connects an element to a path of the data model. [Creating components](../../guides/creating-components/) explains how to write one, and [ui-component](../ui-component/) describes the element. In the examples, `com` is an instance found with `FIND()`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nBuilds the content of the component.\n\nThe delegate runs once, after the declaration, when the element is in the DOM.\n\nExample: Defining make\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.html('<b>Ready</b>');\n        };\n    });\n</script>\n```\n\n### self.init = function()\n\nType: `delegate`\n\nRuns once for all instances of the component.\n\nOnly the first instance of the page calls this delegate.\n\nExample: Defining init\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.init = () => console.log('once');  // once\n    });\n</script>\n```\n\n### self.done = function()\n\nType: `delegate`\n\nRuns after the instance has been initialized.\n\nThe delegate runs after the first `setter` and `state` calls.\n\nExample: Defining done\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.done = () => console.log('done');  // done\n    });\n</script>\n```\n\n### self.released = function(hidden)\n\nType: `delegate`\n\nTells whether the element is hidden when the instance starts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `hidden` | `Boolean` | yes |  | `true` when the element is hidden. |\n\nThe delegate runs once and receives `true` for a hidden element.\n\nExample: Defining released\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.released = hidden => console.log(hidden);  // false\n    });\n</script>\n```\n\n### self.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nReceives the configuration keys.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The name of the key. |\n| `value` | `Object` | yes |  | The new value. |\n| `init` | `Boolean` | yes |  | `true` during the initialization. |\n| `prev` | `Object` | yes |  | The previous value. |\n\nThe delegate runs for each key during the initialization, with `init` set to `true`, and again for each changed key. It also receives changes of the `modified`, `touched` and `invalid` keys.\n\nExample: Defining configure\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = function(key, value, init, prev) {\n            key === 'title' && console.log(value, init);  // Orders true\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nReceives the value of the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value of the path. |\n| `path` | `String` | yes |  | The path that changed. |\n| `type` | `Number` | yes |  | The source of the change. |\n\nDefine it to render the value. The default implementation writes the formatted value to nested `input`, `select` and `textarea` fields with the `data-jc-bind` attribute.\n\nThe `type` argument tells where the change comes from:\n\n| Type | Source |\n| --- | --- |\n| `0` | The initialization. |\n| `1` | A manual change, such as `SET()`. |\n| `2` | An input of the user. |\n| `3` | A default value or a reset. |\n\nExample: Defining setter\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value, path, type) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter(value, [realtime], [nobind])\n\nType: `delegate`\n\nWrites a value from the user to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The raw value. |\n| `realtime` | `Boolean` | no |  | `true` when the value comes while the user types. |\n| `nobind` | `Boolean` | no |  | `true` validates the value without writing it. |\n\nThe default implementation runs the parsers and writes the result. Nested fields with the `data-jc-bind` attribute call it automatically. Call it from your own controls to write a value.\n\nExample: Defining getter\n```html\n<ui-component name=\"box\" path=\"form.name\"><button>Set</button></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.event('click', 'button', () => self.getter('Peter'));\n        };\n    });\n    setTimeout(function() {\n        $('button').click();\n        console.log(GET('form.name'));  // Peter\n    }, 500);\n</script>\n```\n\n### self.setter2 = function(value, path, type)\n\nType: `delegate`\n\nRuns after the `setter` delegate.\n\nIt receives the same arguments. Use it to extend a component and keep its setter.\n\nExample: Defining setter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter2 = value => value && console.log(value);  // Peter\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter2 = function(value, realtime)\n\nType: `delegate`\n\nRuns when the `getter` receives a value.\n\nIt receives the parsed value and the `realtime` argument.\n\nExample: Defining getter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.getter2 = value => console.log(value);  // PETER\n        self.parser((path, value) => value.toUpperCase());\n    });\n    setTimeout(() => FIND('box').getter('peter'), 500);\n</script>\n```\n\n### self.state = function(type, what)\n\nType: `delegate`\n\nRuns when the state of the instance changes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | yes |  | The source of the change. |\n| `what` | `Number` | yes |  | The kind of the change. |\n\nThe `type` argument is `0` for the initialization, `1` for a manual change and `2` for an input of the user.\n\nThe `what` argument tells what happened:\n\n| What | Meaning |\n| --- | --- |\n| `1` | Validation. |\n| `2` | The touched state changed. |\n| `3` | A reset. |\n| `4` | An update. |\n| `5` | A new value. |\n| `6` | A notification. |\n\nExample: Defining state\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state = function(type, what) {\n            console.log(type, what);  // 0 3\n        };\n    });\n</script>\n```\n\n### self.state2 = function(type, what)\n\nType: `delegate`\n\nRuns after the `state` delegate.\n\nIt receives the same arguments.\n\nExample: Defining state2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state2 = (type, what) => console.log(type, what);  // 0 3\n    });\n</script>\n```\n\n### self.validate = function(value, init)\n\nType: `delegate`\n\nDecides whether the value is valid.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value of the path. |\n| `init` | `Boolean` | no |  | `true` during the initialization. |\n\nReturn `true` for a valid value. The result is stored in `config.invalid`.\n\nExample: Defining validate\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        self.validate = value => !!value;\n        self.done = () => console.log(config.invalid);  // true\n    });\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nRuns once per minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | The number of runs. |\n\nThe delegate receives a counter that grows by one on each run.\n\n### self.destroy = function()\n\nType: `delegate`\n\nRuns when the instance is removed.\n\nRelease timers and external listeners here.\n\nExample: Defining destroy\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => FIND('box').remove(), 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nThe name of the component, with its version.\n\nExample: Reading name\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.name));  // box@2\n</script>\n```\n\n### self.version\n\nType: `property`\n\nThe version from the name of the component.\n\nThe value is empty when the name has no version. The element also receives the `jc-v{version}` class.\n\nExample: Reading version\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.version));  // 2\n</script>\n```\n\n### self.id\n\nType: `property`\n\nThe identifier of the instance.\n\nThe [`$id`](../ui-component/#x-id) configuration key sets it. Otherwise it has the same value as `ID`.\n\nExample: Reading id\n```html\n<ui-component name=\"box\" config=\"$id:orders\"></ui-component>\n<script>\n    COMPONENT('box', self => self.make = () => console.log(self.id));  // orders\n</script>\n```\n\n### self.ID\n\nType: `property`\n\nThe unique generated identifier of the instance.\n\nExample: Reading ID\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.ID.substring(0, 2)));  // jc\n</script>\n```\n\n### self.path\n\nType: `property`\n\nThe path of the data model bound to the instance.\n\nThe value is empty when the component has no path.\n\nExample: Reading path\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.path));  // form.name\n</script>\n```\n\n### self.type\n\nType: `property`\n\nThe data type of the instance.\n\nThe value is passed to parsers and formatters. Set it in the declaration or with the [`$type`](../ui-component/#x-type) key.\n\nExample: Reading type\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.type = 'number';\n        self.parser((path, value, type) => console.log(type));  // number\n        self.make = () => self.parser('1');\n    });\n</script>\n```\n\n### self.format\n\nType: `property`\n\nThe format passed to parsers and formatters.\n\nWhen the property is empty, `config.format` is used.\n\nExample: Reading format\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.format = 'dd.MM.yyyy';\n        self.formatter((path, value, type, format) => console.log(format));  // dd.MM.yyyy\n        self.make = () => self.formatter('1');\n    });\n</script>\n```\n\n### self.trim\n\nType: `property`\n\nRemoves spaces around text in the parser.\n\nThe default value is `true`.\n\nExample: Reading trim\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.trim = false;\n        self.make = () => console.log(self.parser('  A  ').length);  // 5\n    });\n</script>\n```\n\n### self.config\n\nType: `property`\n\nThe configuration object.\n\nIt also holds the state keys `modified`, `touched`, `invalid` and, when set, `disabled`.\n\nExample: Reading config\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.config.title, self.config.touched));  // Orders false\n</script>\n```\n\n### self.element\n\nType: `property`\n\nThe element of the instance as a jQuery object.\n\nExample: Reading element\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.element.prop('tagName')));  // UI-COMPONENT\n</script>\n```\n\n### self.dom\n\nType: `property`\n\nThe element of the instance as a DOM node.\n\nExample: Reading dom\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.dom.tagName));  // UI-COMPONENT\n</script>\n```\n\n### self.owner\n\nType: `property`\n\nThe closest parent component.\n\nThe property is missing when the component has no parent component.\n\nExample: Reading owner\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', self => console.log(self.owner.name));  // parent\n</script>\n```\n\n### self.caller\n\nType: `property`\n\nThe component that called this instance through `exec()`.\n\nExample: Reading caller\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', function(self) {\n        self.ping = () => console.log(self.caller.name);  // parent\n    });\n    setTimeout(() => FIND('parent').exec('ping'), 500);\n</script>\n```\n\n### self.global\n\nType: `property`\n\nAn object shared by all instances of the component.\n\nExample: Reading global\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.global.count = (self.global.count || 0) + 1;\n    });\n    setTimeout(() => console.log(FIND('box').global.count), 500);  // 2\n</script>\n```\n\n### self.scope\n\nType: `property`\n\nThe [Scope](../scope/) of the instance.\n\nThe property exists when the path contains `?`.\n\nExample: Reading scope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.scope.path));  // users\n</script>\n```\n\n### self.pathscope\n\nType: `property`\n\nThe path of the scope of the instance.\n\nThe property exists when the path contains `?`.\n\nExample: Reading pathscope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.pathscope));  // users\n</script>\n```\n\n### self.plugin\n\nType: `property`\n\nThe [Plugin](../plugin/) of the scope of the instance.\n\nThe property exists when the path contains `?`.\n\nExample: Reading plugin\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.plugin.name));  // users\n</script>\n```\n\n### self.siblings\n\nType: `property`\n\nTells whether the element hosts several components.\n\nExample: Reading siblings\n```html\n<ui-component name=\"a,b\"></ui-component>\n<script>\n    COMPONENT('a', self => console.log(self.siblings));  // true\n    COMPONENT('b', function(self) {});\n</script>\n```\n\n### self.removed\n\nType: `property`\n\nTells whether the instance has been removed.\n\nExample: Reading removed\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var com = FIND('box');\n        com.remove();\n        console.log(com.removed);  // true\n    }, 500);\n</script>\n```\n\n### com.get([path])\n\nType: `method`\n\nReturns the value of the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Another path. |\n\nReturns: `Object` The value.\n\nWith an argument, the method reads another path.\n\nExample: Using get()\n```js\nvar com = FIND('demo');\nSET('form.name', 'Peter');\nconsole.log(com.get());  // Peter\n```\n\n### com.set(value, [type])\n\nType: `method`\n\nWrites a value to the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The new value. |\n| `type` | `Number` | no |  | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nThe instance is marked as modified.\n\nExample: Using set()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(GET('form.name'), com.config.modified);  // Peter true\n```\n\n### com.modify(value, [type])\n\nType: `method`\n\nWrites a value through the parsers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The raw value. |\n| `type` | `Number` | no | `2` | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nThe instance is marked as touched.\n\nExample: Using modify()\n```js\nvar com = FIND('demo');\ncom.modify('  Peter  ');\nconsole.log(GET('form.name'), com.config.touched);  // Peter true\n```\n\n### com.inc(value, [type])\n\nType: `method`\n\nIncreases the number stored in the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number` | yes |  | The increment. |\n| `type` | `Number` | no |  | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nExample: Using inc()\n```js\nvar com = FIND('demo');\ncom.set(5);\ncom.inc(2);\nconsole.log(GET('form.name'));  // 7\n```\n\n### com.extend(value, [type])\n\nType: `method`\n\nMerges an object into the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The fields to merge. |\n| `type` | `Number` | no |  | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nExample: Using extend()\n```js\nvar com = FIND('demo');\ncom.set({ a: 1 });\ncom.extend({ b: 2 });\nconsole.log(GET('form.name'));  // {\"a\":1,\"b\":2}\n```\n\n### com.push(value, [type])\n\nType: `method`\n\nAdds an item to the array stored in the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The item. |\n| `type` | `Number` | no |  | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nExample: Using push()\n```js\nvar com = FIND('demo');\ncom.push('A');\ncom.push('B');\nconsole.log(GET('form.name'));  // [\"A\",\"B\"]\n```\n\n### com.rewrite(value, [type])\n\nType: `method`\n\nWrites a value without notifying anyone.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The new value. |\n| `type` | `Number` | no |  | The type of the change. |\n\nReturns: `Component` The instance.\n\nBound components, binders and watchers are not called.\n\nExample: Using rewrite()\n```js\nvar com = FIND('demo');\ncom.rewrite('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### com.update([type])\n\nType: `method`\n\nWrites the current value again.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nAll listeners of the path are notified.\n\nExample: Using update()\n```js\nvar com = FIND('demo');\ncom.watch(function(path, value) {\n    console.log(value);  // Peter\n});\nwindow.form.name = 'Peter';\ncom.update();\n```\n\n### com.refresh([notify], [type])\n\nType: `method`\n\nCalls the setter of this instance with the current value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `notify` | `Boolean` | no |  | `true` notifies all listeners. |\n| `type` | `Number|String` | no |  | The type passed to the setter. |\n\nReturns: `Component` The instance.\n\nWith `notify`, the value is written to the path and all listeners are notified.\n\nExample: Using refresh()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.refresh();\nconsole.log(com.text());  // Peter\n```\n\n### com.notify()\n\nType: `method`\n\nNotifies the listeners of the exact bound path.\n\nReturns: `Component` The instance.\n\nThe method calls `NOTIFY()` with the path of the instance.\n\nExample: Using notify()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.notify();\nconsole.log(com.text());  // Peter\n```\n\n### com.skip()\n\nType: `method`\n\nSkips the next call of the setter.\n\nReturns: `Component` The instance.\n\nExample: Using skip()\n```js\nvar com = FIND('demo');\ncom.skip();\ncom.set('Peter');\nsetTimeout(() => console.log(com.text() || 'empty'), 500);  // empty\n```\n\n### com.bind(flags, [value])\n\nType: `method`\n\nChanges the state and optionally writes a value.\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` argument is a list of words separated by a space, a comma or `|`. An optional `@` prefix is ignored.\n\n| Flag | Effect |\n| --- | --- |\n| `touched`, `touch` | Marks the instance as touched. |\n| `modified`, `modify`, `changed`, `change` | Marks the instance as modified. |\n| `reset` | Clears the touched and modified state. |\n| `validate` | Validates the value. |\n| `setter` | Calls the setter. |\n\nWhen `value` is passed, it is written to the path, and the setter of this instance runs only with the `setter` flag.\n\nExample: Using bind()\n```js\nvar com = FIND('demo');\ncom.bind('@touched @modified', 'Peter');\nconsole.log(GET('form.name'), com.config.touched, com.config.modified);  // Peter true true\n```\n\n### com.reset()\n\nType: `method`\n\nClears the touched and modified state.\n\nReturns: `Component` The instance.\n\nThe value is validated again.\n\nExample: Using reset()\n```js\nvar com = FIND('demo');\ncom.modify('Peter');\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### com.default([reset])\n\nType: `method`\n\nRestores the default value of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `reset` | `Boolean` | no | `true` | `false` keeps the state of the instance. |\n\nReturns: `Component` The instance.\n\nThe default value comes from the [`default`](../ui-component/#default) attribute.\n\nExample: Using default()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\ncom.default();\nconsole.log(GET('form.name'));  // Anonymous\n```\n\n### com.change([value])\n\nType: `method`\n\nSets the touched and modified state of components on the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no | `true` | The new state. |\n\nReturns: `Component` The instance.\n\nThe method applies to all components bound to the path and its nested paths. The method is also available as `touched()`.\n\nExample: Using change()\n```js\nvar com = FIND('demo');\ncom.change();\nconsole.log(com.config.touched, com.config.modified);  // true true\n```\n\n### com.dirty([value], [noemit])\n\nType: `method`\n\nReads or sets the untouched state.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no |  | `false` marks the instance as touched. |\n| `noemit` | `Boolean` | no |  | `true` skips the `state` delegate. |\n\nReturns: `Boolean|Component` The state, or the instance when `value` is passed.\n\nWithout arguments, the method returns `true` for an untouched instance.\n\nExample: Using dirty()\n```js\nvar com = FIND('demo');\nconsole.log(com.dirty());  // true\ncom.dirty(false);\nconsole.log(com.config.touched);  // true\n```\n\n### com.isInvalid()\n\nType: `method`\n\nTells whether the instance is touched and invalid.\n\nReturns: `Boolean` The result.\n\nExample: Using isInvalid()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\ncom.modify('');\ncom.validate2();\ncom.bind('touched');\nconsole.log(com.isInvalid());  // true\n```\n\n### com.validate2()\n\nType: `method`\n\nRuns the `validate` delegate and updates the state.\n\nReturns: `Boolean` `true` for a valid value.\n\nExample: Using validate2()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\nconsole.log(com.validate2());  // false\n```\n\n### com.notmodified([fields])\n\nType: `method`\n\nTells whether the value is the same as at the last check.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fields` | `String|Array` | no |  | The fields to compare. |\n\nReturns: `Boolean` `true` when the value has not changed.\n\nThe first check returns `false`.\n\nExample: Using notmodified()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(com.notmodified());  // false\nconsole.log(com.notmodified());  // true\n```\n\n### com.parser(value, [prepend])\n\nType: `method`\n\nAdds a parser, or parses a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | A parser or the value to parse. |\n| `prepend` | `Boolean` | no |  | `true` adds the parser to the beginning. |\n\nReturns: `Object` The parsed value, or the instance when a parser is added.\n\nA function is added to the parsers of the instance. It receives `path`, `value`, `type` and `format`, and returns the new value. Any other argument is parsed and returned.\n\nExample: Using parser()\n```js\nvar com = FIND('demo');\ncom.parser((path, value) => value.toUpperCase());\nconsole.log(com.parser('peter'));  // PETER\n```\n\n### com.formatter(value, [prepend])\n\nType: `method`\n\nAdds a formatter, or formats a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | A formatter or the value to format. |\n| `prepend` | `Boolean` | no |  | `true` adds the formatter to the beginning. |\n\nReturns: `Object` The formatted value, or the instance when a formatter is added.\n\nA function is added to the formatters of the instance. It receives `path`, `value`, `type` and `format`, and returns the new value. Any other argument is formatted and returned.\n\nExample: Using formatter()\n```js\nvar com = FIND('demo');\ncom.formatter((path, value) => value + '!');\nconsole.log(com.formatter('Peter'));  // Peter!\n```\n\n### com.parsesource(value)\n\nType: `method`\n\nConverts a text list to an array of items.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The list. |\n\nReturns: `Array` Objects with `id`, `name` and `icon`.\n\nItems are separated by a comma. Each item has the form `id|name|icon`. When the instance has the `number` type, the identifiers are converted to numbers.\n\nExample: Using parsesource()\n```js\nvar com = FIND('demo');\nconsole.log(com.parsesource('1|One,2|Two|home')[1]);  // {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n\n### com.reconfigure(value, [callback], [init], [noemit])\n\nType: `method`\n\nChanges the configuration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | The configuration. |\n| `callback` | `Function` | no |  | Receives `key`, `value`, `init` and `prev` instead of the `configure` delegate. |\n| `init` | `Boolean` | no |  | The `init` argument of the delegate. |\n| `noemit` | `Boolean` | no |  | `true` skips the delegate. |\n\nReturns: `Component` The instance.\n\nThe value can be a string of `key:value` pairs, an object, or `=path` to read an object from a path. The `configure` delegate receives each key.\n\nExample: Using reconfigure()\n```js\nvar com = FIND('demo');\ncom.reconfigure('title:Orders;limit:10');\nconsole.log(com.config.title, com.config.limit);  // Orders 10\n```\n\n### com.configdisplay(key, value)\n\nType: `method`\n\nResolves a value that depends on the display.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The name of the key. |\n| `value` | `Object` | yes |  | The value. |\n\nReturns: `Object` The resolved value.\n\nThe value has the form `@xs=1,@md=2`. Other values are returned unchanged. See [Responsive configuration](../ui-component/#responsive-configuration).\n\nExample: Using configdisplay()\n```js\nvar com = FIND('demo');\nconsole.log(com.configdisplay('size', '@xs=1,@lg=4'), WIDTH());  // 1 xs\n```\n\n### com.data(key, [value])\n\nType: `method`\n\nReads or writes data of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The name of the key. |\n| `value` | `Object` | no |  | The value to write. |\n\nReturns: `Object` The value.\n\nNested elements read the keys with the `@key` path. An empty key is the current value of the instance.\n\nExample: Using data()\n```js\nvar com = FIND('demo');\ncom.data('title', 'Orders');\nconsole.log(com.data('title'));  // Orders\n```\n\n### com.datasource(path, callback, [init])\n\nType: `method`\n\nWatches a path that holds a data source.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the data source. |\n| `callback` | `Function` | yes |  | The function that receives the data. |\n| `init` | `Boolean` | no | `true` | `false` skips the initial call. |\n\nReturns: `Component` The instance.\n\nThe callback receives `path`, `value` and `type`. Unless `init` is `false`, it also runs after the configuration is loaded. A new call replaces the previous data source.\n\nExample: Using datasource()\n```js\nvar com = FIND('demo');\ncom.datasource('common.items', function(path, value) {\n    console.log(value);  // [1,2]\n}, false);\nSET('common.items', [1, 2]);\n```\n\n### com.watch([path], callback, [init])\n\nType: `method`\n\nWatches a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The path to watch. |\n| `callback` | `Function` | yes |  | The function that receives the changes. |\n| `init` | `Boolean` | no |  | `true` calls the callback immediately. |\n\nReturns: `Component` The instance.\n\nThe callback receives `path`, `value` and `type`, and `this` is the instance. Without a path, the method watches the path of the instance. The watcher is removed together with the instance.\n\nExample: Using watch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', function(path, value) {\n    console.log(path, value);  // form.age 30\n});\nSET('form.age', 30);\n```\n\n### com.unwatch(path)\n\nType: `method`\n\nRemoves the watchers of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The watched path. |\n\nReturns: `Component` The instance.\n\nThe method removes all watchers that this instance has on the path.\n\nExample: Using unwatch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', () => console.log('called'));\ncom.unwatch('form.age');\nSET('form.age', 30);\nconsole.log('end');  // end\n```\n\n### com.on(name, callback)\n\nType: `method`\n\nListens for a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | yes |  | The listener. |\n\nReturns: `Component` The instance.\n\nThe listener is removed together with the instance. A `^` prefix of the name puts the listener first.\n\nExample: Using on()\n```js\nvar com = FIND('demo');\ncom.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### com.off(name, [callback])\n\nType: `method`\n\nRemoves a listener of a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | no |  | The listener. |\n\nReturns: `Component` The instance.\n\nWithout a callback, all listeners of the event in this instance are removed.\n\nExample: Using off()\n```js\nvar com = FIND('demo');\nvar fn = () => console.log('called');\ncom.on('saved', fn);\ncom.off('saved', fn);\nconsole.log(EMIT('saved'));  // false\n```\n\n### com.emit(name, [...args])\n\nType: `method`\n\nEmits a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `args` | `Object` | no |  | The arguments of the event. |\n\nReturns: `Component` The instance.\n\nThe method calls `EMIT()`.\n\nExample: Using emit()\n```js\nvar com = FIND('demo');\nON('saved', value => console.log(value));  // 5\ncom.emit('saved', 5);\n```\n\n### com.command(name, callback)\n\nType: `method`\n\nRegisters a command of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the command. |\n| `callback` | `Function` | yes |  | The handler. |\n\nReturns: `Component` The instance.\n\nA `^` prefix of the name puts the handler first. Commands are called by [`CMD()`](#cmd) or by the global `CMD()`.\n\nExample: Using command()\n```js\nvar com = FIND('demo');\ncom.command('clear', () => console.log('cleared'));  // cleared\nCMD('clear');\n```\n\n### com.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nCalls a command of this instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the command. |\n\nReturns: `Component` The instance.\n\nThe method accepts up to five arguments.\n\nExample: Using CMD()\n```js\nvar com = FIND('demo');\ncom.command('add', (a, b) => console.log(a + b));  // 3\ncom.CMD('add', 1, 2);\n```\n\n### com.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nCalls a method of all nested components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the method. |\n\nReturns: `Component` The instance.\n\nEach nested component receives this instance in `caller`.\n\nExample: Using exec()\n```js\nvar com = FIND('demo');\ncom.exec('ping', 5);\n```\n\n### com.GET(path)\n\nType: `method`\n\nReads a path relative to the scope of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `Object` The value.\n\nThe `?` character is replaced with the path of the scope.\n\nExample: Using GET()\n```js\nvar com = FIND('demo');\nSET('users.name', 'Peter');\nconsole.log(com.GET('?.name'));  // Peter\n```\n\n### com.SET(path, value)\n\nType: `method`\n\nWrites a path relative to the scope of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Object` | yes |  | The value. |\n\nThe `?` character is replaced with the path of the scope.\n\nExample: Using SET()\n```js\nvar com = FIND('demo');\ncom.SET('?.age', 30);\nconsole.log(GET('users.age'));  // 30\n```\n\n### com.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function by its path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the function. |\n\nReturns: `Component` The instance.\n\nThe `?` character is replaced with the path of the scope. A path with the `@` prefix calls a method of the parent component.\n\nExample: Using EXEC()\n```js\nvar com = FIND('child');\ncom.EXEC('@ping', 5);\n```\n\n### com.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function or writes a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `Component` The instance.\n\nThe method calls the function on the path. When the path holds no function, the first argument is written to it. The `@` prefix works with the parent component.\n\nExample: Using SEEX()\n```js\nvar com = FIND('child');\ncom.SEEX('@title', 'Orders');\nconsole.log(FIND('demo').title);  // Orders\n```\n\n### com.makepath(path)\n\nType: `method`\n\nResolves a path in the scope of the instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `String` The resolved path.\n\nExample: Using makepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.makepath('?.age'));  // users.age\n```\n\n### com.scopepath(path)\n\nType: `method`\n\nReplaces `?` in a path with the path of the scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `String` The resolved path.\n\nA path without `?` is returned unchanged.\n\nExample: Using scopepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.scopepath('?.age'), com.scopepath('form.age'));  // users.age form.age\n```\n\n### com.setPath(path)\n\nType: `method`\n\nChanges the bound path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The new path. |\n\nReturns: `Component` The instance.\n\nExample: Using setPath()\n```js\nvar com = FIND('demo');\ncom.setPath('form.other');\nSET('form.other', 5);\nconsole.log(com.path, com.get());  // form.other 5\n```\n\n### com.blind()\n\nType: `method`\n\nDisconnects the instance from its path.\n\nReturns: `Component` The instance.\n\nExample: Using blind()\n```js\nvar com = FIND('demo');\ncom.blind();\nSET('form.name', 'Peter');\nconsole.log(com.path, com.text() || 'empty');  // null empty\n```\n\n### self.readonly()\n\nType: `method`\n\nRemoves the `setter`, `getter` and `validate` delegates.\n\nReturns: `Component` The instance.\n\nUse it in components that only display content.\n\nExample: Using readonly()\n```js\nvar com = FIND('demo');\nconsole.log(com.setter, com.getter);  // null null\n```\n\n### self.singleton()\n\nType: `method`\n\nAllows only one instance of the component in the page.\n\nReturns: `Component` The instance.\n\nOther elements of the same component are removed.\n\nExample: Using singleton()\n```js\nconsole.log(FIND('demo', true).length, $('ui-component').length);  // 1 1\n```\n\n### self.bindchanges([enable])\n\nType: `method`\n\nSkips the setter when the value has not changed.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` turns the feature off. |\n\nReturns: `Component` The instance.\n\nExample: Using bindchanges()\n```js\nSET('form.name', 'A');\nSET('form.name', 'A');\nsetTimeout(() => console.log(window.calls), 500);  // 2\n```\n\n### self.bindexact([enable])\n\nType: `method`\n\nIgnores changes of nested paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` turns the feature off. |\n\nReturns: `Component` The instance.\n\nThe setter runs only for the exact path or its parents.\n\nExample: Using bindexact()\n```js\nSET('form.user.name', 'Peter');\nsetTimeout(() => console.log(window.calls), 500);  // 1\n```\n\n### self.bindvisible([timeout])\n\nType: `method`\n\nDelays the setter until the element is visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `timeout` | `Number|Boolean` | no | `DEF.delaybinder` | The delay in milliseconds after the element becomes visible. `false` turns the feature off. |\n\nReturns: `Component` The instance.\n\nExample: Using bindvisible()\n```js\nSET('form.name', 'Peter');\nsetTimeout(() => $('#tab').show(), 500);\nsetTimeout(() => console.log($('ui-component').text()), 1500);  // Peter\n```\n\n### self.autofill([enable])\n\nType: `method`\n\nReads values filled in by the browser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` turns the feature off. |\n\nReturns: `Component` The instance.\n\nAfter the page is ready, the value of nested fields with the `data-jc-bind` attribute is written to the path.\n\nExample: Using autofill()\n```js\n$('input').val('Peter');\nsetTimeout(() => console.log(GET('form.name')), 1400);  // Peter\n```\n\n### com.caniuse(name)\n\nType: `method`\n\nTells whether a component is available.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the component. |\n\nReturns: `Number` `1` for a declared component, `2` for a lazy one, `undefined` for an unknown one.\n\nExample: Using caniuse()\n```js\nvar com = FIND('demo');\nconsole.log(com.caniuse('demo'));  // 1\n```\n\n### com.main()\n\nType: `method`\n\nReturns the closest parent component.\n\nReturns: `Component` The parent component or `null`.\n\nExample: Using main()\n```js\nvar com = FIND('child');\nconsole.log(com.main().name);  // demo\n```\n\n### com.compile([container])\n\nType: `method`\n\nCompiles new content of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `jQuery|Element` | no | `the component element` | The element to compile. |\n\nReturns: `Component` The instance.\n\nCall it after you add elements with bindings or components.\n\nExample: Using compile()\n```js\nvar com = FIND('demo');\ncom.append('<div data-bind=\"form.name__text\"></div>');\ncom.compile();\nSET('form.name', 'Peter');\nsetTimeout(() => console.log(com.find('div').text()), 500);  // Peter\n```\n\n### com.import(url, [callback], [insert], [preparator])\n\nType: `method`\n\nImports content into the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL. |\n| `callback` | `Function` | no |  | Runs after the import. |\n| `insert` | `Boolean` | no |  | The `insert` argument of `IMPORT()`. |\n| `preparator` | `Function` | no |  | Changes the response before the insertion. |\n\nReturns: `Component` The instance.\n\nThe method calls `IMPORT()` with the element as the target.\n\nExample: Using import()\n```js\nvar com = FIND('demo');\ncom.import('/part.html', () => console.log('imported'));  // imported\n```\n\n### com.replace(element, [remove])\n\nType: `method`\n\nMoves the instance to another element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | The new element. |\n| `remove` | `Boolean` | no |  | `true` removes the original element. |\n\nReturns: `Component` The instance.\n\nExample: Using replace()\n```js\nvar com = FIND('demo');\ncom.replace($('#target'), true);\nconsole.log(com.dom.id, $('ui-component').length);  // target 0\n```\n\n### com.remove([noclear])\n\nType: `method`\n\nRemoves the instance and its element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noclear` | `Boolean` | no |  | `true` does not start the cleanup immediately. |\n\nReturns: `Boolean` Always `true`.\n\nThe `destroy` delegate runs during the cleanup. The method is also available as `kill()`.\n\nExample: Using remove()\n```js\nvar com = FIND('demo');\nconsole.log(com.remove());  // true\n```\n\n### com.find(selector)\n\nType: `method`\n\nFinds nested elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | A selector or an object of selectors. |\n\nReturns: `jQuery|Object` The result.\n\nAn object of selectors returns an object of jQuery results with the same keys.\n\nExample: Using find()\n```js\nvar com = FIND('demo');\nconsole.log(com.find('.label').text());  // Text\n```\n\n### com.closest(selector)\n\nType: `method`\n\nFinds the closest matching parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector. |\n\nReturns: `jQuery` The result.\n\nExample: Using closest()\n```js\nvar com = FIND('demo');\nconsole.log(com.closest('body').length);  // 1\n```\n\n### com.parent([selector])\n\nType: `method`\n\nReturns a parent element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | The selector. |\n\nReturns: `jQuery` The result.\n\nThe argument can be:\n\n| Value | Result |\n| --- | --- |\n| omitted | The direct parent. |\n| A selector | The closest matching element. |\n| `auto` | The closest parent with a defined height, otherwise `window`. |\n| `window` | `window` as a jQuery object. |\n| `document` | The `document` object. |\n| `parent` | The direct parent. |\n| `parent2` | The element two levels above the direct parent. |\n\nExample: Using parent()\n```js\nvar com = FIND('demo');\nconsole.log(com.parent().prop('tagName'));  // BODY\n```\n\n### com.html([value])\n\nType: `method`\n\nReads or replaces the HTML content.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | The new content. |\n\nReturns: `String|jQuery` The content, or the element when `value` is passed.\n\nAn array is joined.\n\nExample: Using html()\n```js\nvar com = FIND('demo');\ncom.html('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.text([value])\n\nType: `method`\n\nReads or replaces the text content.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | The new content. |\n\nReturns: `String|jQuery` The content, or the element when `value` is passed.\n\nAn array is joined.\n\nExample: Using text()\n```js\nvar com = FIND('demo');\ncom.text('<b>A</b>');\nconsole.log(com.html());  // &lt;b&gt;A&lt;/b&gt;\n```\n\n### com.append(value)\n\nType: `method`\n\nAdds content to the end of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | The content. |\n\nReturns: `jQuery` The element.\n\nAn array is joined.\n\nExample: Using append()\n```js\nvar com = FIND('demo');\ncom.empty();\ncom.append('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.empty()\n\nType: `method`\n\nRemoves the content of the element.\n\nReturns: `jQuery` The element.\n\nNested components are removed too.\n\nExample: Using empty()\n```js\nvar com = FIND('demo');\ncom.empty();\nconsole.log(com.html() === '');  // true\n```\n\n### com.event(name, [selector], callback)\n\nType: `method`\n\nAttaches a jQuery event to the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `selector` | `String` | no |  | The delegated selector. |\n| `callback` | `Function` | yes |  | The handler. |\n\nReturns: `Component` The instance.\n\nThe arguments are the same as in the jQuery `on()` method.\n\nExample: Using event()\n```js\nvar com = FIND('demo');\ncom.event('click', '.label', () => console.log('clicked'));  // clicked\ncom.find('.label').click();\n```\n\n### com.aclass(classes, [timeout])\n\nType: `method`\n\nAdds CSS classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | The classes. |\n| `timeout` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `Component` The instance.\n\nExample: Using aclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.rclass([classes], [timeout])\n\nType: `method`\n\nRemoves CSS classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | The classes. |\n| `timeout` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `Component` The instance.\n\nWithout an argument, all classes are removed.\n\nExample: Using rclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\ncom.rclass('active');\nconsole.log(com.hclass('active'));  // false\n```\n\n### com.rclass2(search)\n\nType: `method`\n\nRemoves CSS classes that contain a text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | The text or a regular expression. |\n\nReturns: `Component` The instance.\n\nExample: Using rclass2()\n```js\nvar com = FIND('demo');\ncom.aclass('col-1 col-2');\ncom.rclass2('col-');\nconsole.log(com.hclass('col-1'));  // false\n```\n\n### com.tclass(classes, [state])\n\nType: `method`\n\nToggles CSS classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | The classes. |\n| `state` | `Boolean` | no |  | Forces the state. |\n\nReturns: `Component` The instance.\n\nExample: Using tclass()\n```js\nvar com = FIND('demo');\ncom.tclass('active', true);\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.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` The result.\n\nExample: Using hclass()\n```js\nvar com = FIND('demo');\nconsole.log(com.hclass('missing'));  // false\n```\n\n### com.attr(name, [value])\n\nType: `method`\n\nReads or writes an attribute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String|Component` The value, or the instance when `value` is passed.\n\nExample: Using attr()\n```js\nvar com = FIND('demo');\ncom.attr('title', 'Orders');\nconsole.log(com.attr('title'));  // Orders\n```\n\n### com.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 name without the `data-` prefix. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String|Component` The value, or the instance when `value` is passed.\n\nExample: Using attrd()\n```js\nvar com = FIND('demo');\ncom.attrd('id', '5');\nconsole.log(com.attr('data-id'));  // 5\n```\n\n### com.attrd2(name)\n\nType: `method`\n\nReads a `data-` attribute from the element or its closest parent that has it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name without the `data-` prefix. |\n\nReturns: `String` The value.\n\nExample: Using attrd2()\n```js\nvar com = FIND('demo');\nconsole.log(com.attrd2('group'));  // main\n```\n\n### com.css(name, [value])\n\nType: `method`\n\nReads or writes a CSS property.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The property. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String|Component` The value, or the instance when `value` is passed.\n\nExample: Using css()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\nconsole.log(com.css('display'));  // block\n```\n\n### com.visible([callback])\n\nType: `method`\n\nTells whether the element is visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Runs when the element is visible. |\n\nReturns: `Boolean` The current visibility.\n\nWith a callback, the function runs as soon as the element is visible.\n\nExample: Using visible()\n```js\nvar com = FIND('demo');\nconsole.log(com.visible());  // true\n```\n\n### com.width([callback])\n\nType: `method`\n\nReturns the width of the element in pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Receives the width. |\n\nReturns: `Number` The width.\n\nWith a callback, the function runs as soon as the width is greater than zero.\n\nExample: Using width()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('width', '200px');\nconsole.log(com.width());  // 200\n```\n\n### com.height([callback])\n\nType: `method`\n\nReturns the height of the element in pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Receives the height. |\n\nReturns: `Number` The height.\n\nWith a callback, the function runs as soon as the height is greater than zero.\n\nExample: Using height()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('height', '50px');\nconsole.log(com.height());  // 50\n```\n\n### com.autofocus([selector])\n\nType: `method`\n\nMoves the focus to the first visible field.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | The fields. |\n\nReturns: `Component` The instance.\n\nThe method tries again for a short time when no field can receive the focus. It does nothing on mobile devices.\n\nExample: Using autofocus()\n```js\nvar com = FIND('demo');\ncom.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### com.faicon(value)\n\nType: `method`\n\nCompletes the name of an icon.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The name of the icon. |\n\nReturns: `String` The CSS classes.\n\nA name without a space receives `DEF.iconprefix`, which is `ti ti-`. The method is also available as `icon()`.\n\nExample: Using faicon()\n```js\nvar com = FIND('demo');\nconsole.log(com.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"init","signature":"self.init = function()","since":"","deprecated":false},{"type":"delegate","name":"done","signature":"self.done = function()","since":"","deprecated":false},{"type":"delegate","name":"released","signature":"self.released = function(hidden)","since":"","deprecated":false},{"type":"delegate","name":"configure","signature":"self.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter","signature":"self.getter(value, [realtime], [nobind])","since":"","deprecated":false},{"type":"delegate","name":"setter2","signature":"self.setter2 = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter2","signature":"self.getter2 = function(value, realtime)","since":"","deprecated":false},{"type":"delegate","name":"state","signature":"self.state = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"state2","signature":"self.state2 = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"validate","signature":"self.validate = function(value, init)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"version","signature":"self.version","since":"","deprecated":false},{"type":"property","name":"id","signature":"self.id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"self.ID","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"type","signature":"self.type","since":"","deprecated":false},{"type":"property","name":"format","signature":"self.format","since":"","deprecated":false},{"type":"property","name":"trim","signature":"self.trim","since":"","deprecated":false},{"type":"property","name":"config","signature":"self.config","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"owner","signature":"self.owner","since":"","deprecated":false},{"type":"property","name":"caller","signature":"self.caller","since":"","deprecated":false},{"type":"property","name":"global","signature":"self.global","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"property","name":"pathscope","signature":"self.pathscope","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"self.plugin","since":"","deprecated":false},{"type":"property","name":"siblings","signature":"self.siblings","since":"","deprecated":false},{"type":"property","name":"removed","signature":"self.removed","since":"","deprecated":false},{"type":"method","name":"get()","signature":"com.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"com.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"com.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"com.inc(value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"com.extend(value, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"com.push(value, [type])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"com.rewrite(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"com.update([type])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"com.refresh([notify], [type])","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"com.notify()","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"com.skip()","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"com.bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"com.reset()","since":"","deprecated":false},{"type":"method","name":"default()","signature":"com.default([reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"com.change([value])","since":"","deprecated":false},{"type":"method","name":"dirty()","signature":"com.dirty([value], [noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"com.isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"com.validate2()","since":"","deprecated":false},{"type":"method","name":"notmodified()","signature":"com.notmodified([fields])","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"com.parser(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"com.formatter(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"parsesource()","signature":"com.parsesource(value)","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"com.reconfigure(value, [callback], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"configdisplay()","signature":"com.configdisplay(key, value)","since":"","deprecated":false},{"type":"method","name":"data()","signature":"com.data(key, [value])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"com.datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"com.watch([path], callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"com.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"on()","signature":"com.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"com.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"com.emit(name, [...args])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"com.command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"com.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"com.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"com.GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"com.SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"com.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"com.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"com.makepath(path)","since":"","deprecated":false},{"type":"method","name":"scopepath()","signature":"com.scopepath(path)","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"com.setPath(path)","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"com.blind()","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"self.readonly()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"self.singleton()","since":"","deprecated":false},{"type":"method","name":"bindchanges()","signature":"self.bindchanges([enable])","since":"","deprecated":false},{"type":"method","name":"bindexact()","signature":"self.bindexact([enable])","since":"","deprecated":false},{"type":"method","name":"bindvisible()","signature":"self.bindvisible([timeout])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"self.autofill([enable])","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"com.caniuse(name)","since":"","deprecated":false},{"type":"method","name":"main()","signature":"com.main()","since":"","deprecated":false},{"type":"method","name":"compile()","signature":"com.compile([container])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"com.import(url, [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"com.replace(element, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"com.remove([noclear])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"com.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"com.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"com.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"com.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"com.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"com.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"com.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"com.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"com.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"com.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"com.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"com.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"com.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"com.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"com.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"com.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"com.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"com.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"com.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"com.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"com.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"com.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUh2gM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Komponente","summary":"Die Delegates, Eigenschaften und Methoden einer Komponenteninstanz.","markdown":"---\ntitle: Komponente\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Komponente\n\n> Die Delegates, Eigenschaften und Methoden einer Komponenteninstanz.\n\nEine Komponenteninstanz ist das Objekt, das an die Deklaration von `COMPONENT()` übergeben wird. Die Instanz verbindet ein Element mit einem Path des Datenmodells. [Komponenten erstellen](../../guides/creating-components/) erklärt, wie du eine schreibst, und [ui-component](../ui-component/) beschreibt das Element. In den Beispielen ist `com` eine mit `FIND()` gefundene Instanz.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nBaut den Inhalt der Komponente auf.\n\nDer Delegate läuft einmal nach der Deklaration, wenn sich das Element im DOM befindet.\n\nExample: make definieren\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.html('<b>Ready</b>');\n        };\n    });\n</script>\n```\n\n### self.init = function()\n\nType: `delegate`\n\nLäuft einmal für alle Instanzen der Komponente.\n\nNur die erste Instanz auf der Seite ruft diesen Delegate auf.\n\nExample: init definieren\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.init = () => console.log('once');  // once\n    });\n</script>\n```\n\n### self.done = function()\n\nType: `delegate`\n\nLäuft, nachdem die Instanz initialisiert wurde.\n\nDer Delegate läuft nach den ersten Aufrufen von `setter` und `state`.\n\nExample: done definieren\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.done = () => console.log('done');  // done\n    });\n</script>\n```\n\n### self.released = function(hidden)\n\nType: `delegate`\n\nGibt an, ob das Element beim Start der Instanz ausgeblendet ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `hidden` | `Boolean` | yes |  | `true`, wenn das Element ausgeblendet ist. |\n\nDer Delegate läuft einmal und erhält bei einem ausgeblendeten Element `true`.\n\nExample: released definieren\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.released = hidden => console.log(hidden);  // false\n    });\n</script>\n```\n\n### self.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nErhält die Konfigurationsschlüssel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Name des Schlüssels. |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `init` | `Boolean` | yes |  | `true` während der Initialisierung. |\n| `prev` | `Object` | yes |  | Der vorherige Wert. |\n\nDer Delegate läuft während der Initialisierung für jeden Schlüssel, wobei `init` auf `true` gesetzt ist, und danach erneut für jeden geänderten Schlüssel. Er erhält auch Änderungen der Schlüssel `modified`, `touched` und `invalid`.\n\nExample: configure definieren\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = function(key, value, init, prev) {\n            key === 'title' && console.log(value, init);  // Orders true\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nErhält den Wert des Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Wert des Paths. |\n| `path` | `String` | yes |  | Der Path, der sich geändert hat. |\n| `type` | `Number` | yes |  | Die Quelle der Änderung. |\n\nDefiniere ihn, um den Wert zu rendern. Die Standardimplementierung schreibt den formatierten Wert in verschachtelte Felder vom Typ `input`, `select` und `textarea` mit dem Attribut `data-jc-bind`.\n\nDas Argument `type` gibt an, woher die Änderung stammt:\n\n| Typ | Quelle |\n| --- | --- |\n| `0` | Die Initialisierung. |\n| `1` | Eine manuelle Änderung, etwa `SET()`. |\n| `2` | Eine Benutzereingabe. |\n| `3` | Ein Standardwert oder ein Zurücksetzen. |\n\nExample: setter definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value, path, type) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter(value, [realtime], [nobind])\n\nType: `delegate`\n\nSchreibt einen Wert aus einer Benutzereingabe in den Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Rohwert. |\n| `realtime` | `Boolean` | no |  | `true`, wenn der Wert während der Eingabe eintrifft. |\n| `nobind` | `Boolean` | no |  | `true` validiert den Wert, ohne ihn zu schreiben. |\n\nDie Standardimplementierung führt die Parser aus und schreibt das Ergebnis. Verschachtelte Felder mit dem Attribut `data-jc-bind` rufen sie automatisch auf. Rufe sie aus deinen eigenen Steuerelementen auf, um einen Wert zu schreiben.\n\nExample: getter definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"><button>Set</button></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.event('click', 'button', () => self.getter('Peter'));\n        };\n    });\n    setTimeout(function() {\n        $('button').click();\n        console.log(GET('form.name'));  // Peter\n    }, 500);\n</script>\n```\n\n### self.setter2 = function(value, path, type)\n\nType: `delegate`\n\nLäuft nach dem Delegate `setter`.\n\nEr erhält dieselben Argumente. Verwende ihn, um eine Komponente zu erweitern und ihren Setter beizubehalten.\n\nExample: setter2 definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter2 = value => value && console.log(value);  // Peter\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter2 = function(value, realtime)\n\nType: `delegate`\n\nLäuft, wenn der `getter` einen Wert erhält.\n\nEr erhält den geparsten Wert und das Argument `realtime`.\n\nExample: getter2 definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.getter2 = value => console.log(value);  // PETER\n        self.parser((path, value) => value.toUpperCase());\n    });\n    setTimeout(() => FIND('box').getter('peter'), 500);\n</script>\n```\n\n### self.state = function(type, what)\n\nType: `delegate`\n\nLäuft, wenn sich der Zustand der Instanz ändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | yes |  | Die Quelle der Änderung. |\n| `what` | `Number` | yes |  | Die Art der Änderung. |\n\nDas Argument `type` ist `0` für die Initialisierung, `1` für eine manuelle Änderung und `2` für eine Benutzereingabe.\n\nDas Argument `what` gibt an, was passiert ist:\n\n| What | Bedeutung |\n| --- | --- |\n| `1` | Validierung. |\n| `2` | Der Zustand „berührt“ hat sich geändert. |\n| `3` | Ein Zurücksetzen. |\n| `4` | Eine Aktualisierung. |\n| `5` | Ein neuer Wert. |\n| `6` | Eine Benachrichtigung. |\n\nExample: state definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state = function(type, what) {\n            console.log(type, what);  // 0 3\n        };\n    });\n</script>\n```\n\n### self.state2 = function(type, what)\n\nType: `delegate`\n\nLäuft nach dem Delegate `state`.\n\nEr erhält dieselben Argumente.\n\nExample: state2 definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state2 = (type, what) => console.log(type, what);  // 0 3\n    });\n</script>\n```\n\n### self.validate = function(value, init)\n\nType: `delegate`\n\nEntscheidet, ob der Wert gültig ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Wert des Paths. |\n| `init` | `Boolean` | no |  | `true` während der Initialisierung. |\n\nGib für einen gültigen Wert `true` zurück. Das Ergebnis wird in `config.invalid` gespeichert.\n\nExample: validate definieren\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        self.validate = value => !!value;\n        self.done = () => console.log(config.invalid);  // true\n    });\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nLäuft einmal pro Minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Die Anzahl der Durchläufe. |\n\nDer Delegate erhält einen Zähler, der bei jedem Lauf um eins steigt.\n\n### self.destroy = function()\n\nType: `delegate`\n\nWird ausgeführt, wenn die Instanz entfernt wird.\n\nGib hier Timer und externe Listener frei.\n\nExample: destroy definieren\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => FIND('box').remove(), 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nDer Name der Komponente mit ihrer Version.\n\nExample: name lesen\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.name));  // box@2\n</script>\n```\n\n### self.version\n\nType: `property`\n\nDie Version aus dem Namen der Komponente.\n\nDer Wert ist leer, wenn der Name keine Version enthält. Das Element erhält außerdem die Klasse `jc-v{version}`.\n\nExample: version lesen\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.version));  // 2\n</script>\n```\n\n### self.id\n\nType: `property`\n\nDer Bezeichner der Instanz.\n\nDer Konfigurationsschlüssel [`$id`](../ui-component/#x-id) legt sie fest. Andernfalls hat sie denselben Wert wie `ID`.\n\nExample: id lesen\n```html\n<ui-component name=\"box\" config=\"$id:orders\"></ui-component>\n<script>\n    COMPONENT('box', self => self.make = () => console.log(self.id));  // orders\n</script>\n```\n\n### self.ID\n\nType: `property`\n\nDie eindeutige, generierte Kennung der Instanz.\n\nExample: ID lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.ID.substring(0, 2)));  // jc\n</script>\n```\n\n### self.path\n\nType: `property`\n\nDer an die Instanz gebundene Path des Datenmodells.\n\nDer Wert ist leer, wenn die Komponente keinen Path hat.\n\nExample: path lesen\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.path));  // form.name\n</script>\n```\n\n### self.type\n\nType: `property`\n\nDer Datentyp der Instanz.\n\nDer Wert wird an Parser und Formatter übergeben. Lege ihn in der Deklaration oder mit dem Schlüssel [`$type`](../ui-component/#x-type) fest.\n\nExample: type lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.type = 'number';\n        self.parser((path, value, type) => console.log(type));  // number\n        self.make = () => self.parser('1');\n    });\n</script>\n```\n\n### self.format\n\nType: `property`\n\nDas an Parser und Formatter übergebene Format.\n\nIst die Eigenschaft leer, wird `config.format` verwendet.\n\nExample: format lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.format = 'dd.MM.yyyy';\n        self.formatter((path, value, type, format) => console.log(format));  // dd.MM.yyyy\n        self.make = () => self.formatter('1');\n    });\n</script>\n```\n\n### self.trim\n\nType: `property`\n\nEntfernt im Parser Leerzeichen rund um den Text.\n\nDer Standardwert ist `true`.\n\nExample: trim lesen\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.trim = false;\n        self.make = () => console.log(self.parser('  A  ').length);  // 5\n    });\n</script>\n```\n\n### self.config\n\nType: `property`\n\nDas Konfigurationsobjekt.\n\nEs enthält auch die Zustandsschlüssel `modified`, `touched`, `invalid` und, sofern gesetzt, `disabled`.\n\nExample: config lesen\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.config.title, self.config.touched));  // Orders false\n</script>\n```\n\n### self.element\n\nType: `property`\n\nDas Element der Instanz als jQuery-Objekt.\n\nExample: element lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.element.prop('tagName')));  // UI-COMPONENT\n</script>\n```\n\n### self.dom\n\nType: `property`\n\nDas Element der Instanz als DOM-Knoten.\n\nExample: dom lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.dom.tagName));  // UI-COMPONENT\n</script>\n```\n\n### self.owner\n\nType: `property`\n\nDie nächstgelegene übergeordnete Komponente.\n\nDie Eigenschaft fehlt, wenn die Komponente keine übergeordnete Komponente hat.\n\nExample: owner lesen\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', self => console.log(self.owner.name));  // parent\n</script>\n```\n\n### self.caller\n\nType: `property`\n\nDie Komponente, die diese Instanz über `exec()` aufgerufen hat.\n\nExample: caller lesen\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', function(self) {\n        self.ping = () => console.log(self.caller.name);  // parent\n    });\n    setTimeout(() => FIND('parent').exec('ping'), 500);\n</script>\n```\n\n### self.global\n\nType: `property`\n\nEin Objekt, das alle Instanzen der Komponente gemeinsam nutzen.\n\nExample: global lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.global.count = (self.global.count || 0) + 1;\n    });\n    setTimeout(() => console.log(FIND('box').global.count), 500);  // 2\n</script>\n```\n\n### self.scope\n\nType: `property`\n\nDer [Scope](../scope/) der Instanz.\n\nDie Eigenschaft existiert, wenn der Path `?` enthält.\n\nExample: scope lesen\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.scope.path));  // users\n</script>\n```\n\n### self.pathscope\n\nType: `property`\n\nDer Path des Scopes der Instanz.\n\nDie Eigenschaft existiert, wenn der Path `?` enthält.\n\nExample: pathscope lesen\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.pathscope));  // users\n</script>\n```\n\n### self.plugin\n\nType: `property`\n\nDas [Plugin](../plugin/) des Scopes der Instanz.\n\nDie Eigenschaft existiert, wenn der Path `?` enthält.\n\nExample: plugin lesen\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.plugin.name));  // users\n</script>\n```\n\n### self.siblings\n\nType: `property`\n\nGibt an, ob das Element mehrere Komponenten enthält.\n\nExample: siblings lesen\n```html\n<ui-component name=\"a,b\"></ui-component>\n<script>\n    COMPONENT('a', self => console.log(self.siblings));  // true\n    COMPONENT('b', function(self) {});\n</script>\n```\n\n### self.removed\n\nType: `property`\n\nGibt an, ob die Instanz entfernt wurde.\n\nExample: removed lesen\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var com = FIND('box');\n        com.remove();\n        console.log(com.removed);  // true\n    }, 500);\n</script>\n```\n\n### com.get([path])\n\nType: `method`\n\nGibt den Wert des gebundenen Paths zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Ein anderer Path. |\n\nReturns: `Object` Der Wert.\n\nMit einem Argument liest die Methode einen anderen Path.\n\nExample: get() verwenden\n```js\nvar com = FIND('demo');\nSET('form.name', 'Peter');\nconsole.log(com.get());  // Peter\n```\n\n### com.set(value, [type])\n\nType: `method`\n\nSchreibt einen Wert in den gebundenen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nDie Instanz wird als geändert markiert.\n\nExample: set() verwenden\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(GET('form.name'), com.config.modified);  // Peter true\n```\n\n### com.modify(value, [type])\n\nType: `method`\n\nSchreibt einen Wert über die Parser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Rohwert. |\n| `type` | `Number` | no | `2` | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nDie Instanz wird als berührt markiert.\n\nExample: modify() verwenden\n```js\nvar com = FIND('demo');\ncom.modify('  Peter  ');\nconsole.log(GET('form.name'), com.config.touched);  // Peter true\n```\n\n### com.inc(value, [type])\n\nType: `method`\n\nErhöht die im gebundenen Path gespeicherte Zahl.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number` | yes |  | Die Schrittweite. |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nExample: inc() verwenden\n```js\nvar com = FIND('demo');\ncom.set(5);\ncom.inc(2);\nconsole.log(GET('form.name'));  // 7\n```\n\n### com.extend(value, [type])\n\nType: `method`\n\nFührt ein Objekt mit dem gebundenen Path zusammen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Die Felder, die zusammengeführt werden. |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nExample: extend() verwenden\n```js\nvar com = FIND('demo');\ncom.set({ a: 1 });\ncom.extend({ b: 2 });\nconsole.log(GET('form.name'));  // {\"a\":1,\"b\":2}\n```\n\n### com.push(value, [type])\n\nType: `method`\n\nFügt dem im gebundenen Path gespeicherten Array einen Eintrag hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Das Element. |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nExample: push() verwenden\n```js\nvar com = FIND('demo');\ncom.push('A');\ncom.push('B');\nconsole.log(GET('form.name'));  // [\"A\",\"B\"]\n```\n\n### com.rewrite(value, [type])\n\nType: `method`\n\nSchreibt einen Wert, ohne jemanden zu benachrichtigen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `type` | `Number` | no |  | Der Typ der Änderung. |\n\nReturns: `Component` Die Instanz.\n\nGebundene Komponenten, Binder und Watcher werden nicht aufgerufen.\n\nExample: rewrite() verwenden\n```js\nvar com = FIND('demo');\ncom.rewrite('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### com.update([type])\n\nType: `method`\n\nSchreibt den aktuellen Wert erneut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nAlle Listener des Paths werden benachrichtigt.\n\nExample: update() verwenden\n```js\nvar com = FIND('demo');\ncom.watch(function(path, value) {\n    console.log(value);  // Peter\n});\nwindow.form.name = 'Peter';\ncom.update();\n```\n\n### com.refresh([notify], [type])\n\nType: `method`\n\nRuft den Setter dieser Instanz mit dem aktuellen Wert auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `notify` | `Boolean` | no |  | `true` benachrichtigt alle Listener. |\n| `type` | `Number|String` | no |  | Der an den Setter übergebene Typ. |\n\nReturns: `Component` Die Instanz.\n\nMit `notify` wird der Wert in den Path geschrieben und alle Listener werden benachrichtigt.\n\nExample: refresh() verwenden\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.refresh();\nconsole.log(com.text());  // Peter\n```\n\n### com.notify()\n\nType: `method`\n\nBenachrichtigt die Listener genau des gebundenen Paths.\n\nReturns: `Component` Die Instanz.\n\nDie Methode ruft `NOTIFY()` mit dem Path der Instanz auf.\n\nExample: notify() verwenden\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.notify();\nconsole.log(com.text());  // Peter\n```\n\n### com.skip()\n\nType: `method`\n\nÜberspringt den nächsten Aufruf des Setters.\n\nReturns: `Component` Die Instanz.\n\nExample: skip() verwenden\n```js\nvar com = FIND('demo');\ncom.skip();\ncom.set('Peter');\nsetTimeout(() => console.log(com.text() || 'empty'), 500);  // empty\n```\n\n### com.bind(flags, [value])\n\nType: `method`\n\nÄndert den Zustand und schreibt optional einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Die Flags. |\n| `value` | `Object` | no |  | Der zu schreibende Wert. |\n\nDas Argument `flags` ist eine Liste von Wörtern, getrennt durch ein Leerzeichen, ein Komma oder `|`. Ein optionales Präfix `@` wird ignoriert.\n\n| Flag | Wirkung |\n| --- | --- |\n| `touched`, `touch` | Markiert die Instanz als berührt. |\n| `modified`, `modify`, `changed`, `change` | Markiert die Instanz als geändert. |\n| `reset` | Löscht den Zustand „berührt“ und „geändert“. |\n| `validate` | Validiert den Wert. |\n| `setter` | Ruft den Setter auf. |\n\nWird `value` übergeben, wird der Wert in den Path geschrieben, und der Setter dieser Instanz läuft nur mit dem Flag `setter`.\n\nExample: bind() verwenden\n```js\nvar com = FIND('demo');\ncom.bind('@touched @modified', 'Peter');\nconsole.log(GET('form.name'), com.config.touched, com.config.modified);  // Peter true true\n```\n\n### com.reset()\n\nType: `method`\n\nLöscht den Zustand berührt und geändert.\n\nReturns: `Component` Die Instanz.\n\nDer Wert wird erneut validiert.\n\nExample: reset() verwenden\n```js\nvar com = FIND('demo');\ncom.modify('Peter');\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### com.default([reset])\n\nType: `method`\n\nStellt den Standardwert der Instanz wieder her.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `reset` | `Boolean` | no | `true` | `false` behält den Zustand der Instanz bei. |\n\nReturns: `Component` Die Instanz.\n\nDer Standardwert stammt aus dem Attribut [`default`](../ui-component/#default).\n\nExample: default() verwenden\n```js\nvar com = FIND('demo');\ncom.set('Peter');\ncom.default();\nconsole.log(GET('form.name'));  // Anonymous\n```\n\n### com.change([value])\n\nType: `method`\n\nSetzt den Zustand „berührt“ und „geändert“ der Komponenten auf dem Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no | `true` | Der neue Zustand. |\n\nReturns: `Component` Die Instanz.\n\nDie Methode gilt für alle Komponenten, die an den Path und seine verschachtelten Paths gebunden sind. Außerdem steht sie als `touched()` zur Verfügung.\n\nExample: change() verwenden\n```js\nvar com = FIND('demo');\ncom.change();\nconsole.log(com.config.touched, com.config.modified);  // true true\n```\n\n### com.dirty([value], [noemit])\n\nType: `method`\n\nLiest oder setzt den Zustand „unberührt“.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no |  | `false` markiert die Instanz als berührt. |\n| `noemit` | `Boolean` | no |  | `true` überspringt den Delegate `state`. |\n\nReturns: `Boolean|Component` Der Zustand oder, wenn `value` übergeben wird, die Instanz.\n\nOhne Argumente gibt die Methode für eine unberührte Instanz `true` zurück.\n\nExample: dirty() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.dirty());  // true\ncom.dirty(false);\nconsole.log(com.config.touched);  // true\n```\n\n### com.isInvalid()\n\nType: `method`\n\nGibt an, ob die Instanz berührt und ungültig ist.\n\nReturns: `Boolean` Das Ergebnis.\n\nExample: isInvalid() verwenden\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\ncom.modify('');\ncom.validate2();\ncom.bind('touched');\nconsole.log(com.isInvalid());  // true\n```\n\n### com.validate2()\n\nType: `method`\n\nFührt den Delegate `validate` aus und aktualisiert den Zustand.\n\nReturns: `Boolean` `true` bei einem gültigen Wert.\n\nExample: validate2() verwenden\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\nconsole.log(com.validate2());  // false\n```\n\n### com.notmodified([fields])\n\nType: `method`\n\nGibt an, ob der Wert derselbe ist wie bei der letzten Prüfung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fields` | `String|Array` | no |  | Die zu vergleichenden Felder. |\n\nReturns: `Boolean` `true`, wenn sich der Wert nicht geändert hat.\n\nDie erste Prüfung gibt `false` zurück.\n\nExample: notmodified() verwenden\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(com.notmodified());  // false\nconsole.log(com.notmodified());  // true\n```\n\n### com.parser(value, [prepend])\n\nType: `method`\n\nFügt einen Parser hinzu oder parst einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Ein Parser oder der zu parsende Wert. |\n| `prepend` | `Boolean` | no |  | `true` fügt den Parser am Anfang hinzu. |\n\nReturns: `Object` Der geparste Wert oder, wenn ein Parser hinzugefügt wird, die Instanz.\n\nEine Funktion wird zu den Parsern der Instanz hinzugefügt. Die Funktion erhält `path`, `value`, `type` und `format` und gibt den neuen Wert zurück. Jedes andere Argument wird geparst und zurückgegeben.\n\nExample: parser() verwenden\n```js\nvar com = FIND('demo');\ncom.parser((path, value) => value.toUpperCase());\nconsole.log(com.parser('peter'));  // PETER\n```\n\n### com.formatter(value, [prepend])\n\nType: `method`\n\nFügt einen Formatter hinzu oder formatiert einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Ein Formatter oder der zu formatierende Wert. |\n| `prepend` | `Boolean` | no |  | `true` fügt den Formatter am Anfang hinzu. |\n\nReturns: `Object` Der formatierte Wert oder, wenn ein Formatter hinzugefügt wird, die Instanz.\n\nEine Funktion wird zu den Formattern der Instanz hinzugefügt. Die Funktion erhält `path`, `value`, `type` und `format` und gibt den neuen Wert zurück. Jedes andere Argument wird formatiert und zurückgegeben.\n\nExample: formatter() verwenden\n```js\nvar com = FIND('demo');\ncom.formatter((path, value) => value + '!');\nconsole.log(com.formatter('Peter'));  // Peter!\n```\n\n### com.parsesource(value)\n\nType: `method`\n\nWandelt eine Textliste in ein Array von Einträgen um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Die Liste. |\n\nReturns: `Array` Objekte mit `id`, `name` und `icon`.\n\nEinträge werden durch ein Komma getrennt. Jeder Eintrag hat die Form `id|name|icon`. Hat die Instanz den Typ `number`, werden die Kennungen in Zahlen umgewandelt.\n\nExample: parsesource() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.parsesource('1|One,2|Two|home')[1]);  // {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n\n### com.reconfigure(value, [callback], [init], [noemit])\n\nType: `method`\n\nÄndert die Konfiguration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Die Konfiguration. |\n| `callback` | `Function` | no |  | Erhält `key`, `value`, `init` und `prev` anstelle des Delegates `configure`. |\n| `init` | `Boolean` | no |  | Das Argument `init` des Delegates. |\n| `noemit` | `Boolean` | no |  | `true` überspringt den Delegate. |\n\nReturns: `Component` Die Instanz.\n\nDer Wert kann ein String aus `key:value`-Paaren, ein Objekt oder `=path` sein, um ein Objekt aus einem Path zu lesen. Der Delegate `configure` erhält jeden Schlüssel.\n\nExample: reconfigure() verwenden\n```js\nvar com = FIND('demo');\ncom.reconfigure('title:Orders;limit:10');\nconsole.log(com.config.title, com.config.limit);  // Orders 10\n```\n\n### com.configdisplay(key, value)\n\nType: `method`\n\nLöst einen Wert auf, der von der Anzeige abhängt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Name des Schlüssels. |\n| `value` | `Object` | yes |  | Der Wert. |\n\nReturns: `Object` Der aufgelöste Wert.\n\nDer Wert hat die Form `@xs=1,@md=2`. Andere Werte werden unverändert zurückgegeben. Siehe [Responsive Konfiguration](../ui-component/#responsive-configuration).\n\nExample: configdisplay() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.configdisplay('size', '@xs=1,@lg=4'), WIDTH());  // 1 xs\n```\n\n### com.data(key, [value])\n\nType: `method`\n\nLiest oder schreibt Daten der Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Name des Schlüssels. |\n| `value` | `Object` | no |  | Der zu schreibende Wert. |\n\nReturns: `Object` Der Wert.\n\nVerschachtelte Elemente lesen die Schlüssel über den Path `@key`. Ein leerer Schlüssel ist der aktuelle Wert der Instanz.\n\nExample: data() verwenden\n```js\nvar com = FIND('demo');\ncom.data('title', 'Orders');\nconsole.log(com.data('title'));  // Orders\n```\n\n### com.datasource(path, callback, [init])\n\nType: `method`\n\nÜberwacht einen Path, der eine Datenquelle enthält.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path der Datenquelle. |\n| `callback` | `Function` | yes |  | Die Funktion, die die Daten erhält. |\n| `init` | `Boolean` | no | `true` | `false` überspringt den ersten Aufruf. |\n\nReturns: `Component` Die Instanz.\n\nDer Callback erhält `path`, `value` und `type`. Sofern `init` nicht `false` ist, läuft er auch, nachdem die Konfiguration geladen wurde. Ein neuer Aufruf ersetzt die vorherige Datenquelle.\n\nExample: datasource() verwenden\n```js\nvar com = FIND('demo');\ncom.datasource('common.items', function(path, value) {\n    console.log(value);  // [1,2]\n}, false);\nSET('common.items', [1, 2]);\n```\n\n### com.watch([path], callback, [init])\n\nType: `method`\n\nÜberwacht einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der Path, der überwacht wird. |\n| `callback` | `Function` | yes |  | Die Funktion, die die Änderungen erhält. |\n| `init` | `Boolean` | no |  | `true` ruft den Callback sofort auf. |\n\nReturns: `Component` Die Instanz.\n\nDer Callback erhält `path`, `value` und `type`, und `this` ist die Instanz. Ohne Path überwacht die Methode den Path der Instanz. Der Watcher wird zusammen mit der Instanz entfernt.\n\nExample: watch() verwenden\n```js\nvar com = FIND('demo');\ncom.watch('form.age', function(path, value) {\n    console.log(path, value);  // form.age 30\n});\nSET('form.age', 30);\n```\n\n### com.unwatch(path)\n\nType: `method`\n\nEntfernt die Watcher eines Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der überwachte Path. |\n\nReturns: `Component` Die Instanz.\n\nDie Methode entfernt alle Watcher, die diese Instanz auf dem Path hat.\n\nExample: unwatch() verwenden\n```js\nvar com = FIND('demo');\ncom.watch('form.age', () => console.log('called'));\ncom.unwatch('form.age');\nSET('form.age', 30);\nconsole.log('end');  // end\n```\n\n### com.on(name, callback)\n\nType: `method`\n\nLauscht auf ein globales Event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | yes |  | Der Listener. |\n\nReturns: `Component` Die Instanz.\n\nDer Listener wird zusammen mit der Instanz entfernt. Ein Präfix `^` vor dem Namen stellt den Listener an die erste Stelle.\n\nExample: on() verwenden\n```js\nvar com = FIND('demo');\ncom.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### com.off(name, [callback])\n\nType: `method`\n\nEntfernt einen Listener eines globalen Events.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | no |  | Der Listener. |\n\nReturns: `Component` Die Instanz.\n\nOhne Callback werden alle Listener des Events in dieser Instanz entfernt.\n\nExample: off() verwenden\n```js\nvar com = FIND('demo');\nvar fn = () => console.log('called');\ncom.on('saved', fn);\ncom.off('saved', fn);\nconsole.log(EMIT('saved'));  // false\n```\n\n### com.emit(name, [...args])\n\nType: `method`\n\nLöst ein globales Event aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `args` | `Object` | no |  | Die Argumente des Events. |\n\nReturns: `Component` Die Instanz.\n\nDie Methode ruft `EMIT()` auf.\n\nExample: emit() verwenden\n```js\nvar com = FIND('demo');\nON('saved', value => console.log(value));  // 5\ncom.emit('saved', 5);\n```\n\n### com.command(name, callback)\n\nType: `method`\n\nRegistriert einen Befehl der Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Befehls. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nReturns: `Component` Die Instanz.\n\nEin Präfix `^` vor dem Namen stellt den Handler an die erste Stelle. Befehle werden von [`CMD()`](#cmd) oder vom globalen `CMD()` aufgerufen.\n\nExample: command() verwenden\n```js\nvar com = FIND('demo');\ncom.command('clear', () => console.log('cleared'));  // cleared\nCMD('clear');\n```\n\n### com.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuft einen Befehl dieser Instanz auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Befehls. |\n\nReturns: `Component` Die Instanz.\n\nDie Methode akzeptiert bis zu fünf Argumente.\n\nExample: CMD() verwenden\n```js\nvar com = FIND('demo');\ncom.command('add', (a, b) => console.log(a + b));  // 3\ncom.CMD('add', 1, 2);\n```\n\n### com.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuft eine Methode aller verschachtelten Komponenten auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Methode. |\n\nReturns: `Component` Die Instanz.\n\nJede verschachtelte Komponente erhält diese Instanz in `caller`.\n\nExample: exec() verwenden\n```js\nvar com = FIND('demo');\ncom.exec('ping', 5);\n```\n\n### com.GET(path)\n\nType: `method`\n\nLiest einen Path relativ zum Scope der Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `Object` Der Wert.\n\nDas Zeichen `?` wird durch den Path des Scopes ersetzt.\n\nExample: GET() verwenden\n```js\nvar com = FIND('demo');\nSET('users.name', 'Peter');\nconsole.log(com.GET('?.name'));  // Peter\n```\n\n### com.SET(path, value)\n\nType: `method`\n\nSchreibt einen Path relativ zum Scope der Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Object` | yes |  | Der Wert. |\n\nDas Zeichen `?` wird durch den Path des Scopes ersetzt.\n\nExample: SET() verwenden\n```js\nvar com = FIND('demo');\ncom.SET('?.age', 30);\nconsole.log(GET('users.age'));  // 30\n```\n\n### com.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Funktion über ihren Path auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path der Funktion. |\n\nReturns: `Component` Die Instanz.\n\nDas Zeichen `?` wird durch den Path des Scopes ersetzt. Ein Path mit dem Präfix `@` ruft eine Methode der übergeordneten Komponente auf.\n\nExample: EXEC() verwenden\n```js\nvar com = FIND('child');\ncom.EXEC('@ping', 5);\n```\n\n### com.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Funktion auf oder schreibt einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `Component` Die Instanz.\n\nDie Methode ruft die Funktion auf dem Path auf. Enthält der Path keine Funktion, wird das erste Argument hineingeschrieben. Das Präfix `@` funktioniert mit der übergeordneten Komponente.\n\nExample: SEEX() verwenden\n```js\nvar com = FIND('child');\ncom.SEEX('@title', 'Orders');\nconsole.log(FIND('demo').title);  // Orders\n```\n\n### com.makepath(path)\n\nType: `method`\n\nLöst einen Path im Scope der Instanz auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `String` Der aufgelöste Path.\n\nExample: makepath() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.makepath('?.age'));  // users.age\n```\n\n### com.scopepath(path)\n\nType: `method`\n\nErsetzt `?` in einem Path durch den Path des Scopes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `String` Der aufgelöste Path.\n\nEin Path ohne `?` wird unverändert zurückgegeben.\n\nExample: scopepath() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.scopepath('?.age'), com.scopepath('form.age'));  // users.age form.age\n```\n\n### com.setPath(path)\n\nType: `method`\n\nÄndert den gebundenen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der neue Path. |\n\nReturns: `Component` Die Instanz.\n\nExample: setPath() verwenden\n```js\nvar com = FIND('demo');\ncom.setPath('form.other');\nSET('form.other', 5);\nconsole.log(com.path, com.get());  // form.other 5\n```\n\n### com.blind()\n\nType: `method`\n\nTrennt die Instanz von ihrem Path.\n\nReturns: `Component` Die Instanz.\n\nExample: blind() verwenden\n```js\nvar com = FIND('demo');\ncom.blind();\nSET('form.name', 'Peter');\nconsole.log(com.path, com.text() || 'empty');  // null empty\n```\n\n### self.readonly()\n\nType: `method`\n\nEntfernt die Delegates `setter`, `getter` und `validate`.\n\nReturns: `Component` Die Instanz.\n\nVerwende die Methode in Komponenten, die nur Inhalte anzeigen.\n\nExample: readonly() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.setter, com.getter);  // null null\n```\n\n### self.singleton()\n\nType: `method`\n\nErlaubt nur eine Instanz der Komponente auf der Seite.\n\nReturns: `Component` Die Instanz.\n\nAndere Elemente derselben Komponente werden entfernt.\n\nExample: singleton() verwenden\n```js\nconsole.log(FIND('demo', true).length, $('ui-component').length);  // 1 1\n```\n\n### self.bindchanges([enable])\n\nType: `method`\n\nÜberspringt den Setter, wenn sich der Wert nicht geändert hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` schaltet die Funktion ab. |\n\nReturns: `Component` Die Instanz.\n\nExample: bindchanges() verwenden\n```js\nSET('form.name', 'A');\nSET('form.name', 'A');\nsetTimeout(() => console.log(window.calls), 500);  // 2\n```\n\n### self.bindexact([enable])\n\nType: `method`\n\nIgnoriert Änderungen an verschachtelten Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` schaltet die Funktion ab. |\n\nReturns: `Component` Die Instanz.\n\nDer Setter läuft nur für den exakten Path oder seine übergeordneten Paths.\n\nExample: bindexact() verwenden\n```js\nSET('form.user.name', 'Peter');\nsetTimeout(() => console.log(window.calls), 500);  // 1\n```\n\n### self.bindvisible([timeout])\n\nType: `method`\n\nVerzögert den Setter, bis das Element sichtbar ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `timeout` | `Number|Boolean` | no | `DEF.delaybinder` | Die Verzögerung in Millisekunden, nachdem das Element sichtbar geworden ist. `false` schaltet die Funktion ab. |\n\nReturns: `Component` Die Instanz.\n\nExample: bindvisible() verwenden\n```js\nSET('form.name', 'Peter');\nsetTimeout(() => $('#tab').show(), 500);\nsetTimeout(() => console.log($('ui-component').text()), 1500);  // Peter\n```\n\n### self.autofill([enable])\n\nType: `method`\n\nLiest Werte, die der Browser ausgefüllt hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` schaltet die Funktion ab. |\n\nReturns: `Component` Die Instanz.\n\nSobald die Seite bereit ist, wird der Wert verschachtelter Felder mit dem Attribut `data-jc-bind` in den Path geschrieben.\n\nExample: autofill() verwenden\n```js\n$('input').val('Peter');\nsetTimeout(() => console.log(GET('form.name')), 1400);  // Peter\n```\n\n### com.caniuse(name)\n\nType: `method`\n\nGibt an, ob eine Komponente verfügbar ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Komponente. |\n\nReturns: `Number` `1` für eine deklarierte Komponente, `2` für eine Lazy-Komponente, `undefined` für eine unbekannte.\n\nExample: caniuse() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.caniuse('demo'));  // 1\n```\n\n### com.main()\n\nType: `method`\n\nGibt die nächstgelegene übergeordnete Komponente zurück.\n\nReturns: `Component` Die übergeordnete Komponente oder `null`.\n\nExample: main() verwenden\n```js\nvar com = FIND('child');\nconsole.log(com.main().name);  // demo\n```\n\n### com.compile([container])\n\nType: `method`\n\nKompiliert neue Inhalte des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `jQuery|Element` | no | `the component element` | Das zu kompilierende Element. |\n\nReturns: `Component` Die Instanz.\n\nRufe die Methode auf, nachdem du Elemente mit Bindungen oder Komponenten hinzugefügt hast.\n\nExample: compile() verwenden\n```js\nvar com = FIND('demo');\ncom.append('<div data-bind=\"form.name__text\"></div>');\ncom.compile();\nSET('form.name', 'Peter');\nsetTimeout(() => console.log(com.find('div').text()), 500);  // Peter\n```\n\n### com.import(url, [callback], [insert], [preparator])\n\nType: `method`\n\nImportiert Inhalte in das Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL. |\n| `callback` | `Function` | no |  | Läuft nach dem Import. |\n| `insert` | `Boolean` | no |  | Das Argument `insert` von `IMPORT()`. |\n| `preparator` | `Function` | no |  | Ändert die Antwort vor dem Einfügen. |\n\nReturns: `Component` Die Instanz.\n\nDie Methode ruft `IMPORT()` mit dem Element als Ziel auf.\n\nExample: import() verwenden\n```js\nvar com = FIND('demo');\ncom.import('/part.html', () => console.log('imported'));  // imported\n```\n\n### com.replace(element, [remove])\n\nType: `method`\n\nVerschiebt die Instanz auf ein anderes Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Das neue Element. |\n| `remove` | `Boolean` | no |  | `true` entfernt das ursprüngliche Element. |\n\nReturns: `Component` Die Instanz.\n\nExample: replace() verwenden\n```js\nvar com = FIND('demo');\ncom.replace($('#target'), true);\nconsole.log(com.dom.id, $('ui-component').length);  // target 0\n```\n\n### com.remove([noclear])\n\nType: `method`\n\nEntfernt die Instanz und ihr Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noclear` | `Boolean` | no |  | `true` startet die Bereinigung nicht sofort. |\n\nReturns: `Boolean` Immer `true`.\n\nDer Delegate `destroy` läuft während der Bereinigung. Die Methode steht auch als `kill()` zur Verfügung.\n\nExample: remove() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.remove());  // true\n```\n\n### com.find(selector)\n\nType: `method`\n\nFindet verschachtelte Elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Ein Selektor oder ein Objekt aus Selektoren. |\n\nReturns: `jQuery|Object` Das Ergebnis.\n\nEin Objekt aus Selektoren liefert ein Objekt aus jQuery-Ergebnissen mit denselben Schlüsseln.\n\nExample: find() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.find('.label').text());  // Text\n```\n\n### com.closest(selector)\n\nType: `method`\n\nFindet das nächstgelegene passende Elternelement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor. |\n\nReturns: `jQuery` Das Ergebnis.\n\nExample: closest() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.closest('body').length);  // 1\n```\n\n### com.parent([selector])\n\nType: `method`\n\nGibt ein Elternelement zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Der Selektor. |\n\nReturns: `jQuery` Das Ergebnis.\n\nDas Argument kann Folgendes sein:\n\n| Wert | Ergebnis |\n| --- | --- |\n| weggelassen | Das direkte Elternelement. |\n| Ein Selektor | Das nächstgelegene passende Element. |\n| `auto` | Das nächstgelegene Elternelement mit definierter Höhe, andernfalls `window`. |\n| `window` | `window` als jQuery-Objekt. |\n| `document` | Das Objekt `document`. |\n| `parent` | Das direkte Elternelement. |\n| `parent2` | Das Element zwei Ebenen über dem direkten Elternelement. |\n\nExample: parent() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.parent().prop('tagName'));  // BODY\n```\n\n### com.html([value])\n\nType: `method`\n\nLiest oder ersetzt den HTML-Inhalt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Der neue Inhalt. |\n\nReturns: `String|jQuery` Der Inhalt oder, wenn `value` übergeben wird, das Element.\n\nEin Array wird zusammengefügt.\n\nExample: html() verwenden\n```js\nvar com = FIND('demo');\ncom.html('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.text([value])\n\nType: `method`\n\nLiest oder ersetzt den Textinhalt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Der neue Inhalt. |\n\nReturns: `String|jQuery` Der Inhalt oder, wenn `value` übergeben wird, das Element.\n\nEin Array wird zusammengefügt.\n\nExample: text() verwenden\n```js\nvar com = FIND('demo');\ncom.text('<b>A</b>');\nconsole.log(com.html());  // &lt;b&gt;A&lt;/b&gt;\n```\n\n### com.append(value)\n\nType: `method`\n\nFügt Inhalt am Ende des Elements hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Der Inhalt. |\n\nReturns: `jQuery` Das Element.\n\nEin Array wird zusammengefügt.\n\nExample: append() verwenden\n```js\nvar com = FIND('demo');\ncom.empty();\ncom.append('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.empty()\n\nType: `method`\n\nEntfernt den Inhalt des Elements.\n\nReturns: `jQuery` Das Element.\n\nAuch verschachtelte Komponenten werden entfernt.\n\nExample: empty() verwenden\n```js\nvar com = FIND('demo');\ncom.empty();\nconsole.log(com.html() === '');  // true\n```\n\n### com.event(name, [selector], callback)\n\nType: `method`\n\nHängt ein jQuery-Event an das Element an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `selector` | `String` | no |  | Der delegierte Selektor. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nReturns: `Component` Die Instanz.\n\nDie Argumente sind dieselben wie bei der jQuery-Methode `on()`.\n\nExample: event() verwenden\n```js\nvar com = FIND('demo');\ncom.event('click', '.label', () => console.log('clicked'));  // clicked\ncom.find('.label').click();\n```\n\n### com.aclass(classes, [timeout])\n\nType: `method`\n\nFügt CSS-Klassen hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Die Klassen. |\n| `timeout` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `Component` Die Instanz.\n\nExample: aclass() verwenden\n```js\nvar com = FIND('demo');\ncom.aclass('active');\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.rclass([classes], [timeout])\n\nType: `method`\n\nEntfernt CSS-Klassen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Die Klassen. |\n| `timeout` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `Component` Die Instanz.\n\nOhne Argument werden alle Klassen entfernt.\n\nExample: rclass() verwenden\n```js\nvar com = FIND('demo');\ncom.aclass('active');\ncom.rclass('active');\nconsole.log(com.hclass('active'));  // false\n```\n\n### com.rclass2(search)\n\nType: `method`\n\nEntfernt CSS-Klassen, die einen bestimmten Text enthalten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Der Text oder ein regulärer Ausdruck. |\n\nReturns: `Component` Die Instanz.\n\nExample: rclass2() verwenden\n```js\nvar com = FIND('demo');\ncom.aclass('col-1 col-2');\ncom.rclass2('col-');\nconsole.log(com.hclass('col-1'));  // false\n```\n\n### com.tclass(classes, [state])\n\nType: `method`\n\nSchaltet CSS-Klassen um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Die Klassen. |\n| `state` | `Boolean` | no |  | Erzwingt den Zustand. |\n\nReturns: `Component` Die Instanz.\n\nExample: tclass() verwenden\n```js\nvar com = FIND('demo');\ncom.tclass('active', true);\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.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` Das Ergebnis.\n\nExample: hclass() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.hclass('missing'));  // false\n```\n\n### com.attr(name, [value])\n\nType: `method`\n\nLiest oder schreibt ein Attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Attribut. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String|Component` Der Wert oder, wenn `value` übergeben wird, die Instanz.\n\nExample: attr() verwenden\n```js\nvar com = FIND('demo');\ncom.attr('title', 'Orders');\nconsole.log(com.attr('title'));  // Orders\n```\n\n### com.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 Name ohne das Präfix `data-`. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String|Component` Der Wert oder, wenn `value` übergeben wird, die Instanz.\n\nExample: attrd() verwenden\n```js\nvar com = FIND('demo');\ncom.attrd('id', '5');\nconsole.log(com.attr('data-id'));  // 5\n```\n\n### com.attrd2(name)\n\nType: `method`\n\nLiest ein `data-`-Attribut vom Element oder von seinem nächstgelegenen Elternelement, das es besitzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name ohne das Präfix `data-`. |\n\nReturns: `String` Der Wert.\n\nExample: attrd2() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.attrd2('group'));  // main\n```\n\n### com.css(name, [value])\n\nType: `method`\n\nLiest oder schreibt eine CSS-Eigenschaft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Eigenschaft. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String|Component` Der Wert oder, wenn `value` übergeben wird, die Instanz.\n\nExample: css() verwenden\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\nconsole.log(com.css('display'));  // block\n```\n\n### com.visible([callback])\n\nType: `method`\n\nGibt an, ob das Element sichtbar ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Läuft, wenn das Element sichtbar ist. |\n\nReturns: `Boolean` Die aktuelle Sichtbarkeit.\n\nMit einem Callback läuft die Funktion, sobald das Element sichtbar ist.\n\nExample: visible() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.visible());  // true\n```\n\n### com.width([callback])\n\nType: `method`\n\nGibt die Breite des Elements in Pixeln zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Erhält die Breite. |\n\nReturns: `Number` Die Breite.\n\nMit einem Callback läuft die Funktion, sobald die Breite größer als null ist.\n\nExample: width() verwenden\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('width', '200px');\nconsole.log(com.width());  // 200\n```\n\n### com.height([callback])\n\nType: `method`\n\nGibt die Höhe des Elements in Pixeln zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Erhält die Höhe. |\n\nReturns: `Number` Die Höhe.\n\nMit einem Callback läuft die Funktion, sobald die Höhe größer als null ist.\n\nExample: height() verwenden\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('height', '50px');\nconsole.log(com.height());  // 50\n```\n\n### com.autofocus([selector])\n\nType: `method`\n\nSetzt den Fokus auf das erste sichtbare Feld.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Die Felder. |\n\nReturns: `Component` Die Instanz.\n\nKann kein Feld den Fokus erhalten, versucht es die Methode für kurze Zeit erneut. Auf Mobilgeräten macht sie nichts.\n\nExample: autofocus() verwenden\n```js\nvar com = FIND('demo');\ncom.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### com.faicon(value)\n\nType: `method`\n\nVervollständigt den Namen eines Icons.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Der Name des Icons. |\n\nReturns: `String` Die CSS-Klassen.\n\nEin Name ohne Leerzeichen erhält `DEF.iconprefix`, also `ti ti-`. Die Methode steht auch als `icon()` zur Verfügung.\n\nExample: faicon() verwenden\n```js\nvar com = FIND('demo');\nconsole.log(com.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"init","signature":"self.init = function()","since":"","deprecated":false},{"type":"delegate","name":"done","signature":"self.done = function()","since":"","deprecated":false},{"type":"delegate","name":"released","signature":"self.released = function(hidden)","since":"","deprecated":false},{"type":"delegate","name":"configure","signature":"self.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter","signature":"self.getter(value, [realtime], [nobind])","since":"","deprecated":false},{"type":"delegate","name":"setter2","signature":"self.setter2 = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter2","signature":"self.getter2 = function(value, realtime)","since":"","deprecated":false},{"type":"delegate","name":"state","signature":"self.state = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"state2","signature":"self.state2 = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"validate","signature":"self.validate = function(value, init)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"version","signature":"self.version","since":"","deprecated":false},{"type":"property","name":"id","signature":"self.id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"self.ID","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"type","signature":"self.type","since":"","deprecated":false},{"type":"property","name":"format","signature":"self.format","since":"","deprecated":false},{"type":"property","name":"trim","signature":"self.trim","since":"","deprecated":false},{"type":"property","name":"config","signature":"self.config","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"owner","signature":"self.owner","since":"","deprecated":false},{"type":"property","name":"caller","signature":"self.caller","since":"","deprecated":false},{"type":"property","name":"global","signature":"self.global","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"property","name":"pathscope","signature":"self.pathscope","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"self.plugin","since":"","deprecated":false},{"type":"property","name":"siblings","signature":"self.siblings","since":"","deprecated":false},{"type":"property","name":"removed","signature":"self.removed","since":"","deprecated":false},{"type":"method","name":"get()","signature":"com.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"com.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"com.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"com.inc(value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"com.extend(value, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"com.push(value, [type])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"com.rewrite(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"com.update([type])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"com.refresh([notify], [type])","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"com.notify()","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"com.skip()","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"com.bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"com.reset()","since":"","deprecated":false},{"type":"method","name":"default()","signature":"com.default([reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"com.change([value])","since":"","deprecated":false},{"type":"method","name":"dirty()","signature":"com.dirty([value], [noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"com.isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"com.validate2()","since":"","deprecated":false},{"type":"method","name":"notmodified()","signature":"com.notmodified([fields])","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"com.parser(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"com.formatter(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"parsesource()","signature":"com.parsesource(value)","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"com.reconfigure(value, [callback], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"configdisplay()","signature":"com.configdisplay(key, value)","since":"","deprecated":false},{"type":"method","name":"data()","signature":"com.data(key, [value])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"com.datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"com.watch([path], callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"com.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"on()","signature":"com.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"com.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"com.emit(name, [...args])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"com.command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"com.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"com.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"com.GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"com.SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"com.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"com.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"com.makepath(path)","since":"","deprecated":false},{"type":"method","name":"scopepath()","signature":"com.scopepath(path)","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"com.setPath(path)","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"com.blind()","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"self.readonly()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"self.singleton()","since":"","deprecated":false},{"type":"method","name":"bindchanges()","signature":"self.bindchanges([enable])","since":"","deprecated":false},{"type":"method","name":"bindexact()","signature":"self.bindexact([enable])","since":"","deprecated":false},{"type":"method","name":"bindvisible()","signature":"self.bindvisible([timeout])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"self.autofill([enable])","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"com.caniuse(name)","since":"","deprecated":false},{"type":"method","name":"main()","signature":"com.main()","since":"","deprecated":false},{"type":"method","name":"compile()","signature":"com.compile([container])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"com.import(url, [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"com.replace(element, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"com.remove([noclear])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"com.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"com.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"com.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"com.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"com.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"com.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"com.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"com.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"com.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"com.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"com.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"com.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"com.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"com.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"com.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"com.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"com.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"com.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"com.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"com.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"com.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"com.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUh2gM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Component","summary":"Los delegates, las propiedades y los métodos de una instancia de componente.","markdown":"---\ntitle: Component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Component\n\n> Los delegates, las propiedades y los métodos de una instancia de componente.\n\nUna instancia de componente es el objeto que se pasa a la declaración de `COMPONENT()`. Conecta un elemento con un path del modelo de datos. En [Crear componentes](../../guides/creating-components/) se explica cómo escribir uno, y en [ui-component](../ui-component/) se describe el elemento. En los ejemplos, `com` es una instancia encontrada con `FIND()`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nConstruye el contenido del componente.\n\nEl delegate se ejecuta una sola vez, después de la declaración, cuando el elemento está en el DOM.\n\nExample: Definir make\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.html('<b>Ready</b>');\n        };\n    });\n</script>\n```\n\n### self.init = function()\n\nType: `delegate`\n\nSe ejecuta una sola vez para todas las instancias del componente.\n\nSolo la primera instancia de la página llama a este delegate.\n\nExample: Definir init\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.init = () => console.log('once');  // once\n    });\n</script>\n```\n\n### self.done = function()\n\nType: `delegate`\n\nSe ejecuta después de inicializar la instancia.\n\nEl delegate se ejecuta después de las primeras llamadas a `setter` y `state`.\n\nExample: Definir done\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.done = () => console.log('done');  // done\n    });\n</script>\n```\n\n### self.released = function(hidden)\n\nType: `delegate`\n\nIndica si el elemento está oculto cuando arranca la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `hidden` | `Boolean` | yes |  | `true` cuando el elemento está oculto. |\n\nEl delegate se ejecuta una sola vez y recibe `true` si el elemento está oculto.\n\nExample: Definir released\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.released = hidden => console.log(hidden);  // false\n    });\n</script>\n```\n\n### self.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nRecibe las claves de configuración.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre de la clave. |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `init` | `Boolean` | yes |  | `true` durante la inicialización. |\n| `prev` | `Object` | yes |  | El valor anterior. |\n\nEl delegate se ejecuta para cada clave durante la inicialización, con `init` a `true`, y de nuevo para cada clave que cambia. También recibe los cambios de las claves `modified`, `touched` e `invalid`.\n\nExample: Definir configure\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = function(key, value, init, prev) {\n            key === 'title' && console.log(value, init);  // Orders true\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nRecibe el valor del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor del path. |\n| `path` | `String` | yes |  | El path que ha cambiado. |\n| `type` | `Number` | yes |  | El origen del cambio. |\n\nDefínelo para renderizar el valor. La implementación predeterminada escribe el valor formateado en los campos anidados `input`, `select` y `textarea` que tienen el atributo `data-jc-bind`.\n\nEl argumento `type` indica de dónde viene el cambio:\n\n| Tipo | Origen |\n| --- | --- |\n| `0` | La inicialización. |\n| `1` | Un cambio manual, como `SET()`. |\n| `2` | Una entrada del usuario. |\n| `3` | Un valor predeterminado o un restablecimiento. |\n\nExample: Definir setter\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value, path, type) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter(value, [realtime], [nobind])\n\nType: `delegate`\n\nEscribe en el path un valor procedente del usuario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor sin procesar. |\n| `realtime` | `Boolean` | no |  | `true` cuando el valor llega mientras el usuario teclea. |\n| `nobind` | `Boolean` | no |  | `true` valida el valor sin escribirlo. |\n\nLa implementación predeterminada ejecuta los parsers y escribe el resultado. Los campos anidados con el atributo `data-jc-bind` lo llaman automáticamente. Llámalo desde tus propios controles para escribir un valor.\n\nExample: Definir getter\n```html\n<ui-component name=\"box\" path=\"form.name\"><button>Set</button></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.event('click', 'button', () => self.getter('Peter'));\n        };\n    });\n    setTimeout(function() {\n        $('button').click();\n        console.log(GET('form.name'));  // Peter\n    }, 500);\n</script>\n```\n\n### self.setter2 = function(value, path, type)\n\nType: `delegate`\n\nSe ejecuta después del delegate `setter`.\n\nRecibe los mismos argumentos. Úsalo para ampliar un componente conservando su setter.\n\nExample: Definir setter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter2 = value => value && console.log(value);  // Peter\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter2 = function(value, realtime)\n\nType: `delegate`\n\nSe ejecuta cuando el `getter` recibe un valor.\n\nRecibe el valor analizado y el argumento `realtime`.\n\nExample: Definir getter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.getter2 = value => console.log(value);  // PETER\n        self.parser((path, value) => value.toUpperCase());\n    });\n    setTimeout(() => FIND('box').getter('peter'), 500);\n</script>\n```\n\n### self.state = function(type, what)\n\nType: `delegate`\n\nSe ejecuta cuando cambia el estado de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | yes |  | El origen del cambio. |\n| `what` | `Number` | yes |  | El tipo de cambio. |\n\nEl argumento `type` es `0` para la inicialización, `1` para un cambio manual y `2` para una entrada del usuario.\n\nEl argumento `what` indica qué ha ocurrido:\n\n| What | Significado |\n| --- | --- |\n| `1` | Validación. |\n| `2` | Ha cambiado el estado tocado. |\n| `3` | Un restablecimiento. |\n| `4` | Una actualización. |\n| `5` | Un valor nuevo. |\n| `6` | Una notificación. |\n\nExample: Definir state\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state = function(type, what) {\n            console.log(type, what);  // 0 3\n        };\n    });\n</script>\n```\n\n### self.state2 = function(type, what)\n\nType: `delegate`\n\nSe ejecuta después del delegate `state`.\n\nRecibe los mismos argumentos.\n\nExample: Definir state2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state2 = (type, what) => console.log(type, what);  // 0 3\n    });\n</script>\n```\n\n### self.validate = function(value, init)\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 del path. |\n| `init` | `Boolean` | no |  | `true` durante la inicialización. |\n\nDevuelve `true` si el valor es válido. El resultado se guarda en `config.invalid`.\n\nExample: Definir validate\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        self.validate = value => !!value;\n        self.done = () => console.log(config.invalid);  // true\n    });\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nSe ejecuta una vez por minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | El número de ejecuciones. |\n\nEl delegate recibe un contador que aumenta en uno en cada ejecución.\n\n### self.destroy = function()\n\nType: `delegate`\n\nSe ejecuta cuando se elimina la instancia.\n\nLibera aquí los temporizadores y los listeners externos.\n\nExample: Definir destroy\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => FIND('box').remove(), 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nEl nombre del componente, con su versión.\n\nExample: Leer name\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.name));  // box@2\n</script>\n```\n\n### self.version\n\nType: `property`\n\nLa versión indicada en el nombre del componente.\n\nEl valor está vacío cuando el nombre no tiene versión. El elemento también recibe la clase `jc-v{version}`.\n\nExample: Leer version\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.version));  // 2\n</script>\n```\n\n### self.id\n\nType: `property`\n\nEl identificador de la instancia.\n\nLo define la clave de configuración [`$id`](../ui-component/#x-id). En caso contrario, tiene el mismo valor que `ID`.\n\nExample: Leer id\n```html\n<ui-component name=\"box\" config=\"$id:orders\"></ui-component>\n<script>\n    COMPONENT('box', self => self.make = () => console.log(self.id));  // orders\n</script>\n```\n\n### self.ID\n\nType: `property`\n\nEl identificador único generado de la instancia.\n\nExample: Leer ID\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.ID.substring(0, 2)));  // jc\n</script>\n```\n\n### self.path\n\nType: `property`\n\nEl path del modelo de datos enlazado a la instancia.\n\nEl valor está vacío cuando el componente no tiene path.\n\nExample: Leer path\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.path));  // form.name\n</script>\n```\n\n### self.type\n\nType: `property`\n\nEl tipo de datos de la instancia.\n\nEl valor se pasa a los parsers y formatters. Defínelo en la declaración o con la clave [`$type`](../ui-component/#x-type).\n\nExample: Leer type\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.type = 'number';\n        self.parser((path, value, type) => console.log(type));  // number\n        self.make = () => self.parser('1');\n    });\n</script>\n```\n\n### self.format\n\nType: `property`\n\nEl formato que se pasa a los parsers y formatters.\n\nCuando la propiedad está vacía, se usa `config.format`.\n\nExample: Leer format\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.format = 'dd.MM.yyyy';\n        self.formatter((path, value, type, format) => console.log(format));  // dd.MM.yyyy\n        self.make = () => self.formatter('1');\n    });\n</script>\n```\n\n### self.trim\n\nType: `property`\n\nElimina los espacios alrededor del texto en el parser.\n\nEl valor predeterminado es `true`.\n\nExample: Leer trim\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.trim = false;\n        self.make = () => console.log(self.parser('  A  ').length);  // 5\n    });\n</script>\n```\n\n### self.config\n\nType: `property`\n\nEl objeto de configuración.\n\nTambién contiene las claves de estado `modified`, `touched`, `invalid` y, cuando está definida, `disabled`.\n\nExample: Leer config\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.config.title, self.config.touched));  // Orders false\n</script>\n```\n\n### self.element\n\nType: `property`\n\nEl elemento de la instancia como objeto de jQuery.\n\nExample: Leer element\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.element.prop('tagName')));  // UI-COMPONENT\n</script>\n```\n\n### self.dom\n\nType: `property`\n\nEl elemento de la instancia como nodo del DOM.\n\nExample: Leer dom\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.dom.tagName));  // UI-COMPONENT\n</script>\n```\n\n### self.owner\n\nType: `property`\n\nEl componente padre más cercano.\n\nLa propiedad no existe cuando el componente no tiene un componente padre.\n\nExample: Leer owner\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', self => console.log(self.owner.name));  // parent\n</script>\n```\n\n### self.caller\n\nType: `property`\n\nEl componente que ha llamado a esta instancia mediante `exec()`.\n\nExample: Leer caller\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', function(self) {\n        self.ping = () => console.log(self.caller.name);  // parent\n    });\n    setTimeout(() => FIND('parent').exec('ping'), 500);\n</script>\n```\n\n### self.global\n\nType: `property`\n\nUn objeto compartido por todas las instancias del componente.\n\nExample: Leer global\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.global.count = (self.global.count || 0) + 1;\n    });\n    setTimeout(() => console.log(FIND('box').global.count), 500);  // 2\n</script>\n```\n\n### self.scope\n\nType: `property`\n\nEl [Scope](../scope/) de la instancia.\n\nLa propiedad existe cuando el path contiene `?`.\n\nExample: Leer scope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.scope.path));  // users\n</script>\n```\n\n### self.pathscope\n\nType: `property`\n\nEl path del scope de la instancia.\n\nLa propiedad existe cuando el path contiene `?`.\n\nExample: Leer pathscope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.pathscope));  // users\n</script>\n```\n\n### self.plugin\n\nType: `property`\n\nEl [Plugin](../plugin/) del scope de la instancia.\n\nLa propiedad existe cuando el path contiene `?`.\n\nExample: Leer plugin\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.plugin.name));  // users\n</script>\n```\n\n### self.siblings\n\nType: `property`\n\nIndica si el elemento aloja varios componentes.\n\nExample: Leer siblings\n```html\n<ui-component name=\"a,b\"></ui-component>\n<script>\n    COMPONENT('a', self => console.log(self.siblings));  // true\n    COMPONENT('b', function(self) {});\n</script>\n```\n\n### self.removed\n\nType: `property`\n\nIndica si la instancia se ha eliminado.\n\nExample: Leer removed\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var com = FIND('box');\n        com.remove();\n        console.log(com.removed);  // true\n    }, 500);\n</script>\n```\n\n### com.get([path])\n\nType: `method`\n\nDevuelve el valor del path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Otro path. |\n\nReturns: `Object` El valor.\n\nCon un argumento, el método lee otro path.\n\nExample: Usar get()\n```js\nvar com = FIND('demo');\nSET('form.name', 'Peter');\nconsole.log(com.get());  // Peter\n```\n\n### com.set(value, [type])\n\nType: `method`\n\nEscribe un valor en el path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `type` | `Number` | no |  | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nLa instancia se marca como modificada.\n\nExample: Usar set()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(GET('form.name'), com.config.modified);  // Peter true\n```\n\n### com.modify(value, [type])\n\nType: `method`\n\nEscribe un valor a través de los parsers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor sin procesar. |\n| `type` | `Number` | no | `2` | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nLa instancia se marca como tocada.\n\nExample: Usar modify()\n```js\nvar com = FIND('demo');\ncom.modify('  Peter  ');\nconsole.log(GET('form.name'), com.config.touched);  // Peter true\n```\n\n### com.inc(value, [type])\n\nType: `method`\n\nIncrementa el número guardado en el path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number` | yes |  | El incremento. |\n| `type` | `Number` | no |  | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nExample: Usar inc()\n```js\nvar com = FIND('demo');\ncom.set(5);\ncom.inc(2);\nconsole.log(GET('form.name'));  // 7\n```\n\n### com.extend(value, [type])\n\nType: `method`\n\nCombina un objeto en el path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Los campos que se fusionan. |\n| `type` | `Number` | no |  | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nExample: Usar extend()\n```js\nvar com = FIND('demo');\ncom.set({ a: 1 });\ncom.extend({ b: 2 });\nconsole.log(GET('form.name'));  // {\"a\":1,\"b\":2}\n```\n\n### com.push(value, [type])\n\nType: `method`\n\nAñade un ítem al array guardado en el path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El elemento. |\n| `type` | `Number` | no |  | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nExample: Usar push()\n```js\nvar com = FIND('demo');\ncom.push('A');\ncom.push('B');\nconsole.log(GET('form.name'));  // [\"A\",\"B\"]\n```\n\n### com.rewrite(value, [type])\n\nType: `method`\n\nEscribe un valor sin notificar a nadie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `type` | `Number` | no |  | El tipo del cambio. |\n\nReturns: `Component` La instancia.\n\nNo se llama a los componentes enlazados, los binders ni los observadores.\n\nExample: Usar rewrite()\n```js\nvar com = FIND('demo');\ncom.rewrite('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### com.update([type])\n\nType: `method`\n\nVuelve a escribir el valor actual.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nSe notifica a todos los listeners del path.\n\nExample: Usar update()\n```js\nvar com = FIND('demo');\ncom.watch(function(path, value) {\n    console.log(value);  // Peter\n});\nwindow.form.name = 'Peter';\ncom.update();\n```\n\n### com.refresh([notify], [type])\n\nType: `method`\n\nLlama al setter de esta instancia con el valor actual.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `notify` | `Boolean` | no |  | `true` notifica a todos los listeners. |\n| `type` | `Number|String` | no |  | El tipo que se pasa al setter. |\n\nReturns: `Component` La instancia.\n\nCon `notify`, el valor se escribe en el path y se notifica a todos los listeners.\n\nExample: Usar refresh()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.refresh();\nconsole.log(com.text());  // Peter\n```\n\n### com.notify()\n\nType: `method`\n\nNotifica a los listeners del path enlazado exacto.\n\nReturns: `Component` La instancia.\n\nEl método llama a `NOTIFY()` con el path de la instancia.\n\nExample: Usar notify()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.notify();\nconsole.log(com.text());  // Peter\n```\n\n### com.skip()\n\nType: `method`\n\nOmite la siguiente llamada al setter.\n\nReturns: `Component` La instancia.\n\nExample: Usar skip()\n```js\nvar com = FIND('demo');\ncom.skip();\ncom.set('Peter');\nsetTimeout(() => console.log(com.text() || 'empty'), 500);  // empty\n```\n\n### com.bind(flags, [value])\n\nType: `method`\n\nCambia el estado y, opcionalmente, escribe un valor.\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\nEl argumento `flags` es una lista de palabras separadas por un espacio, una coma o `|`. Un prefijo `@` opcional se ignora.\n\n| Flag | Efecto |\n| --- | --- |\n| `touched`, `touch` | Marca la instancia como tocada. |\n| `modified`, `modify`, `changed`, `change` | Marca la instancia como modificada. |\n| `reset` | Limpia el estado tocado y modificado. |\n| `validate` | Valida el valor. |\n| `setter` | Llama al setter. |\n\nCuando se pasa `value`, se escribe en el path, y el setter de esta instancia solo se ejecuta con el flag `setter`.\n\nExample: Usar bind()\n```js\nvar com = FIND('demo');\ncom.bind('@touched @modified', 'Peter');\nconsole.log(GET('form.name'), com.config.touched, com.config.modified);  // Peter true true\n```\n\n### com.reset()\n\nType: `method`\n\nBorra el estado de tocado y modificado.\n\nReturns: `Component` La instancia.\n\nEl valor se vuelve a validar.\n\nExample: Usar reset()\n```js\nvar com = FIND('demo');\ncom.modify('Peter');\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### com.default([reset])\n\nType: `method`\n\nRestaura el valor predeterminado de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `reset` | `Boolean` | no | `true` | `false` conserva el estado de la instancia. |\n\nReturns: `Component` La instancia.\n\nEl valor predeterminado viene del atributo [`default`](../ui-component/#default).\n\nExample: Usar default()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\ncom.default();\nconsole.log(GET('form.name'));  // Anonymous\n```\n\n### com.change([value])\n\nType: `method`\n\nDefine el estado tocado y modificado de los componentes del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no | `true` | El nuevo estado. |\n\nReturns: `Component` La instancia.\n\nEl método se aplica a todos los componentes enlazados al path y a sus paths anidados. El método también está disponible como `touched()`.\n\nExample: Usar change()\n```js\nvar com = FIND('demo');\ncom.change();\nconsole.log(com.config.touched, com.config.modified);  // true true\n```\n\n### com.dirty([value], [noemit])\n\nType: `method`\n\nLee o define el estado sin tocar.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no |  | `false` marca la instancia como tocada. |\n| `noemit` | `Boolean` | no |  | `true` omite el delegate `state`. |\n\nReturns: `Boolean|Component` El estado, o la instancia cuando se pasa `value`.\n\nSin argumentos, el método devuelve `true` si la instancia no está tocada.\n\nExample: Usar dirty()\n```js\nvar com = FIND('demo');\nconsole.log(com.dirty());  // true\ncom.dirty(false);\nconsole.log(com.config.touched);  // true\n```\n\n### com.isInvalid()\n\nType: `method`\n\nIndica si la instancia está tocada y es inválida.\n\nReturns: `Boolean` El resultado.\n\nExample: Usar isInvalid()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\ncom.modify('');\ncom.validate2();\ncom.bind('touched');\nconsole.log(com.isInvalid());  // true\n```\n\n### com.validate2()\n\nType: `method`\n\nEjecuta el delegate `validate` y actualiza el estado.\n\nReturns: `Boolean` `true` si el valor es válido.\n\nExample: Usar validate2()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\nconsole.log(com.validate2());  // false\n```\n\n### com.notmodified([fields])\n\nType: `method`\n\nIndica si el valor es el mismo que en la última comprobación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fields` | `String|Array` | no |  | Los campos que se comparan. |\n\nReturns: `Boolean` `true` cuando el valor no ha cambiado.\n\nLa primera comprobación devuelve `false`.\n\nExample: Usar notmodified()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(com.notmodified());  // false\nconsole.log(com.notmodified());  // true\n```\n\n### com.parser(value, [prepend])\n\nType: `method`\n\nAñade un parser o analiza un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Un parser o el valor que se va a analizar. |\n| `prepend` | `Boolean` | no |  | `true` añade el parser al principio. |\n\nReturns: `Object` El valor analizado, o la instancia cuando se añade un parser.\n\nUna función se añade a los parsers de la instancia. Recibe `path`, `value`, `type` y `format`, y devuelve el nuevo valor. Cualquier otro argumento se analiza y se devuelve.\n\nExample: Usar parser()\n```js\nvar com = FIND('demo');\ncom.parser((path, value) => value.toUpperCase());\nconsole.log(com.parser('peter'));  // PETER\n```\n\n### com.formatter(value, [prepend])\n\nType: `method`\n\nAñade un formatter o da formato a un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Un formatter o el valor al que se va a dar formato. |\n| `prepend` | `Boolean` | no |  | `true` añade el formatter al principio. |\n\nReturns: `Object` El valor formateado, o la instancia cuando se añade un formatter.\n\nUna función se añade a los formatters de la instancia. Recibe `path`, `value`, `type` y `format`, y devuelve el nuevo valor. Cualquier otro argumento se formatea y se devuelve.\n\nExample: Usar formatter()\n```js\nvar com = FIND('demo');\ncom.formatter((path, value) => value + '!');\nconsole.log(com.formatter('Peter'));  // Peter!\n```\n\n### com.parsesource(value)\n\nType: `method`\n\nConvierte una lista de texto en un array de ítems.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La lista. |\n\nReturns: `Array` Objetos con `id`, `name` e `icon`.\n\nLos ítems se separan con una coma. Cada ítem tiene la forma `id|name|icon`. Cuando la instancia tiene el tipo `number`, los identificadores se convierten a números.\n\nExample: Usar parsesource()\n```js\nvar com = FIND('demo');\nconsole.log(com.parsesource('1|One,2|Two|home')[1]);  // {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n\n### com.reconfigure(value, [callback], [init], [noemit])\n\nType: `method`\n\nCambia la configuración.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | La configuración. |\n| `callback` | `Function` | no |  | Recibe `key`, `value`, `init` y `prev` en lugar del delegate `configure`. |\n| `init` | `Boolean` | no |  | El argumento `init` del delegate. |\n| `noemit` | `Boolean` | no |  | `true` omite el delegate. |\n\nReturns: `Component` La instancia.\n\nEl valor puede ser una cadena de pares `key:value`, un objeto o `=path` para leer un objeto desde un path. El delegate `configure` recibe cada clave.\n\nExample: Usar reconfigure()\n```js\nvar com = FIND('demo');\ncom.reconfigure('title:Orders;limit:10');\nconsole.log(com.config.title, com.config.limit);  // Orders 10\n```\n\n### com.configdisplay(key, value)\n\nType: `method`\n\nResuelve un valor que depende de la pantalla.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre de la clave. |\n| `value` | `Object` | yes |  | El valor. |\n\nReturns: `Object` El valor resuelto.\n\nEl valor tiene la forma `@xs=1,@md=2`. Los demás valores se devuelven sin cambios. Consulta [Configuración responsive](../ui-component/#responsive-configuration).\n\nExample: Usar configdisplay()\n```js\nvar com = FIND('demo');\nconsole.log(com.configdisplay('size', '@xs=1,@lg=4'), WIDTH());  // 1 xs\n```\n\n### com.data(key, [value])\n\nType: `method`\n\nLee o escribe datos de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre de la clave. |\n| `value` | `Object` | no |  | El valor que se va a escribir. |\n\nReturns: `Object` El valor.\n\nLos elementos anidados leen las claves con el path `@key`. Una clave vacía es el valor actual de la instancia.\n\nExample: Usar data()\n```js\nvar com = FIND('demo');\ncom.data('title', 'Orders');\nconsole.log(com.data('title'));  // Orders\n```\n\n### com.datasource(path, callback, [init])\n\nType: `method`\n\nObserva un path que contiene una fuente de datos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path de la fuente de datos. |\n| `callback` | `Function` | yes |  | La función que recibe los datos. |\n| `init` | `Boolean` | no | `true` | `false` omite la llamada inicial. |\n\nReturns: `Component` La instancia.\n\nEl callback recibe `path`, `value` y `type`. Salvo que `init` sea `false`, también se ejecuta después de cargar la configuración. Una nueva llamada sustituye la fuente de datos anterior.\n\nExample: Usar datasource()\n```js\nvar com = FIND('demo');\ncom.datasource('common.items', function(path, value) {\n    console.log(value);  // [1,2]\n}, false);\nSET('common.items', [1, 2]);\n```\n\n### com.watch([path], callback, [init])\n\nType: `method`\n\nObserva un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path que se observa. |\n| `callback` | `Function` | yes |  | La función que recibe los cambios. |\n| `init` | `Boolean` | no |  | `true` llama al callback de inmediato. |\n\nReturns: `Component` La instancia.\n\nEl callback recibe `path`, `value` y `type`, y `this` es la instancia. Sin path, el método observa el path de la instancia. El observador se elimina junto con la instancia.\n\nExample: Usar watch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', function(path, value) {\n    console.log(path, value);  // form.age 30\n});\nSET('form.age', 30);\n```\n\n### com.unwatch(path)\n\nType: `method`\n\nElimina los observadores de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path observado. |\n\nReturns: `Component` La instancia.\n\nEl método elimina todos los observadores que esta instancia tiene en el path.\n\nExample: Usar unwatch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', () => console.log('called'));\ncom.unwatch('form.age');\nSET('form.age', 30);\nconsole.log('end');  // end\n```\n\n### com.on(name, callback)\n\nType: `method`\n\nEscucha un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | yes |  | El listener. |\n\nReturns: `Component` La instancia.\n\nEl listener se elimina junto con la instancia. Un prefijo `^` en el nombre coloca el listener en primer lugar.\n\nExample: Usar on()\n```js\nvar com = FIND('demo');\ncom.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### com.off(name, [callback])\n\nType: `method`\n\nElimina un listener 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 listener. |\n\nReturns: `Component` La instancia.\n\nSin callback, se eliminan todos los listeners del evento en esta instancia.\n\nExample: Usar off()\n```js\nvar com = FIND('demo');\nvar fn = () => console.log('called');\ncom.on('saved', fn);\ncom.off('saved', fn);\nconsole.log(EMIT('saved'));  // false\n```\n\n### com.emit(name, [...args])\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| `args` | `Object` | no |  | Los argumentos del evento. |\n\nReturns: `Component` La instancia.\n\nEl método llama a `EMIT()`.\n\nExample: Usar emit()\n```js\nvar com = FIND('demo');\nON('saved', value => console.log(value));  // 5\ncom.emit('saved', 5);\n```\n\n### com.command(name, callback)\n\nType: `method`\n\nRegistra un comando de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nReturns: `Component` La instancia.\n\nUn prefijo `^` en el nombre coloca el manejador en primer lugar. Los comandos se llaman con [`CMD()`](#cmd) o con el `CMD()` global.\n\nExample: Usar command()\n```js\nvar com = FIND('demo');\ncom.command('clear', () => console.log('cleared'));  // cleared\nCMD('clear');\n```\n\n### com.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nLlama a un comando de esta instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n\nReturns: `Component` La instancia.\n\nEl método admite hasta cinco argumentos.\n\nExample: Usar CMD()\n```js\nvar com = FIND('demo');\ncom.command('add', (a, b) => console.log(a + b));  // 3\ncom.CMD('add', 1, 2);\n```\n\n### com.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nLlama a un método de todos los componentes anidados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del método. |\n\nReturns: `Component` La instancia.\n\nCada componente anidado recibe esta instancia en `caller`.\n\nExample: Usar exec()\n```js\nvar com = FIND('demo');\ncom.exec('ping', 5);\n```\n\n### com.GET(path)\n\nType: `method`\n\nLee un path relativo al scope de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `Object` El valor.\n\nEl carácter `?` se sustituye por el path del scope.\n\nExample: Usar GET()\n```js\nvar com = FIND('demo');\nSET('users.name', 'Peter');\nconsole.log(com.GET('?.name'));  // Peter\n```\n\n### com.SET(path, value)\n\nType: `method`\n\nEscribe un path relativo al scope de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Object` | yes |  | El valor. |\n\nEl carácter `?` se sustituye por el path del scope.\n\nExample: Usar SET()\n```js\nvar com = FIND('demo');\ncom.SET('?.age', 30);\nconsole.log(GET('users.age'));  // 30\n```\n\n### com.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función por su path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path de la función. |\n\nReturns: `Component` La instancia.\n\nEl carácter `?` se sustituye por el path del scope. Un path con el prefijo `@` llama a un método del componente padre.\n\nExample: Usar EXEC()\n```js\nvar com = FIND('child');\ncom.EXEC('@ping', 5);\n```\n\n### com.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función o escribe un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `Component` La instancia.\n\nEl método llama a la función del path. Cuando el path no contiene ninguna función, se escribe en él el primer argumento. El prefijo `@` funciona con el componente padre.\n\nExample: Usar SEEX()\n```js\nvar com = FIND('child');\ncom.SEEX('@title', 'Orders');\nconsole.log(FIND('demo').title);  // Orders\n```\n\n### com.makepath(path)\n\nType: `method`\n\nResuelve un path en el scope de la instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `String` El path resuelto.\n\nExample: Usar makepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.makepath('?.age'));  // users.age\n```\n\n### com.scopepath(path)\n\nType: `method`\n\nSustituye `?` en un path por el path del scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `String` El path resuelto.\n\nUn path sin `?` se devuelve sin cambios.\n\nExample: Usar scopepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.scopepath('?.age'), com.scopepath('form.age'));  // users.age form.age\n```\n\n### com.setPath(path)\n\nType: `method`\n\nCambia el path enlazado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El nuevo path. |\n\nReturns: `Component` La instancia.\n\nExample: Usar setPath()\n```js\nvar com = FIND('demo');\ncom.setPath('form.other');\nSET('form.other', 5);\nconsole.log(com.path, com.get());  // form.other 5\n```\n\n### com.blind()\n\nType: `method`\n\nDesconecta la instancia de su path.\n\nReturns: `Component` La instancia.\n\nExample: Usar blind()\n```js\nvar com = FIND('demo');\ncom.blind();\nSET('form.name', 'Peter');\nconsole.log(com.path, com.text() || 'empty');  // null empty\n```\n\n### self.readonly()\n\nType: `method`\n\nElimina los delegates `setter`, `getter` y `validate`.\n\nReturns: `Component` La instancia.\n\nÚsalo en componentes que solo muestran contenido.\n\nExample: Usar readonly()\n```js\nvar com = FIND('demo');\nconsole.log(com.setter, com.getter);  // null null\n```\n\n### self.singleton()\n\nType: `method`\n\nPermite una sola instancia del componente en la página.\n\nReturns: `Component` La instancia.\n\nLos demás elementos del mismo componente se eliminan.\n\nExample: Usar singleton()\n```js\nconsole.log(FIND('demo', true).length, $('ui-component').length);  // 1 1\n```\n\n### self.bindchanges([enable])\n\nType: `method`\n\nOmite el setter cuando el valor no ha cambiado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` desactiva la función. |\n\nReturns: `Component` La instancia.\n\nExample: Usar bindchanges()\n```js\nSET('form.name', 'A');\nSET('form.name', 'A');\nsetTimeout(() => console.log(window.calls), 500);  // 2\n```\n\n### self.bindexact([enable])\n\nType: `method`\n\nIgnora los cambios de los paths anidados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` desactiva la función. |\n\nReturns: `Component` La instancia.\n\nEl setter se ejecuta solo para el path exacto o sus padres.\n\nExample: Usar bindexact()\n```js\nSET('form.user.name', 'Peter');\nsetTimeout(() => console.log(window.calls), 500);  // 1\n```\n\n### self.bindvisible([timeout])\n\nType: `method`\n\nRetrasa el setter hasta que el elemento sea visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `timeout` | `Number|Boolean` | no | `DEF.delaybinder` | El retardo en milisegundos después de que el elemento se vuelva visible. `false` desactiva la función. |\n\nReturns: `Component` La instancia.\n\nExample: Usar bindvisible()\n```js\nSET('form.name', 'Peter');\nsetTimeout(() => $('#tab').show(), 500);\nsetTimeout(() => console.log($('ui-component').text()), 1500);  // Peter\n```\n\n### self.autofill([enable])\n\nType: `method`\n\nLee los valores que rellena el navegador.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` desactiva la función. |\n\nReturns: `Component` La instancia.\n\nCuando la página está lista, el valor de los campos anidados con el atributo `data-jc-bind` se escribe en el path.\n\nExample: Usar autofill()\n```js\n$('input').val('Peter');\nsetTimeout(() => console.log(GET('form.name')), 1400);  // Peter\n```\n\n### com.caniuse(name)\n\nType: `method`\n\nIndica si un componente está disponible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del componente. |\n\nReturns: `Number` `1` para un componente declarado, `2` para uno lazy y `undefined` para uno desconocido.\n\nExample: Usar caniuse()\n```js\nvar com = FIND('demo');\nconsole.log(com.caniuse('demo'));  // 1\n```\n\n### com.main()\n\nType: `method`\n\nDevuelve el componente padre más cercano.\n\nReturns: `Component` El componente padre o `null`.\n\nExample: Usar main()\n```js\nvar com = FIND('child');\nconsole.log(com.main().name);  // demo\n```\n\n### com.compile([container])\n\nType: `method`\n\nCompila el contenido nuevo del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `jQuery|Element` | no | `the component element` | El elemento que se va a compilar. |\n\nReturns: `Component` La instancia.\n\nLlámalo después de añadir elementos con bindings o componentes.\n\nExample: Usar compile()\n```js\nvar com = FIND('demo');\ncom.append('<div data-bind=\"form.name__text\"></div>');\ncom.compile();\nSET('form.name', 'Peter');\nsetTimeout(() => console.log(com.find('div').text()), 500);  // Peter\n```\n\n### com.import(url, [callback], [insert], [preparator])\n\nType: `method`\n\nImporta contenido en el elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL. |\n| `callback` | `Function` | no |  | Se ejecuta después de la importación. |\n| `insert` | `Boolean` | no |  | El argumento `insert` de `IMPORT()`. |\n| `preparator` | `Function` | no |  | Cambia la respuesta antes de insertarla. |\n\nReturns: `Component` La instancia.\n\nEl método llama a `IMPORT()` con el elemento como destino.\n\nExample: Usar import()\n```js\nvar com = FIND('demo');\ncom.import('/part.html', () => console.log('imported'));  // imported\n```\n\n### com.replace(element, [remove])\n\nType: `method`\n\nMueve la instancia a otro elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | El nuevo elemento. |\n| `remove` | `Boolean` | no |  | `true` elimina el elemento original. |\n\nReturns: `Component` La instancia.\n\nExample: Usar replace()\n```js\nvar com = FIND('demo');\ncom.replace($('#target'), true);\nconsole.log(com.dom.id, $('ui-component').length);  // target 0\n```\n\n### com.remove([noclear])\n\nType: `method`\n\nElimina la instancia y su elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noclear` | `Boolean` | no |  | `true` no inicia la limpieza de inmediato. |\n\nReturns: `Boolean` Siempre `true`.\n\nEl delegate `destroy` se ejecuta durante la limpieza. El método también está disponible como `kill()`.\n\nExample: Usar remove()\n```js\nvar com = FIND('demo');\nconsole.log(com.remove());  // true\n```\n\n### com.find(selector)\n\nType: `method`\n\nBusca elementos anidados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un selector o un objeto de selectores. |\n\nReturns: `jQuery|Object` El resultado.\n\nUn objeto de selectores devuelve un objeto de resultados de jQuery con las mismas claves.\n\nExample: Usar find()\n```js\nvar com = FIND('demo');\nconsole.log(com.find('.label').text());  // Text\n```\n\n### com.closest(selector)\n\nType: `method`\n\nBusca el padre coincidente más cercano.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector. |\n\nReturns: `jQuery` El resultado.\n\nExample: Usar closest()\n```js\nvar com = FIND('demo');\nconsole.log(com.closest('body').length);  // 1\n```\n\n### com.parent([selector])\n\nType: `method`\n\nDevuelve un elemento padre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | El selector. |\n\nReturns: `jQuery` El resultado.\n\nEl argumento puede ser:\n\n| Valor | Resultado |\n| --- | --- |\n| omitido | El padre directo. |\n| Un selector | El elemento coincidente más cercano. |\n| `auto` | El padre más cercano con una altura definida; si no lo hay, `window`. |\n| `window` | `window` como objeto de jQuery. |\n| `document` | El objeto `document`. |\n| `parent` | El padre directo. |\n| `parent2` | El elemento situado dos niveles por encima del padre directo. |\n\nExample: Usar parent()\n```js\nvar com = FIND('demo');\nconsole.log(com.parent().prop('tagName'));  // BODY\n```\n\n### com.html([value])\n\nType: `method`\n\nLee o sustituye el contenido HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | El contenido nuevo. |\n\nReturns: `String|jQuery` El contenido, o el elemento cuando se pasa `value`.\n\nSi es un array, se une.\n\nExample: Usar html()\n```js\nvar com = FIND('demo');\ncom.html('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.text([value])\n\nType: `method`\n\nLee o sustituye el contenido de texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | El contenido nuevo. |\n\nReturns: `String|jQuery` El contenido, o el elemento cuando se pasa `value`.\n\nSi es un array, se une.\n\nExample: Usar text()\n```js\nvar com = FIND('demo');\ncom.text('<b>A</b>');\nconsole.log(com.html());  // &lt;b&gt;A&lt;/b&gt;\n```\n\n### com.append(value)\n\nType: `method`\n\nAñade contenido al final del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | El contenido. |\n\nReturns: `jQuery` El elemento.\n\nSi es un array, se une.\n\nExample: Usar append()\n```js\nvar com = FIND('demo');\ncom.empty();\ncom.append('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.empty()\n\nType: `method`\n\nElimina el contenido del elemento.\n\nReturns: `jQuery` El elemento.\n\nTambién se eliminan los componentes anidados.\n\nExample: Usar empty()\n```js\nvar com = FIND('demo');\ncom.empty();\nconsole.log(com.html() === '');  // true\n```\n\n### com.event(name, [selector], callback)\n\nType: `method`\n\nAsocia un evento de jQuery al elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `selector` | `String` | no |  | El selector delegado. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nReturns: `Component` La instancia.\n\nLos argumentos son los mismos que en el método `on()` de jQuery.\n\nExample: Usar event()\n```js\nvar com = FIND('demo');\ncom.event('click', '.label', () => console.log('clicked'));  // clicked\ncom.find('.label').click();\n```\n\n### com.aclass(classes, [timeout])\n\nType: `method`\n\nAñade clases CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Las clases. |\n| `timeout` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `Component` La instancia.\n\nExample: Usar aclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.rclass([classes], [timeout])\n\nType: `method`\n\nElimina clases CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Las clases. |\n| `timeout` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `Component` La instancia.\n\nSin argumento, se eliminan todas las clases.\n\nExample: Usar rclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\ncom.rclass('active');\nconsole.log(com.hclass('active'));  // false\n```\n\n### com.rclass2(search)\n\nType: `method`\n\nElimina las clases CSS que contienen un texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | El texto o una expresión regular. |\n\nReturns: `Component` La instancia.\n\nExample: Usar rclass2()\n```js\nvar com = FIND('demo');\ncom.aclass('col-1 col-2');\ncom.rclass2('col-');\nconsole.log(com.hclass('col-1'));  // false\n```\n\n### com.tclass(classes, [state])\n\nType: `method`\n\nAlterna clases CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Las clases. |\n| `state` | `Boolean` | no |  | Fuerza el estado. |\n\nReturns: `Component` La instancia.\n\nExample: Usar tclass()\n```js\nvar com = FIND('demo');\ncom.tclass('active', true);\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.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` El resultado.\n\nExample: Usar hclass()\n```js\nvar com = FIND('demo');\nconsole.log(com.hclass('missing'));  // false\n```\n\n### com.attr(name, [value])\n\nType: `method`\n\nLee o escribe un atributo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El atributo. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String|Component` El valor, o la instancia cuando se pasa `value`.\n\nExample: Usar attr()\n```js\nvar com = FIND('demo');\ncom.attr('title', 'Orders');\nconsole.log(com.attr('title'));  // Orders\n```\n\n### com.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 sin el prefijo `data-`. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String|Component` El valor, o la instancia cuando se pasa `value`.\n\nExample: Usar attrd()\n```js\nvar com = FIND('demo');\ncom.attrd('id', '5');\nconsole.log(com.attr('data-id'));  // 5\n```\n\n### com.attrd2(name)\n\nType: `method`\n\nLee un atributo `data-` del elemento o del padre más cercano que lo tenga.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre sin el prefijo `data-`. |\n\nReturns: `String` El valor.\n\nExample: Usar attrd2()\n```js\nvar com = FIND('demo');\nconsole.log(com.attrd2('group'));  // main\n```\n\n### com.css(name, [value])\n\nType: `method`\n\nLee o escribe una propiedad CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La propiedad. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String|Component` El valor, o la instancia cuando se pasa `value`.\n\nExample: Usar css()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\nconsole.log(com.css('display'));  // block\n```\n\n### com.visible([callback])\n\nType: `method`\n\nIndica si el elemento está visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Se ejecuta cuando el elemento es visible. |\n\nReturns: `Boolean` La visibilidad actual.\n\nCon un callback, la función se ejecuta en cuanto el elemento es visible.\n\nExample: Usar visible()\n```js\nvar com = FIND('demo');\nconsole.log(com.visible());  // true\n```\n\n### com.width([callback])\n\nType: `method`\n\nDevuelve el ancho del elemento en píxeles.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Recibe el ancho. |\n\nReturns: `Number` El ancho.\n\nCon un callback, la función se ejecuta en cuanto el ancho es mayor que cero.\n\nExample: Usar width()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('width', '200px');\nconsole.log(com.width());  // 200\n```\n\n### com.height([callback])\n\nType: `method`\n\nDevuelve la altura del elemento en píxeles.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Recibe la altura. |\n\nReturns: `Number` La altura.\n\nCon un callback, la función se ejecuta en cuanto la altura es mayor que cero.\n\nExample: Usar height()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('height', '50px');\nconsole.log(com.height());  // 50\n```\n\n### com.autofocus([selector])\n\nType: `method`\n\nMueve el foco al primer campo visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Los campos. |\n\nReturns: `Component` La instancia.\n\nEl método vuelve a intentarlo durante un breve tiempo cuando ningún campo puede recibir el foco. No hace nada en dispositivos móviles.\n\nExample: Usar autofocus()\n```js\nvar com = FIND('demo');\ncom.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### com.faicon(value)\n\nType: `method`\n\nCompleta el nombre de un icono.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El nombre del icono. |\n\nReturns: `String` Las clases CSS.\n\nUn nombre sin espacios recibe `DEF.iconprefix`, que es `ti ti-`. El método también está disponible como `icon()`.\n\nExample: Usar faicon()\n```js\nvar com = FIND('demo');\nconsole.log(com.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"init","signature":"self.init = function()","since":"","deprecated":false},{"type":"delegate","name":"done","signature":"self.done = function()","since":"","deprecated":false},{"type":"delegate","name":"released","signature":"self.released = function(hidden)","since":"","deprecated":false},{"type":"delegate","name":"configure","signature":"self.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter","signature":"self.getter(value, [realtime], [nobind])","since":"","deprecated":false},{"type":"delegate","name":"setter2","signature":"self.setter2 = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter2","signature":"self.getter2 = function(value, realtime)","since":"","deprecated":false},{"type":"delegate","name":"state","signature":"self.state = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"state2","signature":"self.state2 = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"validate","signature":"self.validate = function(value, init)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"version","signature":"self.version","since":"","deprecated":false},{"type":"property","name":"id","signature":"self.id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"self.ID","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"type","signature":"self.type","since":"","deprecated":false},{"type":"property","name":"format","signature":"self.format","since":"","deprecated":false},{"type":"property","name":"trim","signature":"self.trim","since":"","deprecated":false},{"type":"property","name":"config","signature":"self.config","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"owner","signature":"self.owner","since":"","deprecated":false},{"type":"property","name":"caller","signature":"self.caller","since":"","deprecated":false},{"type":"property","name":"global","signature":"self.global","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"property","name":"pathscope","signature":"self.pathscope","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"self.plugin","since":"","deprecated":false},{"type":"property","name":"siblings","signature":"self.siblings","since":"","deprecated":false},{"type":"property","name":"removed","signature":"self.removed","since":"","deprecated":false},{"type":"method","name":"get()","signature":"com.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"com.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"com.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"com.inc(value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"com.extend(value, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"com.push(value, [type])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"com.rewrite(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"com.update([type])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"com.refresh([notify], [type])","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"com.notify()","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"com.skip()","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"com.bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"com.reset()","since":"","deprecated":false},{"type":"method","name":"default()","signature":"com.default([reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"com.change([value])","since":"","deprecated":false},{"type":"method","name":"dirty()","signature":"com.dirty([value], [noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"com.isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"com.validate2()","since":"","deprecated":false},{"type":"method","name":"notmodified()","signature":"com.notmodified([fields])","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"com.parser(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"com.formatter(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"parsesource()","signature":"com.parsesource(value)","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"com.reconfigure(value, [callback], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"configdisplay()","signature":"com.configdisplay(key, value)","since":"","deprecated":false},{"type":"method","name":"data()","signature":"com.data(key, [value])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"com.datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"com.watch([path], callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"com.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"on()","signature":"com.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"com.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"com.emit(name, [...args])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"com.command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"com.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"com.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"com.GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"com.SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"com.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"com.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"com.makepath(path)","since":"","deprecated":false},{"type":"method","name":"scopepath()","signature":"com.scopepath(path)","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"com.setPath(path)","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"com.blind()","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"self.readonly()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"self.singleton()","since":"","deprecated":false},{"type":"method","name":"bindchanges()","signature":"self.bindchanges([enable])","since":"","deprecated":false},{"type":"method","name":"bindexact()","signature":"self.bindexact([enable])","since":"","deprecated":false},{"type":"method","name":"bindvisible()","signature":"self.bindvisible([timeout])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"self.autofill([enable])","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"com.caniuse(name)","since":"","deprecated":false},{"type":"method","name":"main()","signature":"com.main()","since":"","deprecated":false},{"type":"method","name":"compile()","signature":"com.compile([container])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"com.import(url, [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"com.replace(element, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"com.remove([noclear])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"com.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"com.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"com.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"com.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"com.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"com.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"com.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"com.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"com.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"com.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"com.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"com.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"com.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"com.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"com.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"com.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"com.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"com.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"com.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"com.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"com.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"com.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUh2gM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Component","summary":"Les delegates, les propriétés et les méthodes d'une instance de composant.","markdown":"---\ntitle: Component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Component\n\n> Les delegates, les propriétés et les méthodes d'une instance de composant.\n\nUne instance de composant est l'objet passé à la déclaration de `COMPONENT()`. Elle connecte un élément à un path du modèle de données. [Créer des composants](../../guides/creating-components/) explique comment en écrire un, et [ui-component](../ui-component/) décrit l'élément. Dans les exemples, `com` est une instance trouvée avec `FIND()`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nConstruit le contenu du composant.\n\nLe delegate s'exécute une seule fois, après la déclaration, quand l'élément est dans le DOM.\n\nExample: Définir make\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.html('<b>Ready</b>');\n        };\n    });\n</script>\n```\n\n### self.init = function()\n\nType: `delegate`\n\nS'exécute une seule fois pour toutes les instances du composant.\n\nSeule la première instance de la page appelle ce delegate.\n\nExample: Définir init\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.init = () => console.log('once');  // once\n    });\n</script>\n```\n\n### self.done = function()\n\nType: `delegate`\n\nS'exécute après l'initialisation de l'instance.\n\nLe delegate s'exécute après les premiers appels de `setter` et de `state`.\n\nExample: Définir done\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.done = () => console.log('done');  // done\n    });\n</script>\n```\n\n### self.released = function(hidden)\n\nType: `delegate`\n\nIndique si l'élément est masqué au démarrage de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `hidden` | `Boolean` | yes |  | `true` quand l'élément est masqué. |\n\nLe delegate s'exécute une seule fois et reçoit `true` pour un élément masqué.\n\nExample: Définir released\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.released = hidden => console.log(hidden);  // false\n    });\n</script>\n```\n\n### self.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nReçoit les clés de configuration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom de la clé. |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `init` | `Boolean` | yes |  | `true` pendant l'initialisation. |\n| `prev` | `Object` | yes |  | La valeur précédente. |\n\nLe delegate s'exécute pour chaque clé pendant l'initialisation, avec `init` à `true`, puis de nouveau pour chaque clé modifiée. Il reçoit aussi les modifications des clés `modified`, `touched` et `invalid`.\n\nExample: Définir configure\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = function(key, value, init, prev) {\n            key === 'title' && console.log(value, init);  // Orders true\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nReçoit la valeur du path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur du path. |\n| `path` | `String` | yes |  | Le path qui a changé. |\n| `type` | `Number` | yes |  | La source de la modification. |\n\nDéfinis-le pour effectuer le rendu de la valeur. L'implémentation par défaut écrit la valeur formatée dans les champs imbriqués `input`, `select` et `textarea` dotés de l'attribut `data-jc-bind`.\n\nL'argument `type` indique d'où vient la modification :\n\n| Type | Source |\n| --- | --- |\n| `0` | L'initialisation. |\n| `1` | Une modification manuelle, par exemple `SET()`. |\n| `2` | Une saisie de l'utilisateur. |\n| `3` | Une valeur par défaut ou une réinitialisation. |\n\nExample: Définir setter\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value, path, type) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter(value, [realtime], [nobind])\n\nType: `delegate`\n\nÉcrit dans le path une valeur provenant de l'utilisateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur brute. |\n| `realtime` | `Boolean` | no |  | `true` quand la valeur arrive pendant la saisie de l'utilisateur. |\n| `nobind` | `Boolean` | no |  | `true` valide la valeur sans l'écrire. |\n\nL'implémentation par défaut exécute les parseurs et écrit le résultat. Les champs imbriqués dotés de l'attribut `data-jc-bind` l'appellent automatiquement. Appelle-le depuis tes propres contrôles pour écrire une valeur.\n\nExample: Définir getter\n```html\n<ui-component name=\"box\" path=\"form.name\"><button>Set</button></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.event('click', 'button', () => self.getter('Peter'));\n        };\n    });\n    setTimeout(function() {\n        $('button').click();\n        console.log(GET('form.name'));  // Peter\n    }, 500);\n</script>\n```\n\n### self.setter2 = function(value, path, type)\n\nType: `delegate`\n\nS'exécute après le delegate `setter`.\n\nIl reçoit les mêmes arguments. Utilise-le pour étendre un composant tout en conservant son setter.\n\nExample: Définir setter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter2 = value => value && console.log(value);  // Peter\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter2 = function(value, realtime)\n\nType: `delegate`\n\nS'exécute quand le `getter` reçoit une valeur.\n\nIl reçoit la valeur analysée et l'argument `realtime`.\n\nExample: Définir getter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.getter2 = value => console.log(value);  // PETER\n        self.parser((path, value) => value.toUpperCase());\n    });\n    setTimeout(() => FIND('box').getter('peter'), 500);\n</script>\n```\n\n### self.state = function(type, what)\n\nType: `delegate`\n\nS'exécute quand l'état de l'instance change.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | yes |  | La source de la modification. |\n| `what` | `Number` | yes |  | La nature de la modification. |\n\nL'argument `type` vaut `0` pour l'initialisation, `1` pour une modification manuelle et `2` pour une saisie de l'utilisateur.\n\nL'argument `what` indique ce qui s'est passé :\n\n| What | Signification |\n| --- | --- |\n| `1` | Validation. |\n| `2` | L'état touché a changé. |\n| `3` | Une réinitialisation. |\n| `4` | Une mise à jour. |\n| `5` | Une nouvelle valeur. |\n| `6` | Une notification. |\n\nExample: Définir state\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state = function(type, what) {\n            console.log(type, what);  // 0 3\n        };\n    });\n</script>\n```\n\n### self.state2 = function(type, what)\n\nType: `delegate`\n\nS'exécute après le delegate `state`.\n\nIl reçoit les mêmes arguments.\n\nExample: Définir state2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state2 = (type, what) => console.log(type, what);  // 0 3\n    });\n</script>\n```\n\n### self.validate = function(value, init)\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 du path. |\n| `init` | `Boolean` | no |  | `true` pendant l'initialisation. |\n\nRenvoie `true` pour une valeur valide. Le résultat est stocké dans `config.invalid`.\n\nExample: Définir validate\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        self.validate = value => !!value;\n        self.done = () => console.log(config.invalid);  // true\n    });\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nS'exécute une fois par minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Le nombre d'exécutions. |\n\nLe delegate reçoit un compteur qui augmente de un à chaque exécution.\n\n### self.destroy = function()\n\nType: `delegate`\n\nS'exécute quand l'instance est supprimée.\n\nLibère ici les minuteurs et les écouteurs externes.\n\nExample: Définir destroy\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => FIND('box').remove(), 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nLe nom du composant, avec sa version.\n\nExample: Lire name\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.name));  // box@2\n</script>\n```\n\n### self.version\n\nType: `property`\n\nLa version issue du nom du composant.\n\nLa valeur est vide quand le nom n'a pas de version. L'élément reçoit aussi la classe `jc-v{version}`.\n\nExample: Lire version\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.version));  // 2\n</script>\n```\n\n### self.id\n\nType: `property`\n\nL'identifiant de l'instance.\n\nLa clé de configuration [`$id`](../ui-component/#x-id) le définit. Sinon, il a la même valeur que `ID`.\n\nExample: Lire id\n```html\n<ui-component name=\"box\" config=\"$id:orders\"></ui-component>\n<script>\n    COMPONENT('box', self => self.make = () => console.log(self.id));  // orders\n</script>\n```\n\n### self.ID\n\nType: `property`\n\nL'identifiant unique généré de l'instance.\n\nExample: Lire ID\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.ID.substring(0, 2)));  // jc\n</script>\n```\n\n### self.path\n\nType: `property`\n\nLe path du modèle de données lié à l'instance.\n\nLa valeur est vide quand le composant n'a pas de path.\n\nExample: Lire path\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.path));  // form.name\n</script>\n```\n\n### self.type\n\nType: `property`\n\nLe type de données de l'instance.\n\nLa valeur est passée aux parseurs et aux formateurs. Définis-la dans la déclaration ou avec la clé [`$type`](../ui-component/#x-type).\n\nExample: Lire type\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.type = 'number';\n        self.parser((path, value, type) => console.log(type));  // number\n        self.make = () => self.parser('1');\n    });\n</script>\n```\n\n### self.format\n\nType: `property`\n\nLe format passé aux parseurs et aux formateurs.\n\nQuand la propriété est vide, `config.format` est utilisé.\n\nExample: Lire format\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.format = 'dd.MM.yyyy';\n        self.formatter((path, value, type, format) => console.log(format));  // dd.MM.yyyy\n        self.make = () => self.formatter('1');\n    });\n</script>\n```\n\n### self.trim\n\nType: `property`\n\nSupprime les espaces autour du texte dans le parseur.\n\nLa valeur par défaut est `true`.\n\nExample: Lire trim\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.trim = false;\n        self.make = () => console.log(self.parser('  A  ').length);  // 5\n    });\n</script>\n```\n\n### self.config\n\nType: `property`\n\nL'objet de configuration.\n\nIl contient aussi les clés d'état `modified`, `touched`, `invalid` et, si elle est définie, `disabled`.\n\nExample: Lire config\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.config.title, self.config.touched));  // Orders false\n</script>\n```\n\n### self.element\n\nType: `property`\n\nL'élément de l'instance sous forme d'objet jQuery.\n\nExample: Lire element\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.element.prop('tagName')));  // UI-COMPONENT\n</script>\n```\n\n### self.dom\n\nType: `property`\n\nL'élément de l'instance sous forme de nœud DOM.\n\nExample: Lire dom\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.dom.tagName));  // UI-COMPONENT\n</script>\n```\n\n### self.owner\n\nType: `property`\n\nLe composant parent le plus proche.\n\nLa propriété est absente quand le composant n'a pas de composant parent.\n\nExample: Lire owner\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', self => console.log(self.owner.name));  // parent\n</script>\n```\n\n### self.caller\n\nType: `property`\n\nLe composant qui a appelé cette instance via `exec()`.\n\nExample: Lire caller\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', function(self) {\n        self.ping = () => console.log(self.caller.name);  // parent\n    });\n    setTimeout(() => FIND('parent').exec('ping'), 500);\n</script>\n```\n\n### self.global\n\nType: `property`\n\nUn objet partagé par toutes les instances du composant.\n\nExample: Lire global\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.global.count = (self.global.count || 0) + 1;\n    });\n    setTimeout(() => console.log(FIND('box').global.count), 500);  // 2\n</script>\n```\n\n### self.scope\n\nType: `property`\n\nLe [Scope](../scope/) de l'instance.\n\nLa propriété existe quand le path contient `?`.\n\nExample: Lire scope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.scope.path));  // users\n</script>\n```\n\n### self.pathscope\n\nType: `property`\n\nLe path du scope de l'instance.\n\nLa propriété existe quand le path contient `?`.\n\nExample: Lire pathscope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.pathscope));  // users\n</script>\n```\n\n### self.plugin\n\nType: `property`\n\nLe [Plugin](../plugin/) du scope de l'instance.\n\nLa propriété existe quand le path contient `?`.\n\nExample: Lire plugin\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.plugin.name));  // users\n</script>\n```\n\n### self.siblings\n\nType: `property`\n\nIndique si l'élément héberge plusieurs composants.\n\nExample: Lire siblings\n```html\n<ui-component name=\"a,b\"></ui-component>\n<script>\n    COMPONENT('a', self => console.log(self.siblings));  // true\n    COMPONENT('b', function(self) {});\n</script>\n```\n\n### self.removed\n\nType: `property`\n\nIndique si l'instance a été supprimée.\n\nExample: Lire removed\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var com = FIND('box');\n        com.remove();\n        console.log(com.removed);  // true\n    }, 500);\n</script>\n```\n\n### com.get([path])\n\nType: `method`\n\nRenvoie la valeur du path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Un autre path. |\n\nReturns: `Object` La valeur.\n\nAvec un argument, la méthode lit un autre path.\n\nExample: Utiliser get()\n```js\nvar com = FIND('demo');\nSET('form.name', 'Peter');\nconsole.log(com.get());  // Peter\n```\n\n### com.set(value, [type])\n\nType: `method`\n\nÉcrit une valeur dans le path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `type` | `Number` | no |  | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nL'instance est marquée comme modifiée.\n\nExample: Utiliser set()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(GET('form.name'), com.config.modified);  // Peter true\n```\n\n### com.modify(value, [type])\n\nType: `method`\n\nÉcrit une valeur en passant par les parseurs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur brute. |\n| `type` | `Number` | no | `2` | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nL'instance est marquée comme touchée.\n\nExample: Utiliser modify()\n```js\nvar com = FIND('demo');\ncom.modify('  Peter  ');\nconsole.log(GET('form.name'), com.config.touched);  // Peter true\n```\n\n### com.inc(value, [type])\n\nType: `method`\n\nAugmente le nombre stocké dans le path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number` | yes |  | L'incrément. |\n| `type` | `Number` | no |  | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser inc()\n```js\nvar com = FIND('demo');\ncom.set(5);\ncom.inc(2);\nconsole.log(GET('form.name'));  // 7\n```\n\n### com.extend(value, [type])\n\nType: `method`\n\nFusionne un objet dans le path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Les champs à fusionner. |\n| `type` | `Number` | no |  | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser extend()\n```js\nvar com = FIND('demo');\ncom.set({ a: 1 });\ncom.extend({ b: 2 });\nconsole.log(GET('form.name'));  // {\"a\":1,\"b\":2}\n```\n\n### com.push(value, [type])\n\nType: `method`\n\nAjoute un élément au tableau stocké dans le path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | L'élément. |\n| `type` | `Number` | no |  | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser push()\n```js\nvar com = FIND('demo');\ncom.push('A');\ncom.push('B');\nconsole.log(GET('form.name'));  // [\"A\",\"B\"]\n```\n\n### com.rewrite(value, [type])\n\nType: `method`\n\nÉcrit une valeur sans notifier personne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `type` | `Number` | no |  | Le type de la modification. |\n\nReturns: `Component` L'instance.\n\nLes composants liés, les binders et les observateurs ne sont pas appelés.\n\nExample: Utiliser rewrite()\n```js\nvar com = FIND('demo');\ncom.rewrite('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### com.update([type])\n\nType: `method`\n\nÉcrit de nouveau la valeur actuelle.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nTous les écouteurs du path sont notifiés.\n\nExample: Utiliser update()\n```js\nvar com = FIND('demo');\ncom.watch(function(path, value) {\n    console.log(value);  // Peter\n});\nwindow.form.name = 'Peter';\ncom.update();\n```\n\n### com.refresh([notify], [type])\n\nType: `method`\n\nAppelle le setter de cette instance avec la valeur actuelle.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `notify` | `Boolean` | no |  | `true` notifie tous les écouteurs. |\n| `type` | `Number|String` | no |  | Le type passé au setter. |\n\nReturns: `Component` L'instance.\n\nAvec `notify`, la valeur est écrite dans le path et tous les écouteurs sont notifiés.\n\nExample: Utiliser refresh()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.refresh();\nconsole.log(com.text());  // Peter\n```\n\n### com.notify()\n\nType: `method`\n\nNotifie les écouteurs du path lié exact.\n\nReturns: `Component` L'instance.\n\nLa méthode appelle `NOTIFY()` avec le path de l'instance.\n\nExample: Utiliser notify()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.notify();\nconsole.log(com.text());  // Peter\n```\n\n### com.skip()\n\nType: `method`\n\nIgnore le prochain appel du setter.\n\nReturns: `Component` L'instance.\n\nExample: Utiliser skip()\n```js\nvar com = FIND('demo');\ncom.skip();\ncom.set('Peter');\nsetTimeout(() => console.log(com.text() || 'empty'), 500);  // empty\n```\n\n### com.bind(flags, [value])\n\nType: `method`\n\nModifie l'état et écrit éventuellement une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Les flags. |\n| `value` | `Object` | no |  | La valeur à écrire. |\n\nL'argument `flags` est une liste de mots séparés par un espace, une virgule ou `|`. Un préfixe `@` facultatif est ignoré.\n\n| Flag | Effet |\n| --- | --- |\n| `touched`, `touch` | Marque l'instance comme touchée. |\n| `modified`, `modify`, `changed`, `change` | Marque l'instance comme modifiée. |\n| `reset` | Efface l'état touché et modifié. |\n| `validate` | Valide la valeur. |\n| `setter` | Appelle le setter. |\n\nQuand `value` est passé, il est écrit dans le path, et le setter de cette instance ne s'exécute qu'avec le flag `setter`.\n\nExample: Utiliser bind()\n```js\nvar com = FIND('demo');\ncom.bind('@touched @modified', 'Peter');\nconsole.log(GET('form.name'), com.config.touched, com.config.modified);  // Peter true true\n```\n\n### com.reset()\n\nType: `method`\n\nEfface l'état touché et modifié.\n\nReturns: `Component` L'instance.\n\nLa valeur est de nouveau validée.\n\nExample: Utiliser reset()\n```js\nvar com = FIND('demo');\ncom.modify('Peter');\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### com.default([reset])\n\nType: `method`\n\nRestaure la valeur par défaut de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `reset` | `Boolean` | no | `true` | `false` conserve l'état de l'instance. |\n\nReturns: `Component` L'instance.\n\nLa valeur par défaut provient de l'attribut [`default`](../ui-component/#default).\n\nExample: Utiliser default()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\ncom.default();\nconsole.log(GET('form.name'));  // Anonymous\n```\n\n### com.change([value])\n\nType: `method`\n\nDéfinit l'état touché et modifié des composants du path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no | `true` | Le nouvel état. |\n\nReturns: `Component` L'instance.\n\nLa méthode s'applique à tous les composants liés au path et à ses paths imbriqués. Elle est aussi disponible sous le nom `touched()`.\n\nExample: Utiliser change()\n```js\nvar com = FIND('demo');\ncom.change();\nconsole.log(com.config.touched, com.config.modified);  // true true\n```\n\n### com.dirty([value], [noemit])\n\nType: `method`\n\nLit ou définit l'état non touché.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no |  | `false` marque l'instance comme touchée. |\n| `noemit` | `Boolean` | no |  | `true` ignore le delegate `state`. |\n\nReturns: `Boolean|Component` L'état, ou l'instance quand `value` est passé.\n\nSans argument, la méthode renvoie `true` pour une instance non touchée.\n\nExample: Utiliser dirty()\n```js\nvar com = FIND('demo');\nconsole.log(com.dirty());  // true\ncom.dirty(false);\nconsole.log(com.config.touched);  // true\n```\n\n### com.isInvalid()\n\nType: `method`\n\nIndique si l'instance est touchée et invalide.\n\nReturns: `Boolean` Le résultat.\n\nExample: Utiliser isInvalid()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\ncom.modify('');\ncom.validate2();\ncom.bind('touched');\nconsole.log(com.isInvalid());  // true\n```\n\n### com.validate2()\n\nType: `method`\n\nExécute le delegate `validate` et met à jour l'état.\n\nReturns: `Boolean` `true` pour une valeur valide.\n\nExample: Utiliser validate2()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\nconsole.log(com.validate2());  // false\n```\n\n### com.notmodified([fields])\n\nType: `method`\n\nIndique si la valeur est la même que lors de la dernière vérification.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fields` | `String|Array` | no |  | Les champs à comparer. |\n\nReturns: `Boolean` `true` quand la valeur n'a pas changé.\n\nLa première vérification renvoie `false`.\n\nExample: Utiliser notmodified()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(com.notmodified());  // false\nconsole.log(com.notmodified());  // true\n```\n\n### com.parser(value, [prepend])\n\nType: `method`\n\nAjoute un parseur ou analyse une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Un parseur ou la valeur à analyser. |\n| `prepend` | `Boolean` | no |  | `true` ajoute le parseur au début. |\n\nReturns: `Object` La valeur analysée, ou l'instance quand un parseur est ajouté.\n\nUne fonction est ajoutée aux parseurs de l'instance. Elle reçoit `path`, `value`, `type` et `format`, et renvoie la nouvelle valeur. Tout autre argument est analysé et renvoyé.\n\nExample: Utiliser parser()\n```js\nvar com = FIND('demo');\ncom.parser((path, value) => value.toUpperCase());\nconsole.log(com.parser('peter'));  // PETER\n```\n\n### com.formatter(value, [prepend])\n\nType: `method`\n\nAjoute un formateur ou formate une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Un formateur ou la valeur à formater. |\n| `prepend` | `Boolean` | no |  | `true` ajoute le formateur au début. |\n\nReturns: `Object` La valeur formatée, ou l'instance quand un formateur est ajouté.\n\nUne fonction est ajoutée aux formateurs de l'instance. Elle reçoit `path`, `value`, `type` et `format`, et renvoie la nouvelle valeur. Tout autre argument est formaté et renvoyé.\n\nExample: Utiliser formatter()\n```js\nvar com = FIND('demo');\ncom.formatter((path, value) => value + '!');\nconsole.log(com.formatter('Peter'));  // Peter!\n```\n\n### com.parsesource(value)\n\nType: `method`\n\nConvertit une liste textuelle en tableau d'éléments.\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\nLes éléments sont séparés par une virgule. Chaque élément a la forme `id|name|icon`. Quand l'instance a le type `number`, les identifiants sont convertis en nombres.\n\nExample: Utiliser parsesource()\n```js\nvar com = FIND('demo');\nconsole.log(com.parsesource('1|One,2|Two|home')[1]);  // {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n\n### com.reconfigure(value, [callback], [init], [noemit])\n\nType: `method`\n\nModifie la configuration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | La configuration. |\n| `callback` | `Function` | no |  | Reçoit `key`, `value`, `init` et `prev` à la place du delegate `configure`. |\n| `init` | `Boolean` | no |  | L'argument `init` du delegate. |\n| `noemit` | `Boolean` | no |  | `true` ignore le delegate. |\n\nReturns: `Component` L'instance.\n\nLa valeur peut être une chaîne de paires `key:value`, un objet, ou `=path` pour lire un objet depuis un path. Le delegate `configure` reçoit chaque clé.\n\nExample: Utiliser reconfigure()\n```js\nvar com = FIND('demo');\ncom.reconfigure('title:Orders;limit:10');\nconsole.log(com.config.title, com.config.limit);  // Orders 10\n```\n\n### com.configdisplay(key, value)\n\nType: `method`\n\nRésout une valeur qui dépend de l'affichage.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom de la clé. |\n| `value` | `Object` | yes |  | La valeur. |\n\nReturns: `Object` La valeur résolue.\n\nLa valeur a la forme `@xs=1,@md=2`. Les autres valeurs sont renvoyées telles quelles. Consulte [Configuration responsive](../ui-component/#responsive-configuration).\n\nExample: Utiliser configdisplay()\n```js\nvar com = FIND('demo');\nconsole.log(com.configdisplay('size', '@xs=1,@lg=4'), WIDTH());  // 1 xs\n```\n\n### com.data(key, [value])\n\nType: `method`\n\nLit ou écrit des données de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom de la clé. |\n| `value` | `Object` | no |  | La valeur à écrire. |\n\nReturns: `Object` La valeur.\n\nLes éléments imbriqués lisent les clés avec le path `@key`. Une clé vide correspond à la valeur actuelle de l'instance.\n\nExample: Utiliser data()\n```js\nvar com = FIND('demo');\ncom.data('title', 'Orders');\nconsole.log(com.data('title'));  // Orders\n```\n\n### com.datasource(path, callback, [init])\n\nType: `method`\n\nObserve un path qui contient une source de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la source de données. |\n| `callback` | `Function` | yes |  | La fonction qui reçoit les données. |\n| `init` | `Boolean` | no | `true` | `false` ignore l'appel initial. |\n\nReturns: `Component` L'instance.\n\nLe callback reçoit `path`, `value` et `type`. Sauf si `init` vaut `false`, il s'exécute aussi après le chargement de la configuration. Un nouvel appel remplace la source de données précédente.\n\nExample: Utiliser datasource()\n```js\nvar com = FIND('demo');\ncom.datasource('common.items', function(path, value) {\n    console.log(value);  // [1,2]\n}, false);\nSET('common.items', [1, 2]);\n```\n\n### com.watch([path], callback, [init])\n\nType: `method`\n\nObserve un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path à observer. |\n| `callback` | `Function` | yes |  | La fonction qui reçoit les modifications. |\n| `init` | `Boolean` | no |  | `true` appelle le callback immédiatement. |\n\nReturns: `Component` L'instance.\n\nLe callback reçoit `path`, `value` et `type`, et `this` est l'instance. Sans path, la méthode observe le path de l'instance. L'observateur est supprimé en même temps que l'instance.\n\nExample: Utiliser watch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', function(path, value) {\n    console.log(path, value);  // form.age 30\n});\nSET('form.age', 30);\n```\n\n### com.unwatch(path)\n\nType: `method`\n\nSupprime les observateurs d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path observé. |\n\nReturns: `Component` L'instance.\n\nLa méthode supprime tous les observateurs que cette instance a sur le path.\n\nExample: Utiliser unwatch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', () => console.log('called'));\ncom.unwatch('form.age');\nSET('form.age', 30);\nconsole.log('end');  // end\n```\n\n### com.on(name, callback)\n\nType: `method`\n\nÉcoute 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 |  | L'écouteur. |\n\nReturns: `Component` L'instance.\n\nL'écouteur est supprimé en même temps que l'instance. Un préfixe `^` devant le nom place l'écouteur en première position.\n\nExample: Utiliser on()\n```js\nvar com = FIND('demo');\ncom.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### com.off(name, [callback])\n\nType: `method`\n\nSupprime un écouteur 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 |  | L'écouteur. |\n\nReturns: `Component` L'instance.\n\nSans callback, tous les écouteurs de l'événement dans cette instance sont supprimés.\n\nExample: Utiliser off()\n```js\nvar com = FIND('demo');\nvar fn = () => console.log('called');\ncom.on('saved', fn);\ncom.off('saved', fn);\nconsole.log(EMIT('saved'));  // false\n```\n\n### com.emit(name, [...args])\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| `args` | `Object` | no |  | Les arguments de l'événement. |\n\nReturns: `Component` L'instance.\n\nLa méthode appelle `EMIT()`.\n\nExample: Utiliser emit()\n```js\nvar com = FIND('demo');\nON('saved', value => console.log(value));  // 5\ncom.emit('saved', 5);\n```\n\n### com.command(name, callback)\n\nType: `method`\n\nEnregistre une commande de l'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\nReturns: `Component` L'instance.\n\nUn préfixe `^` devant le nom place le gestionnaire en première position. Les commandes sont appelées par [`CMD()`](#cmd) ou par le `CMD()` global.\n\nExample: Utiliser command()\n```js\nvar com = FIND('demo');\ncom.command('clear', () => console.log('cleared'));  // cleared\nCMD('clear');\n```\n\n### com.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nAppelle une commande de cette instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la commande. |\n\nReturns: `Component` L'instance.\n\nLa méthode accepte jusqu'à cinq arguments.\n\nExample: Utiliser CMD()\n```js\nvar com = FIND('demo');\ncom.command('add', (a, b) => console.log(a + b));  // 3\ncom.CMD('add', 1, 2);\n```\n\n### com.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nAppelle une méthode de tous les composants imbriqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la méthode. |\n\nReturns: `Component` L'instance.\n\nChaque composant imbriqué reçoit cette instance dans `caller`.\n\nExample: Utiliser exec()\n```js\nvar com = FIND('demo');\ncom.exec('ping', 5);\n```\n\n### com.GET(path)\n\nType: `method`\n\nLit un path relatif au scope de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `Object` La valeur.\n\nLe caractère `?` est remplacé par le path du scope.\n\nExample: Utiliser GET()\n```js\nvar com = FIND('demo');\nSET('users.name', 'Peter');\nconsole.log(com.GET('?.name'));  // Peter\n```\n\n### com.SET(path, value)\n\nType: `method`\n\nÉcrit dans un path relatif au scope de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Object` | yes |  | La valeur. |\n\nLe caractère `?` est remplacé par le path du scope.\n\nExample: Utiliser SET()\n```js\nvar com = FIND('demo');\ncom.SET('?.age', 30);\nconsole.log(GET('users.age'));  // 30\n```\n\n### com.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction par son path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la fonction. |\n\nReturns: `Component` L'instance.\n\nLe caractère `?` est remplacé par le path du scope. Un path avec le préfixe `@` appelle une méthode du composant parent.\n\nExample: Utiliser EXEC()\n```js\nvar com = FIND('child');\ncom.EXEC('@ping', 5);\n```\n\n### com.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction ou écrit une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `Component` L'instance.\n\nLa méthode appelle la fonction du path. Quand le path ne contient pas de fonction, le premier argument y est écrit. Le préfixe `@` fonctionne avec le composant parent.\n\nExample: Utiliser SEEX()\n```js\nvar com = FIND('child');\ncom.SEEX('@title', 'Orders');\nconsole.log(FIND('demo').title);  // Orders\n```\n\n### com.makepath(path)\n\nType: `method`\n\nRésout un path dans le scope de l'instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `String` Le path résolu.\n\nExample: Utiliser makepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.makepath('?.age'));  // users.age\n```\n\n### com.scopepath(path)\n\nType: `method`\n\nRemplace `?` dans un path par le path du scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `String` Le path résolu.\n\nUn path sans `?` est renvoyé tel quel.\n\nExample: Utiliser scopepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.scopepath('?.age'), com.scopepath('form.age'));  // users.age form.age\n```\n\n### com.setPath(path)\n\nType: `method`\n\nModifie le path lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le nouveau path. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser setPath()\n```js\nvar com = FIND('demo');\ncom.setPath('form.other');\nSET('form.other', 5);\nconsole.log(com.path, com.get());  // form.other 5\n```\n\n### com.blind()\n\nType: `method`\n\nDéconnecte l'instance de son path.\n\nReturns: `Component` L'instance.\n\nExample: Utiliser blind()\n```js\nvar com = FIND('demo');\ncom.blind();\nSET('form.name', 'Peter');\nconsole.log(com.path, com.text() || 'empty');  // null empty\n```\n\n### self.readonly()\n\nType: `method`\n\nSupprime les delegates `setter`, `getter` et `validate`.\n\nReturns: `Component` L'instance.\n\nUtilise-la dans les composants qui ne font qu'afficher du contenu.\n\nExample: Utiliser readonly()\n```js\nvar com = FIND('demo');\nconsole.log(com.setter, com.getter);  // null null\n```\n\n### self.singleton()\n\nType: `method`\n\nN'autorise qu'une seule instance du composant dans la page.\n\nReturns: `Component` L'instance.\n\nLes autres éléments du même composant sont supprimés.\n\nExample: Utiliser singleton()\n```js\nconsole.log(FIND('demo', true).length, $('ui-component').length);  // 1 1\n```\n\n### self.bindchanges([enable])\n\nType: `method`\n\nIgnore le setter quand la valeur n'a pas changé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` désactive la fonctionnalité. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser bindchanges()\n```js\nSET('form.name', 'A');\nSET('form.name', 'A');\nsetTimeout(() => console.log(window.calls), 500);  // 2\n```\n\n### self.bindexact([enable])\n\nType: `method`\n\nIgnore les modifications des paths imbriqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` désactive la fonctionnalité. |\n\nReturns: `Component` L'instance.\n\nLe setter ne s'exécute que pour le path exact ou ses parents.\n\nExample: Utiliser bindexact()\n```js\nSET('form.user.name', 'Peter');\nsetTimeout(() => console.log(window.calls), 500);  // 1\n```\n\n### self.bindvisible([timeout])\n\nType: `method`\n\nRetarde le setter jusqu'à ce que l'élément soit visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `timeout` | `Number|Boolean` | no | `DEF.delaybinder` | Le délai en millisecondes après que l'élément est devenu visible. `false` désactive la fonctionnalité. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser bindvisible()\n```js\nSET('form.name', 'Peter');\nsetTimeout(() => $('#tab').show(), 500);\nsetTimeout(() => console.log($('ui-component').text()), 1500);  // Peter\n```\n\n### self.autofill([enable])\n\nType: `method`\n\nLit les valeurs remplies par le navigateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` désactive la fonctionnalité. |\n\nReturns: `Component` L'instance.\n\nUne fois la page prête, la valeur des champs imbriqués dotés de l'attribut `data-jc-bind` est écrite dans le path.\n\nExample: Utiliser autofill()\n```js\n$('input').val('Peter');\nsetTimeout(() => console.log(GET('form.name')), 1400);  // Peter\n```\n\n### com.caniuse(name)\n\nType: `method`\n\nIndique si un composant est disponible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du composant. |\n\nReturns: `Number` `1` pour un composant déclaré, `2` pour un composant différé, `undefined` pour un composant inconnu.\n\nExample: Utiliser caniuse()\n```js\nvar com = FIND('demo');\nconsole.log(com.caniuse('demo'));  // 1\n```\n\n### com.main()\n\nType: `method`\n\nRenvoie le composant parent le plus proche.\n\nReturns: `Component` Le composant parent ou `null`.\n\nExample: Utiliser main()\n```js\nvar com = FIND('child');\nconsole.log(com.main().name);  // demo\n```\n\n### com.compile([container])\n\nType: `method`\n\nCompile le nouveau contenu de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `jQuery|Element` | no | `the component element` | L'élément à compiler. |\n\nReturns: `Component` L'instance.\n\nAppelle-la après avoir ajouté des éléments avec des liaisons ou des composants.\n\nExample: Utiliser compile()\n```js\nvar com = FIND('demo');\ncom.append('<div data-bind=\"form.name__text\"></div>');\ncom.compile();\nSET('form.name', 'Peter');\nsetTimeout(() => console.log(com.find('div').text()), 500);  // Peter\n```\n\n### com.import(url, [callback], [insert], [preparator])\n\nType: `method`\n\nImporte du contenu dans l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `callback` | `Function` | no |  | S'exécute après l'importation. |\n| `insert` | `Boolean` | no |  | L'argument `insert` de `IMPORT()`. |\n| `preparator` | `Function` | no |  | Modifie la réponse avant l'insertion. |\n\nReturns: `Component` L'instance.\n\nLa méthode appelle `IMPORT()` avec l'élément comme cible.\n\nExample: Utiliser import()\n```js\nvar com = FIND('demo');\ncom.import('/part.html', () => console.log('imported'));  // imported\n```\n\n### com.replace(element, [remove])\n\nType: `method`\n\nDéplace l'instance vers un autre élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Le nouvel élément. |\n| `remove` | `Boolean` | no |  | `true` supprime l'élément d'origine. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser replace()\n```js\nvar com = FIND('demo');\ncom.replace($('#target'), true);\nconsole.log(com.dom.id, $('ui-component').length);  // target 0\n```\n\n### com.remove([noclear])\n\nType: `method`\n\nSupprime l'instance et son élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noclear` | `Boolean` | no |  | `true` ne lance pas le nettoyage immédiatement. |\n\nReturns: `Boolean` Toujours `true`.\n\nLe delegate `destroy` s'exécute pendant le nettoyage. La méthode est aussi disponible sous le nom `kill()`.\n\nExample: Utiliser remove()\n```js\nvar com = FIND('demo');\nconsole.log(com.remove());  // true\n```\n\n### com.find(selector)\n\nType: `method`\n\nTrouve des éléments imbriqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un sélecteur ou un objet de sélecteurs. |\n\nReturns: `jQuery|Object` Le résultat.\n\nUn objet de sélecteurs renvoie un objet de résultats jQuery avec les mêmes clés.\n\nExample: Utiliser find()\n```js\nvar com = FIND('demo');\nconsole.log(com.find('.label').text());  // Text\n```\n\n### com.closest(selector)\n\nType: `method`\n\nTrouve le parent correspondant le plus proche.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur. |\n\nReturns: `jQuery` Le résultat.\n\nExample: Utiliser closest()\n```js\nvar com = FIND('demo');\nconsole.log(com.closest('body').length);  // 1\n```\n\n### com.parent([selector])\n\nType: `method`\n\nRenvoie un élément parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Le sélecteur. |\n\nReturns: `jQuery` Le résultat.\n\nL'argument peut être :\n\n| Valeur | Résultat |\n| --- | --- |\n| omis | Le parent direct. |\n| Un sélecteur | L'élément correspondant le plus proche. |\n| `auto` | Le parent le plus proche ayant une hauteur définie, sinon `window`. |\n| `window` | `window` sous forme d'objet jQuery. |\n| `document` | L'objet `document`. |\n| `parent` | Le parent direct. |\n| `parent2` | L'élément situé deux niveaux au-dessus du parent direct. |\n\nExample: Utiliser parent()\n```js\nvar com = FIND('demo');\nconsole.log(com.parent().prop('tagName'));  // BODY\n```\n\n### com.html([value])\n\nType: `method`\n\nLit ou remplace le contenu HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Le nouveau contenu. |\n\nReturns: `String|jQuery` Le contenu, ou l'élément quand `value` est passé.\n\nUn tableau est concaténé.\n\nExample: Utiliser html()\n```js\nvar com = FIND('demo');\ncom.html('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.text([value])\n\nType: `method`\n\nLit ou remplace le contenu textuel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Le nouveau contenu. |\n\nReturns: `String|jQuery` Le contenu, ou l'élément quand `value` est passé.\n\nUn tableau est concaténé.\n\nExample: Utiliser text()\n```js\nvar com = FIND('demo');\ncom.text('<b>A</b>');\nconsole.log(com.html());  // &lt;b&gt;A&lt;/b&gt;\n```\n\n### com.append(value)\n\nType: `method`\n\nAjoute du contenu à la fin de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Le contenu. |\n\nReturns: `jQuery` L'élément.\n\nUn tableau est concaténé.\n\nExample: Utiliser append()\n```js\nvar com = FIND('demo');\ncom.empty();\ncom.append('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.empty()\n\nType: `method`\n\nSupprime le contenu de l'élément.\n\nReturns: `jQuery` L'élément.\n\nLes composants imbriqués sont aussi supprimés.\n\nExample: Utiliser empty()\n```js\nvar com = FIND('demo');\ncom.empty();\nconsole.log(com.html() === '');  // true\n```\n\n### com.event(name, [selector], callback)\n\nType: `method`\n\nAttache un événement jQuery à l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `selector` | `String` | no |  | Le sélecteur de délégation. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nReturns: `Component` L'instance.\n\nLes arguments sont les mêmes que ceux de la méthode jQuery `on()`.\n\nExample: Utiliser event()\n```js\nvar com = FIND('demo');\ncom.event('click', '.label', () => console.log('clicked'));  // clicked\ncom.find('.label').click();\n```\n\n### com.aclass(classes, [timeout])\n\nType: `method`\n\nAjoute des classes CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Les classes. |\n| `timeout` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser aclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.rclass([classes], [timeout])\n\nType: `method`\n\nSupprime des classes CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Les classes. |\n| `timeout` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `Component` L'instance.\n\nSans argument, toutes les classes sont supprimées.\n\nExample: Utiliser rclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\ncom.rclass('active');\nconsole.log(com.hclass('active'));  // false\n```\n\n### com.rclass2(search)\n\nType: `method`\n\nSupprime les classes CSS qui contiennent un texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Le texte ou une expression régulière. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser rclass2()\n```js\nvar com = FIND('demo');\ncom.aclass('col-1 col-2');\ncom.rclass2('col-');\nconsole.log(com.hclass('col-1'));  // false\n```\n\n### com.tclass(classes, [state])\n\nType: `method`\n\nBascule des classes CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Les classes. |\n| `state` | `Boolean` | no |  | Force l'état. |\n\nReturns: `Component` L'instance.\n\nExample: Utiliser tclass()\n```js\nvar com = FIND('demo');\ncom.tclass('active', true);\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.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` Le résultat.\n\nExample: Utiliser hclass()\n```js\nvar com = FIND('demo');\nconsole.log(com.hclass('missing'));  // false\n```\n\n### com.attr(name, [value])\n\nType: `method`\n\nLit ou écrit un attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'attribut. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String|Component` La valeur, ou l'instance quand `value` est passé.\n\nExample: Utiliser attr()\n```js\nvar com = FIND('demo');\ncom.attr('title', 'Orders');\nconsole.log(com.attr('title'));  // Orders\n```\n\n### com.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 sans le préfixe `data-`. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String|Component` La valeur, ou l'instance quand `value` est passé.\n\nExample: Utiliser attrd()\n```js\nvar com = FIND('demo');\ncom.attrd('id', '5');\nconsole.log(com.attr('data-id'));  // 5\n```\n\n### com.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 sans le préfixe `data-`. |\n\nReturns: `String` La valeur.\n\nExample: Utiliser attrd2()\n```js\nvar com = FIND('demo');\nconsole.log(com.attrd2('group'));  // main\n```\n\n### com.css(name, [value])\n\nType: `method`\n\nLit ou écrit une propriété CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La propriété. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String|Component` La valeur, ou l'instance quand `value` est passé.\n\nExample: Utiliser css()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\nconsole.log(com.css('display'));  // block\n```\n\n### com.visible([callback])\n\nType: `method`\n\nIndique si l'élément est visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | S'exécute quand l'élément est visible. |\n\nReturns: `Boolean` La visibilité actuelle.\n\nAvec un callback, la fonction s'exécute dès que l'élément est visible.\n\nExample: Utiliser visible()\n```js\nvar com = FIND('demo');\nconsole.log(com.visible());  // true\n```\n\n### com.width([callback])\n\nType: `method`\n\nRenvoie la largeur de l'élément en pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Reçoit la largeur. |\n\nReturns: `Number` La largeur.\n\nAvec un callback, la fonction s'exécute dès que la largeur est supérieure à zéro.\n\nExample: Utiliser width()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('width', '200px');\nconsole.log(com.width());  // 200\n```\n\n### com.height([callback])\n\nType: `method`\n\nRenvoie la hauteur de l'élément en pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Reçoit la hauteur. |\n\nReturns: `Number` La hauteur.\n\nAvec un callback, la fonction s'exécute dès que la hauteur est supérieure à zéro.\n\nExample: Utiliser height()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('height', '50px');\nconsole.log(com.height());  // 50\n```\n\n### com.autofocus([selector])\n\nType: `method`\n\nDéplace le focus vers le premier champ visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Les champs. |\n\nReturns: `Component` L'instance.\n\nLa méthode réessaie pendant un court instant quand aucun champ ne peut recevoir le focus. Elle ne fait rien sur les appareils mobiles.\n\nExample: Utiliser autofocus()\n```js\nvar com = FIND('demo');\ncom.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### com.faicon(value)\n\nType: `method`\n\nComplète le nom d'une icône.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Le nom de l'icône. |\n\nReturns: `String` Les classes CSS.\n\nUn nom sans espace reçoit `DEF.iconprefix`, qui vaut `ti ti-`. La méthode est aussi disponible sous le nom `icon()`.\n\nExample: Utiliser faicon()\n```js\nvar com = FIND('demo');\nconsole.log(com.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"init","signature":"self.init = function()","since":"","deprecated":false},{"type":"delegate","name":"done","signature":"self.done = function()","since":"","deprecated":false},{"type":"delegate","name":"released","signature":"self.released = function(hidden)","since":"","deprecated":false},{"type":"delegate","name":"configure","signature":"self.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter","signature":"self.getter(value, [realtime], [nobind])","since":"","deprecated":false},{"type":"delegate","name":"setter2","signature":"self.setter2 = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter2","signature":"self.getter2 = function(value, realtime)","since":"","deprecated":false},{"type":"delegate","name":"state","signature":"self.state = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"state2","signature":"self.state2 = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"validate","signature":"self.validate = function(value, init)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"version","signature":"self.version","since":"","deprecated":false},{"type":"property","name":"id","signature":"self.id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"self.ID","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"type","signature":"self.type","since":"","deprecated":false},{"type":"property","name":"format","signature":"self.format","since":"","deprecated":false},{"type":"property","name":"trim","signature":"self.trim","since":"","deprecated":false},{"type":"property","name":"config","signature":"self.config","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"owner","signature":"self.owner","since":"","deprecated":false},{"type":"property","name":"caller","signature":"self.caller","since":"","deprecated":false},{"type":"property","name":"global","signature":"self.global","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"property","name":"pathscope","signature":"self.pathscope","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"self.plugin","since":"","deprecated":false},{"type":"property","name":"siblings","signature":"self.siblings","since":"","deprecated":false},{"type":"property","name":"removed","signature":"self.removed","since":"","deprecated":false},{"type":"method","name":"get()","signature":"com.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"com.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"com.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"com.inc(value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"com.extend(value, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"com.push(value, [type])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"com.rewrite(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"com.update([type])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"com.refresh([notify], [type])","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"com.notify()","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"com.skip()","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"com.bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"com.reset()","since":"","deprecated":false},{"type":"method","name":"default()","signature":"com.default([reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"com.change([value])","since":"","deprecated":false},{"type":"method","name":"dirty()","signature":"com.dirty([value], [noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"com.isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"com.validate2()","since":"","deprecated":false},{"type":"method","name":"notmodified()","signature":"com.notmodified([fields])","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"com.parser(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"com.formatter(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"parsesource()","signature":"com.parsesource(value)","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"com.reconfigure(value, [callback], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"configdisplay()","signature":"com.configdisplay(key, value)","since":"","deprecated":false},{"type":"method","name":"data()","signature":"com.data(key, [value])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"com.datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"com.watch([path], callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"com.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"on()","signature":"com.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"com.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"com.emit(name, [...args])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"com.command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"com.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"com.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"com.GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"com.SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"com.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"com.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"com.makepath(path)","since":"","deprecated":false},{"type":"method","name":"scopepath()","signature":"com.scopepath(path)","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"com.setPath(path)","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"com.blind()","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"self.readonly()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"self.singleton()","since":"","deprecated":false},{"type":"method","name":"bindchanges()","signature":"self.bindchanges([enable])","since":"","deprecated":false},{"type":"method","name":"bindexact()","signature":"self.bindexact([enable])","since":"","deprecated":false},{"type":"method","name":"bindvisible()","signature":"self.bindvisible([timeout])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"self.autofill([enable])","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"com.caniuse(name)","since":"","deprecated":false},{"type":"method","name":"main()","signature":"com.main()","since":"","deprecated":false},{"type":"method","name":"compile()","signature":"com.compile([container])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"com.import(url, [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"com.replace(element, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"com.remove([noclear])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"com.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"com.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"com.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"com.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"com.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"com.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"com.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"com.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"com.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"com.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"com.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"com.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"com.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"com.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"com.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"com.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"com.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"com.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"com.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"com.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"com.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"com.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUh2gM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Componente","summary":"I delegate, le proprietà e i metodi di un'istanza di componente.","markdown":"---\ntitle: Componente\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Componente\n\n> I delegate, le proprietà e i metodi di un'istanza di componente.\n\nUn'istanza di componente è l'oggetto passato alla dichiarazione di `COMPONENT()`. Collega un elemento a un path del modello dei dati. [Creazione dei componenti](../../guides/creating-components/) spiega come scriverne uno e [ui-component](../ui-component/) descrive l'elemento. Negli esempi, `com` è un'istanza trovata con `FIND()`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nCostruisce il contenuto del componente.\n\nIl delegate viene eseguito una sola volta, dopo la dichiarazione, quando l'elemento è nel DOM.\n\nExample: Definizione di make\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.html('<b>Ready</b>');\n        };\n    });\n</script>\n```\n\n### self.init = function()\n\nType: `delegate`\n\nViene eseguito una sola volta per tutte le istanze del componente.\n\nSolo la prima istanza della pagina chiama questo delegate.\n\nExample: Definizione di init\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.init = () => console.log('once');  // once\n    });\n</script>\n```\n\n### self.done = function()\n\nType: `delegate`\n\nViene eseguito dopo l'inizializzazione dell'istanza.\n\nIl delegate viene eseguito dopo le prime chiamate di `setter` e `state`.\n\nExample: Definizione di done\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.done = () => console.log('done');  // done\n    });\n</script>\n```\n\n### self.released = function(hidden)\n\nType: `delegate`\n\nIndica se l'elemento è nascosto all'avvio dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `hidden` | `Boolean` | yes |  | `true` quando l'elemento è nascosto. |\n\nIl delegate viene eseguito una sola volta e riceve `true` per un elemento nascosto.\n\nExample: Definizione di released\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.released = hidden => console.log(hidden);  // false\n    });\n</script>\n```\n\n### self.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nRiceve le chiavi di configurazione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome della chiave. |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `init` | `Boolean` | yes |  | `true` durante l'inizializzazione. |\n| `prev` | `Object` | yes |  | Il valore precedente. |\n\nIl delegate viene eseguito per ogni chiave durante l'inizializzazione, con `init` impostato a `true`, e di nuovo per ogni chiave modificata. Riceve anche le modifiche delle chiavi `modified`, `touched` e `invalid`.\n\nExample: Definizione di configure\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = function(key, value, init, prev) {\n            key === 'title' && console.log(value, init);  // Orders true\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nRiceve il valore del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore del path. |\n| `path` | `String` | yes |  | Il path che è cambiato. |\n| `type` | `Number` | yes |  | L'origine della modifica. |\n\nDefiniscilo per eseguire il rendering del valore. L'implementazione predefinita scrive il valore formattato nei campi annidati `input`, `select` e `textarea` con l'attributo `data-jc-bind`.\n\nL'argomento `type` indica da dove proviene la modifica:\n\n| Tipo | Origine |\n| --- | --- |\n| `0` | L'inizializzazione. |\n| `1` | Una modifica manuale, come `SET()`. |\n| `2` | Un input dell'utente. |\n| `3` | Un valore predefinito o un reset. |\n\nExample: Definizione di setter\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value, path, type) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter(value, [realtime], [nobind])\n\nType: `delegate`\n\nScrive nel path un valore proveniente dall'utente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore grezzo. |\n| `realtime` | `Boolean` | no |  | `true` quando il valore arriva mentre l'utente digita. |\n| `nobind` | `Boolean` | no |  | `true` convalida il valore senza scriverlo. |\n\nL'implementazione predefinita esegue i parser e scrive il risultato. I campi annidati con l'attributo `data-jc-bind` lo chiamano automaticamente. Chiamalo dai tuoi controlli per scrivere un valore.\n\nExample: Definizione di getter\n```html\n<ui-component name=\"box\" path=\"form.name\"><button>Set</button></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.event('click', 'button', () => self.getter('Peter'));\n        };\n    });\n    setTimeout(function() {\n        $('button').click();\n        console.log(GET('form.name'));  // Peter\n    }, 500);\n</script>\n```\n\n### self.setter2 = function(value, path, type)\n\nType: `delegate`\n\nViene eseguito dopo il delegate `setter`.\n\nRiceve gli stessi argomenti. Usalo per estendere un componente mantenendone il setter.\n\nExample: Definizione di setter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter2 = value => value && console.log(value);  // Peter\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter2 = function(value, realtime)\n\nType: `delegate`\n\nViene eseguito quando il `getter` riceve un valore.\n\nRiceve il valore analizzato e l'argomento `realtime`.\n\nExample: Definizione di getter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.getter2 = value => console.log(value);  // PETER\n        self.parser((path, value) => value.toUpperCase());\n    });\n    setTimeout(() => FIND('box').getter('peter'), 500);\n</script>\n```\n\n### self.state = function(type, what)\n\nType: `delegate`\n\nViene eseguito quando lo stato dell'istanza cambia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | yes |  | L'origine della modifica. |\n| `what` | `Number` | yes |  | La natura della modifica. |\n\nL'argomento `type` è `0` per l'inizializzazione, `1` per una modifica manuale e `2` per un input dell'utente.\n\nL'argomento `what` indica cosa è successo:\n\n| What | Significato |\n| --- | --- |\n| `1` | Convalida. |\n| `2` | Lo stato di toccato è cambiato. |\n| `3` | Un reset. |\n| `4` | Un aggiornamento. |\n| `5` | Un nuovo valore. |\n| `6` | Una notifica. |\n\nExample: Definizione di state\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state = function(type, what) {\n            console.log(type, what);  // 0 3\n        };\n    });\n</script>\n```\n\n### self.state2 = function(type, what)\n\nType: `delegate`\n\nViene eseguito dopo il delegate `state`.\n\nRiceve gli stessi argomenti.\n\nExample: Definizione di state2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state2 = (type, what) => console.log(type, what);  // 0 3\n    });\n</script>\n```\n\n### self.validate = function(value, init)\n\nType: `delegate`\n\nStabilisce se il valore è valido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore del path. |\n| `init` | `Boolean` | no |  | `true` durante l'inizializzazione. |\n\nRestituisci `true` per un valore valido. Il risultato viene memorizzato in `config.invalid`.\n\nExample: Definizione di validate\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        self.validate = value => !!value;\n        self.done = () => console.log(config.invalid);  // true\n    });\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nViene eseguito una volta al minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Il numero di esecuzioni. |\n\nIl delegate riceve un contatore che aumenta di uno a ogni esecuzione.\n\n### self.destroy = function()\n\nType: `delegate`\n\nViene eseguito quando l'istanza viene rimossa.\n\nRilascia qui i timer e i listener esterni.\n\nExample: Definizione di destroy\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => FIND('box').remove(), 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nIl nome del componente, con la relativa versione.\n\nExample: Lettura di name\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.name));  // box@2\n</script>\n```\n\n### self.version\n\nType: `property`\n\nLa versione ricavata dal nome del componente.\n\nIl valore è vuoto quando il nome non ha una versione. L'elemento riceve anche la classe `jc-v{version}`.\n\nExample: Lettura di version\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.version));  // 2\n</script>\n```\n\n### self.id\n\nType: `property`\n\nL'identificatore dell'istanza.\n\nLo imposta la chiave di configurazione [`$id`](../ui-component/#x-id). Altrimenti ha lo stesso valore di `ID`.\n\nExample: Lettura di id\n```html\n<ui-component name=\"box\" config=\"$id:orders\"></ui-component>\n<script>\n    COMPONENT('box', self => self.make = () => console.log(self.id));  // orders\n</script>\n```\n\n### self.ID\n\nType: `property`\n\nL'identificatore univoco generato dell'istanza.\n\nExample: Lettura di ID\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.ID.substring(0, 2)));  // jc\n</script>\n```\n\n### self.path\n\nType: `property`\n\nIl path del modello dei dati associato all'istanza.\n\nIl valore è vuoto quando il componente non ha un path.\n\nExample: Lettura di path\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.path));  // form.name\n</script>\n```\n\n### self.type\n\nType: `property`\n\nIl tipo di dati dell'istanza.\n\nIl valore viene passato a parser e formatter. Impostalo nella dichiarazione o con la chiave [`$type`](../ui-component/#x-type).\n\nExample: Lettura di type\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.type = 'number';\n        self.parser((path, value, type) => console.log(type));  // number\n        self.make = () => self.parser('1');\n    });\n</script>\n```\n\n### self.format\n\nType: `property`\n\nIl formato passato a parser e formatter.\n\nQuando la proprietà è vuota, viene usato `config.format`.\n\nExample: Lettura di format\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.format = 'dd.MM.yyyy';\n        self.formatter((path, value, type, format) => console.log(format));  // dd.MM.yyyy\n        self.make = () => self.formatter('1');\n    });\n</script>\n```\n\n### self.trim\n\nType: `property`\n\nRimuove gli spazi attorno al testo nel parser.\n\nIl valore predefinito è `true`.\n\nExample: Lettura di trim\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.trim = false;\n        self.make = () => console.log(self.parser('  A  ').length);  // 5\n    });\n</script>\n```\n\n### self.config\n\nType: `property`\n\nL'oggetto di configurazione.\n\nContiene anche le chiavi di stato `modified`, `touched`, `invalid` e, se impostata, `disabled`.\n\nExample: Lettura di config\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.config.title, self.config.touched));  // Orders false\n</script>\n```\n\n### self.element\n\nType: `property`\n\nL'elemento dell'istanza come oggetto jQuery.\n\nExample: Lettura di element\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.element.prop('tagName')));  // UI-COMPONENT\n</script>\n```\n\n### self.dom\n\nType: `property`\n\nL'elemento dell'istanza come nodo DOM.\n\nExample: Lettura di dom\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.dom.tagName));  // UI-COMPONENT\n</script>\n```\n\n### self.owner\n\nType: `property`\n\nIl componente padre più vicino.\n\nLa proprietà manca quando il componente non ha un componente padre.\n\nExample: Lettura di owner\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', self => console.log(self.owner.name));  // parent\n</script>\n```\n\n### self.caller\n\nType: `property`\n\nIl componente che ha chiamato questa istanza tramite `exec()`.\n\nExample: Lettura di caller\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', function(self) {\n        self.ping = () => console.log(self.caller.name);  // parent\n    });\n    setTimeout(() => FIND('parent').exec('ping'), 500);\n</script>\n```\n\n### self.global\n\nType: `property`\n\nUn oggetto condiviso da tutte le istanze del componente.\n\nExample: Lettura di global\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.global.count = (self.global.count || 0) + 1;\n    });\n    setTimeout(() => console.log(FIND('box').global.count), 500);  // 2\n</script>\n```\n\n### self.scope\n\nType: `property`\n\nLo [Scope](../scope/) dell'istanza.\n\nLa proprietà esiste quando il path contiene `?`.\n\nExample: Lettura di scope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.scope.path));  // users\n</script>\n```\n\n### self.pathscope\n\nType: `property`\n\nIl path dello scope dell'istanza.\n\nLa proprietà esiste quando il path contiene `?`.\n\nExample: Lettura di pathscope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.pathscope));  // users\n</script>\n```\n\n### self.plugin\n\nType: `property`\n\nIl [Plugin](../plugin/) dello scope dell'istanza.\n\nLa proprietà esiste quando il path contiene `?`.\n\nExample: Lettura di plugin\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.plugin.name));  // users\n</script>\n```\n\n### self.siblings\n\nType: `property`\n\nIndica se l'elemento ospita più componenti.\n\nExample: Lettura di siblings\n```html\n<ui-component name=\"a,b\"></ui-component>\n<script>\n    COMPONENT('a', self => console.log(self.siblings));  // true\n    COMPONENT('b', function(self) {});\n</script>\n```\n\n### self.removed\n\nType: `property`\n\nIndica se l'istanza è stata rimossa.\n\nExample: Lettura di removed\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var com = FIND('box');\n        com.remove();\n        console.log(com.removed);  // true\n    }, 500);\n</script>\n```\n\n### com.get([path])\n\nType: `method`\n\nRestituisce il valore del path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Un altro path. |\n\nReturns: `Object` Il valore.\n\nCon un argomento, il metodo legge un altro path.\n\nExample: Uso di get()\n```js\nvar com = FIND('demo');\nSET('form.name', 'Peter');\nconsole.log(com.get());  // Peter\n```\n\n### com.set(value, [type])\n\nType: `method`\n\nScrive un valore nel path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `type` | `Number` | no |  | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nL'istanza viene segnata come modificata.\n\nExample: Uso di set()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(GET('form.name'), com.config.modified);  // Peter true\n```\n\n### com.modify(value, [type])\n\nType: `method`\n\nScrive un valore tramite i parser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore grezzo. |\n| `type` | `Number` | no | `2` | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nL'istanza viene segnata come toccata.\n\nExample: Uso di modify()\n```js\nvar com = FIND('demo');\ncom.modify('  Peter  ');\nconsole.log(GET('form.name'), com.config.touched);  // Peter true\n```\n\n### com.inc(value, [type])\n\nType: `method`\n\nIncrementa il numero memorizzato nel path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number` | yes |  | L'incremento. |\n| `type` | `Number` | no |  | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di inc()\n```js\nvar com = FIND('demo');\ncom.set(5);\ncom.inc(2);\nconsole.log(GET('form.name'));  // 7\n```\n\n### com.extend(value, [type])\n\nType: `method`\n\nUnisce un oggetto nel path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | I campi da unire. |\n| `type` | `Number` | no |  | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di extend()\n```js\nvar com = FIND('demo');\ncom.set({ a: 1 });\ncom.extend({ b: 2 });\nconsole.log(GET('form.name'));  // {\"a\":1,\"b\":2}\n```\n\n### com.push(value, [type])\n\nType: `method`\n\nAggiunge un elemento all'array memorizzato nel path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | L'elemento. |\n| `type` | `Number` | no |  | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di push()\n```js\nvar com = FIND('demo');\ncom.push('A');\ncom.push('B');\nconsole.log(GET('form.name'));  // [\"A\",\"B\"]\n```\n\n### com.rewrite(value, [type])\n\nType: `method`\n\nScrive un valore senza notificare nessuno.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `type` | `Number` | no |  | Il tipo della modifica. |\n\nReturns: `Component` L'istanza.\n\nI componenti associati, i binder e gli osservatori non vengono chiamati.\n\nExample: Uso di rewrite()\n```js\nvar com = FIND('demo');\ncom.rewrite('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### com.update([type])\n\nType: `method`\n\nScrive di nuovo il valore corrente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nTutti i listener del path vengono notificati.\n\nExample: Uso di update()\n```js\nvar com = FIND('demo');\ncom.watch(function(path, value) {\n    console.log(value);  // Peter\n});\nwindow.form.name = 'Peter';\ncom.update();\n```\n\n### com.refresh([notify], [type])\n\nType: `method`\n\nChiama il setter di questa istanza con il valore corrente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `notify` | `Boolean` | no |  | `true` notifica tutti i listener. |\n| `type` | `Number|String` | no |  | Il tipo passato al setter. |\n\nReturns: `Component` L'istanza.\n\nCon `notify`, il valore viene scritto nel path e tutti i listener vengono notificati.\n\nExample: Uso di refresh()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.refresh();\nconsole.log(com.text());  // Peter\n```\n\n### com.notify()\n\nType: `method`\n\nNotifica i listener del path associato esatto.\n\nReturns: `Component` L'istanza.\n\nIl metodo chiama `NOTIFY()` con il path dell'istanza.\n\nExample: Uso di notify()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.notify();\nconsole.log(com.text());  // Peter\n```\n\n### com.skip()\n\nType: `method`\n\nSalta la prossima chiamata del setter.\n\nReturns: `Component` L'istanza.\n\nExample: Uso di skip()\n```js\nvar com = FIND('demo');\ncom.skip();\ncom.set('Peter');\nsetTimeout(() => console.log(com.text() || 'empty'), 500);  // empty\n```\n\n### com.bind(flags, [value])\n\nType: `method`\n\nCambia lo stato e, facoltativamente, scrive un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | I flag. |\n| `value` | `Object` | no |  | Il valore da scrivere. |\n\nL'argomento `flags` è un elenco di parole separate da uno spazio, una virgola o `|`. Un eventuale prefisso `@` viene ignorato.\n\n| Flag | Effetto |\n| --- | --- |\n| `touched`, `touch` | Segna l'istanza come toccata. |\n| `modified`, `modify`, `changed`, `change` | Segna l'istanza come modificata. |\n| `reset` | Azzera lo stato di toccato e modificato. |\n| `validate` | Convalida il valore. |\n| `setter` | Chiama il setter. |\n\nQuando passi `value`, viene scritto nel path, e il setter di questa istanza viene eseguito solo con il flag `setter`.\n\nExample: Uso di bind()\n```js\nvar com = FIND('demo');\ncom.bind('@touched @modified', 'Peter');\nconsole.log(GET('form.name'), com.config.touched, com.config.modified);  // Peter true true\n```\n\n### com.reset()\n\nType: `method`\n\nAzzera lo stato toccato e modificato.\n\nReturns: `Component` L'istanza.\n\nIl valore viene convalidato di nuovo.\n\nExample: Uso di reset()\n```js\nvar com = FIND('demo');\ncom.modify('Peter');\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### com.default([reset])\n\nType: `method`\n\nRipristina il valore predefinito dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `reset` | `Boolean` | no | `true` | `false` mantiene lo stato dell'istanza. |\n\nReturns: `Component` L'istanza.\n\nIl valore predefinito proviene dall'attributo [`default`](../ui-component/#default).\n\nExample: Uso di default()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\ncom.default();\nconsole.log(GET('form.name'));  // Anonymous\n```\n\n### com.change([value])\n\nType: `method`\n\nImposta lo stato di toccato e modificato dei componenti del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no | `true` | Il nuovo stato. |\n\nReturns: `Component` L'istanza.\n\nIl metodo si applica a tutti i componenti associati al path e ai path annidati. È disponibile anche come `touched()`.\n\nExample: Uso di change()\n```js\nvar com = FIND('demo');\ncom.change();\nconsole.log(com.config.touched, com.config.modified);  // true true\n```\n\n### com.dirty([value], [noemit])\n\nType: `method`\n\nLegge o imposta lo stato di non toccato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no |  | `false` segna l'istanza come toccata. |\n| `noemit` | `Boolean` | no |  | `true` salta il delegate `state`. |\n\nReturns: `Boolean|Component` Lo stato, oppure l'istanza quando passi `value`.\n\nSenza argomenti, il metodo restituisce `true` per un'istanza non toccata.\n\nExample: Uso di dirty()\n```js\nvar com = FIND('demo');\nconsole.log(com.dirty());  // true\ncom.dirty(false);\nconsole.log(com.config.touched);  // true\n```\n\n### com.isInvalid()\n\nType: `method`\n\nIndica se l'istanza è toccata e non valida.\n\nReturns: `Boolean` Il risultato.\n\nExample: Uso di isInvalid()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\ncom.modify('');\ncom.validate2();\ncom.bind('touched');\nconsole.log(com.isInvalid());  // true\n```\n\n### com.validate2()\n\nType: `method`\n\nEsegue il delegate `validate` e aggiorna lo stato.\n\nReturns: `Boolean` `true` per un valore valido.\n\nExample: Uso di validate2()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\nconsole.log(com.validate2());  // false\n```\n\n### com.notmodified([fields])\n\nType: `method`\n\nIndica se il valore è lo stesso dell'ultimo controllo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fields` | `String|Array` | no |  | I campi da confrontare. |\n\nReturns: `Boolean` `true` quando il valore non è cambiato.\n\nIl primo controllo restituisce `false`.\n\nExample: Uso di notmodified()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(com.notmodified());  // false\nconsole.log(com.notmodified());  // true\n```\n\n### com.parser(value, [prepend])\n\nType: `method`\n\nAggiunge un parser o analizza un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Un parser o il valore da analizzare. |\n| `prepend` | `Boolean` | no |  | `true` aggiunge il parser all'inizio. |\n\nReturns: `Object` Il valore analizzato, oppure l'istanza quando aggiungi un parser.\n\nUna funzione viene aggiunta ai parser dell'istanza. Riceve `path`, `value`, `type` e `format`, e restituisce il nuovo valore. Qualsiasi altro argomento viene analizzato e restituito.\n\nExample: Uso di parser()\n```js\nvar com = FIND('demo');\ncom.parser((path, value) => value.toUpperCase());\nconsole.log(com.parser('peter'));  // PETER\n```\n\n### com.formatter(value, [prepend])\n\nType: `method`\n\nAggiunge un formatter o formatta un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Un formatter o il valore da formattare. |\n| `prepend` | `Boolean` | no |  | `true` aggiunge il formatter all'inizio. |\n\nReturns: `Object` Il valore formattato, oppure l'istanza quando aggiungi un formatter.\n\nUna funzione viene aggiunta ai formatter dell'istanza. Riceve `path`, `value`, `type` e `format`, e restituisce il nuovo valore. Qualsiasi altro argomento viene formattato e restituito.\n\nExample: Uso di formatter()\n```js\nvar com = FIND('demo');\ncom.formatter((path, value) => value + '!');\nconsole.log(com.formatter('Peter'));  // Peter!\n```\n\n### com.parsesource(value)\n\nType: `method`\n\nConverte un elenco testuale in un array di elementi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | L'elenco. |\n\nReturns: `Array` Oggetti con `id`, `name` e `icon`.\n\nGli elementi sono separati da una virgola. Ogni elemento ha la forma `id|name|icon`. Quando l'istanza ha il tipo `number`, gli identificatori vengono convertiti in numeri.\n\nExample: Uso di parsesource()\n```js\nvar com = FIND('demo');\nconsole.log(com.parsesource('1|One,2|Two|home')[1]);  // {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n\n### com.reconfigure(value, [callback], [init], [noemit])\n\nType: `method`\n\nCambia la configurazione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | La configurazione. |\n| `callback` | `Function` | no |  | Riceve `key`, `value`, `init` e `prev` al posto del delegate `configure`. |\n| `init` | `Boolean` | no |  | L'argomento `init` del delegate. |\n| `noemit` | `Boolean` | no |  | `true` salta il delegate. |\n\nReturns: `Component` L'istanza.\n\nIl valore può essere una stringa di coppie `key:value`, un oggetto oppure `=path` per leggere un oggetto da un path. Il delegate `configure` riceve ogni chiave.\n\nExample: Uso di reconfigure()\n```js\nvar com = FIND('demo');\ncom.reconfigure('title:Orders;limit:10');\nconsole.log(com.config.title, com.config.limit);  // Orders 10\n```\n\n### com.configdisplay(key, value)\n\nType: `method`\n\nRisolve un valore che dipende dallo schermo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome della chiave. |\n| `value` | `Object` | yes |  | Il valore. |\n\nReturns: `Object` Il valore risolto.\n\nIl valore ha la forma `@xs=1,@md=2`. Gli altri valori vengono restituiti senza modifiche. Vedi [Configurazione responsive](../ui-component/#responsive-configuration).\n\nExample: Uso di configdisplay()\n```js\nvar com = FIND('demo');\nconsole.log(com.configdisplay('size', '@xs=1,@lg=4'), WIDTH());  // 1 xs\n```\n\n### com.data(key, [value])\n\nType: `method`\n\nLegge o scrive i dati dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome della chiave. |\n| `value` | `Object` | no |  | Il valore da scrivere. |\n\nReturns: `Object` Il valore.\n\nGli elementi annidati leggono le chiavi con il path `@key`. Una chiave vuota è il valore corrente dell'istanza.\n\nExample: Uso di data()\n```js\nvar com = FIND('demo');\ncom.data('title', 'Orders');\nconsole.log(com.data('title'));  // Orders\n```\n\n### com.datasource(path, callback, [init])\n\nType: `method`\n\nOsserva un path che contiene una sorgente di dati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path della sorgente di dati. |\n| `callback` | `Function` | yes |  | La funzione che riceve i dati. |\n| `init` | `Boolean` | no | `true` | `false` salta la chiamata iniziale. |\n\nReturns: `Component` L'istanza.\n\nIl callback riceve `path`, `value` e `type`. A meno che `init` non sia `false`, viene eseguito anche dopo il caricamento della configurazione. Una nuova chiamata sostituisce la sorgente di dati precedente.\n\nExample: Uso di datasource()\n```js\nvar com = FIND('demo');\ncom.datasource('common.items', function(path, value) {\n    console.log(value);  // [1,2]\n}, false);\nSET('common.items', [1, 2]);\n```\n\n### com.watch([path], callback, [init])\n\nType: `method`\n\nOsserva un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path da osservare. |\n| `callback` | `Function` | yes |  | La funzione che riceve le modifiche. |\n| `init` | `Boolean` | no |  | `true` chiama subito il callback. |\n\nReturns: `Component` L'istanza.\n\nIl callback riceve `path`, `value` e `type`, e `this` è l'istanza. Senza un path, il metodo osserva il path dell'istanza. L'osservatore viene rimosso insieme all'istanza.\n\nExample: Uso di watch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', function(path, value) {\n    console.log(path, value);  // form.age 30\n});\nSET('form.age', 30);\n```\n\n### com.unwatch(path)\n\nType: `method`\n\nRimuove gli osservatori di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path osservato. |\n\nReturns: `Component` L'istanza.\n\nIl metodo rimuove tutti gli osservatori che questa istanza ha sul path.\n\nExample: Uso di unwatch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', () => console.log('called'));\ncom.unwatch('form.age');\nSET('form.age', 30);\nconsole.log('end');  // end\n```\n\n### com.on(name, callback)\n\nType: `method`\n\nResta in ascolto 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 listener. |\n\nReturns: `Component` L'istanza.\n\nIl listener viene rimosso insieme all'istanza. Un prefisso `^` nel nome mette il listener al primo posto.\n\nExample: Uso di on()\n```js\nvar com = FIND('demo');\ncom.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### com.off(name, [callback])\n\nType: `method`\n\nRimuove un listener 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 listener. |\n\nReturns: `Component` L'istanza.\n\nSenza un callback, vengono rimossi tutti i listener dell'evento in questa istanza.\n\nExample: Uso di off()\n```js\nvar com = FIND('demo');\nvar fn = () => console.log('called');\ncom.on('saved', fn);\ncom.off('saved', fn);\nconsole.log(EMIT('saved'));  // false\n```\n\n### com.emit(name, [...args])\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| `args` | `Object` | no |  | Gli argomenti dell'evento. |\n\nReturns: `Component` L'istanza.\n\nIl metodo chiama `EMIT()`.\n\nExample: Uso di emit()\n```js\nvar com = FIND('demo');\nON('saved', value => console.log(value));  // 5\ncom.emit('saved', 5);\n```\n\n### com.command(name, callback)\n\nType: `method`\n\nRegistra un comando dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nReturns: `Component` L'istanza.\n\nUn prefisso `^` nel nome mette il gestore al primo posto. I comandi vengono chiamati da [`CMD()`](#cmd) o dal `CMD()` globale.\n\nExample: Uso di command()\n```js\nvar com = FIND('demo');\ncom.command('clear', () => console.log('cleared'));  // cleared\nCMD('clear');\n```\n\n### com.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nChiama un comando di questa istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n\nReturns: `Component` L'istanza.\n\nIl metodo accetta fino a cinque argomenti.\n\nExample: Uso di CMD()\n```js\nvar com = FIND('demo');\ncom.command('add', (a, b) => console.log(a + b));  // 3\ncom.CMD('add', 1, 2);\n```\n\n### com.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nChiama un metodo di tutti i componenti annidati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del metodo. |\n\nReturns: `Component` L'istanza.\n\nOgni componente annidato riceve questa istanza in `caller`.\n\nExample: Uso di exec()\n```js\nvar com = FIND('demo');\ncom.exec('ping', 5);\n```\n\n### com.GET(path)\n\nType: `method`\n\nLegge un path relativo allo scope dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `Object` Il valore.\n\nIl carattere `?` viene sostituito con il path dello scope.\n\nExample: Uso di GET()\n```js\nvar com = FIND('demo');\nSET('users.name', 'Peter');\nconsole.log(com.GET('?.name'));  // Peter\n```\n\n### com.SET(path, value)\n\nType: `method`\n\nScrive in un path relativo allo scope dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Object` | yes |  | Il valore. |\n\nIl carattere `?` viene sostituito con il path dello scope.\n\nExample: Uso di SET()\n```js\nvar com = FIND('demo');\ncom.SET('?.age', 30);\nconsole.log(GET('users.age'));  // 30\n```\n\n### com.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione tramite il suo path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path della funzione. |\n\nReturns: `Component` L'istanza.\n\nIl carattere `?` viene sostituito con il path dello scope. Un path con il prefisso `@` chiama un metodo del componente padre.\n\nExample: Uso di EXEC()\n```js\nvar com = FIND('child');\ncom.EXEC('@ping', 5);\n```\n\n### com.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione o scrive un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `Component` L'istanza.\n\nIl metodo chiama la funzione presente nel path. Quando il path non contiene una funzione, vi viene scritto il primo argomento. Il prefisso `@` funziona con il componente padre.\n\nExample: Uso di SEEX()\n```js\nvar com = FIND('child');\ncom.SEEX('@title', 'Orders');\nconsole.log(FIND('demo').title);  // Orders\n```\n\n### com.makepath(path)\n\nType: `method`\n\nRisolve un path nello scope dell'istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `String` Il path risolto.\n\nExample: Uso di makepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.makepath('?.age'));  // users.age\n```\n\n### com.scopepath(path)\n\nType: `method`\n\nSostituisce `?` in un path con il path dello scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `String` Il path risolto.\n\nUn path senza `?` viene restituito senza modifiche.\n\nExample: Uso di scopepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.scopepath('?.age'), com.scopepath('form.age'));  // users.age form.age\n```\n\n### com.setPath(path)\n\nType: `method`\n\nCambia il path associato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il nuovo path. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di setPath()\n```js\nvar com = FIND('demo');\ncom.setPath('form.other');\nSET('form.other', 5);\nconsole.log(com.path, com.get());  // form.other 5\n```\n\n### com.blind()\n\nType: `method`\n\nScollega l'istanza dal suo path.\n\nReturns: `Component` L'istanza.\n\nExample: Uso di blind()\n```js\nvar com = FIND('demo');\ncom.blind();\nSET('form.name', 'Peter');\nconsole.log(com.path, com.text() || 'empty');  // null empty\n```\n\n### self.readonly()\n\nType: `method`\n\nRimuove i delegate `setter`, `getter` e `validate`.\n\nReturns: `Component` L'istanza.\n\nUsalo nei componenti che si limitano a mostrare contenuti.\n\nExample: Uso di readonly()\n```js\nvar com = FIND('demo');\nconsole.log(com.setter, com.getter);  // null null\n```\n\n### self.singleton()\n\nType: `method`\n\nConsente una sola istanza del componente nella pagina.\n\nReturns: `Component` L'istanza.\n\nGli altri elementi dello stesso componente vengono rimossi.\n\nExample: Uso di singleton()\n```js\nconsole.log(FIND('demo', true).length, $('ui-component').length);  // 1 1\n```\n\n### self.bindchanges([enable])\n\nType: `method`\n\nSalta il setter quando il valore non è cambiato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` disattiva la funzionalità. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di bindchanges()\n```js\nSET('form.name', 'A');\nSET('form.name', 'A');\nsetTimeout(() => console.log(window.calls), 500);  // 2\n```\n\n### self.bindexact([enable])\n\nType: `method`\n\nIgnora le modifiche dei path annidati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` disattiva la funzionalità. |\n\nReturns: `Component` L'istanza.\n\nIl setter viene eseguito solo per il path esatto o per i suoi genitori.\n\nExample: Uso di bindexact()\n```js\nSET('form.user.name', 'Peter');\nsetTimeout(() => console.log(window.calls), 500);  // 1\n```\n\n### self.bindvisible([timeout])\n\nType: `method`\n\nRitarda il setter finché l'elemento non è visibile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `timeout` | `Number|Boolean` | no | `DEF.delaybinder` | Il ritardo in millisecondi dopo che l'elemento diventa visibile. `false` disattiva la funzionalità. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di bindvisible()\n```js\nSET('form.name', 'Peter');\nsetTimeout(() => $('#tab').show(), 500);\nsetTimeout(() => console.log($('ui-component').text()), 1500);  // Peter\n```\n\n### self.autofill([enable])\n\nType: `method`\n\nLegge i valori compilati dal browser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` disattiva la funzionalità. |\n\nReturns: `Component` L'istanza.\n\nQuando la pagina è pronta, il valore dei campi annidati con l'attributo `data-jc-bind` viene scritto nel path.\n\nExample: Uso di autofill()\n```js\n$('input').val('Peter');\nsetTimeout(() => console.log(GET('form.name')), 1400);  // Peter\n```\n\n### com.caniuse(name)\n\nType: `method`\n\nIndica se un componente è disponibile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del componente. |\n\nReturns: `Number` `1` per un componente dichiarato, `2` per uno lazy, `undefined` per uno sconosciuto.\n\nExample: Uso di caniuse()\n```js\nvar com = FIND('demo');\nconsole.log(com.caniuse('demo'));  // 1\n```\n\n### com.main()\n\nType: `method`\n\nRestituisce il componente padre più vicino.\n\nReturns: `Component` Il componente padre o `null`.\n\nExample: Uso di main()\n```js\nvar com = FIND('child');\nconsole.log(com.main().name);  // demo\n```\n\n### com.compile([container])\n\nType: `method`\n\nCompila il nuovo contenuto dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `jQuery|Element` | no | `the component element` | L'elemento da compilare. |\n\nReturns: `Component` L'istanza.\n\nChiamalo dopo aver aggiunto elementi con associazioni o componenti.\n\nExample: Uso di compile()\n```js\nvar com = FIND('demo');\ncom.append('<div data-bind=\"form.name__text\"></div>');\ncom.compile();\nSET('form.name', 'Peter');\nsetTimeout(() => console.log(com.find('div').text()), 500);  // Peter\n```\n\n### com.import(url, [callback], [insert], [preparator])\n\nType: `method`\n\nImporta contenuto nell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `callback` | `Function` | no |  | Viene eseguito dopo l'importazione. |\n| `insert` | `Boolean` | no |  | L'argomento `insert` di `IMPORT()`. |\n| `preparator` | `Function` | no |  | Modifica la risposta prima dell'inserimento. |\n\nReturns: `Component` L'istanza.\n\nIl metodo chiama `IMPORT()` con l'elemento come destinazione.\n\nExample: Uso di import()\n```js\nvar com = FIND('demo');\ncom.import('/part.html', () => console.log('imported'));  // imported\n```\n\n### com.replace(element, [remove])\n\nType: `method`\n\nSposta l'istanza su un altro elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Il nuovo elemento. |\n| `remove` | `Boolean` | no |  | `true` rimuove l'elemento originale. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di replace()\n```js\nvar com = FIND('demo');\ncom.replace($('#target'), true);\nconsole.log(com.dom.id, $('ui-component').length);  // target 0\n```\n\n### com.remove([noclear])\n\nType: `method`\n\nRimuove l'istanza e il relativo elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noclear` | `Boolean` | no |  | `true` non avvia subito la pulizia. |\n\nReturns: `Boolean` Sempre `true`.\n\nIl delegate `destroy` viene eseguito durante la pulizia. Il metodo è disponibile anche come `kill()`.\n\nExample: Uso di remove()\n```js\nvar com = FIND('demo');\nconsole.log(com.remove());  // true\n```\n\n### com.find(selector)\n\nType: `method`\n\nTrova gli elementi annidati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un selettore o un oggetto di selettori. |\n\nReturns: `jQuery|Object` Il risultato.\n\nUn oggetto di selettori restituisce un oggetto di risultati jQuery con le stesse chiavi.\n\nExample: Uso di find()\n```js\nvar com = FIND('demo');\nconsole.log(com.find('.label').text());  // Text\n```\n\n### com.closest(selector)\n\nType: `method`\n\nTrova il genitore corrispondente più vicino.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore. |\n\nReturns: `jQuery` Il risultato.\n\nExample: Uso di closest()\n```js\nvar com = FIND('demo');\nconsole.log(com.closest('body').length);  // 1\n```\n\n### com.parent([selector])\n\nType: `method`\n\nRestituisce un elemento genitore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Il selettore. |\n\nReturns: `jQuery` Il risultato.\n\nL'argomento può essere:\n\n| Valore | Risultato |\n| --- | --- |\n| omesso | Il genitore diretto. |\n| Un selettore | L'elemento corrispondente più vicino. |\n| `auto` | Il genitore più vicino con un'altezza definita, altrimenti `window`. |\n| `window` | `window` come oggetto jQuery. |\n| `document` | L'oggetto `document`. |\n| `parent` | Il genitore diretto. |\n| `parent2` | L'elemento due livelli sopra il genitore diretto. |\n\nExample: Uso di parent()\n```js\nvar com = FIND('demo');\nconsole.log(com.parent().prop('tagName'));  // BODY\n```\n\n### com.html([value])\n\nType: `method`\n\nLegge o sostituisce il contenuto HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Il nuovo contenuto. |\n\nReturns: `String|jQuery` Il contenuto, oppure l'elemento quando passi `value`.\n\nUn array viene unito.\n\nExample: Uso di html()\n```js\nvar com = FIND('demo');\ncom.html('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.text([value])\n\nType: `method`\n\nLegge o sostituisce il contenuto testuale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Il nuovo contenuto. |\n\nReturns: `String|jQuery` Il contenuto, oppure l'elemento quando passi `value`.\n\nUn array viene unito.\n\nExample: Uso di text()\n```js\nvar com = FIND('demo');\ncom.text('<b>A</b>');\nconsole.log(com.html());  // &lt;b&gt;A&lt;/b&gt;\n```\n\n### com.append(value)\n\nType: `method`\n\nAggiunge contenuto alla fine dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Il contenuto. |\n\nReturns: `jQuery` L'elemento.\n\nUn array viene unito.\n\nExample: Uso di append()\n```js\nvar com = FIND('demo');\ncom.empty();\ncom.append('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.empty()\n\nType: `method`\n\nRimuove il contenuto dell'elemento.\n\nReturns: `jQuery` L'elemento.\n\nVengono rimossi anche i componenti annidati.\n\nExample: Uso di empty()\n```js\nvar com = FIND('demo');\ncom.empty();\nconsole.log(com.html() === '');  // true\n```\n\n### com.event(name, [selector], callback)\n\nType: `method`\n\nCollega un evento jQuery all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `selector` | `String` | no |  | Il selettore delegato. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nReturns: `Component` L'istanza.\n\nGli argomenti sono gli stessi del metodo jQuery `on()`.\n\nExample: Uso di event()\n```js\nvar com = FIND('demo');\ncom.event('click', '.label', () => console.log('clicked'));  // clicked\ncom.find('.label').click();\n```\n\n### com.aclass(classes, [timeout])\n\nType: `method`\n\nAggiunge classi CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Le classi. |\n| `timeout` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di aclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.rclass([classes], [timeout])\n\nType: `method`\n\nRimuove classi CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Le classi. |\n| `timeout` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `Component` L'istanza.\n\nSenza argomenti, vengono rimosse tutte le classi.\n\nExample: Uso di rclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\ncom.rclass('active');\nconsole.log(com.hclass('active'));  // false\n```\n\n### com.rclass2(search)\n\nType: `method`\n\nRimuove le classi CSS che contengono un testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Il testo o un'espressione regolare. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di rclass2()\n```js\nvar com = FIND('demo');\ncom.aclass('col-1 col-2');\ncom.rclass2('col-');\nconsole.log(com.hclass('col-1'));  // false\n```\n\n### com.tclass(classes, [state])\n\nType: `method`\n\nAttiva o disattiva classi CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Le classi. |\n| `state` | `Boolean` | no |  | Forza lo stato. |\n\nReturns: `Component` L'istanza.\n\nExample: Uso di tclass()\n```js\nvar com = FIND('demo');\ncom.tclass('active', true);\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.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` Il risultato.\n\nExample: Uso di hclass()\n```js\nvar com = FIND('demo');\nconsole.log(com.hclass('missing'));  // false\n```\n\n### com.attr(name, [value])\n\nType: `method`\n\nLegge o scrive un attributo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'attributo. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String|Component` Il valore, oppure l'istanza quando passi `value`.\n\nExample: Uso di attr()\n```js\nvar com = FIND('demo');\ncom.attr('title', 'Orders');\nconsole.log(com.attr('title'));  // Orders\n```\n\n### com.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 senza il prefisso `data-`. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String|Component` Il valore, oppure l'istanza quando passi `value`.\n\nExample: Uso di attrd()\n```js\nvar com = FIND('demo');\ncom.attrd('id', '5');\nconsole.log(com.attr('data-id'));  // 5\n```\n\n### com.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 senza il prefisso `data-`. |\n\nReturns: `String` Il valore.\n\nExample: Uso di attrd2()\n```js\nvar com = FIND('demo');\nconsole.log(com.attrd2('group'));  // main\n```\n\n### com.css(name, [value])\n\nType: `method`\n\nLegge o scrive una proprietà CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La proprietà. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String|Component` Il valore, oppure l'istanza quando passi `value`.\n\nExample: Uso di css()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\nconsole.log(com.css('display'));  // block\n```\n\n### com.visible([callback])\n\nType: `method`\n\nIndica se l'elemento è visibile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Viene eseguito quando l'elemento è visibile. |\n\nReturns: `Boolean` La visibilità corrente.\n\nCon un callback, la funzione viene eseguita non appena l'elemento è visibile.\n\nExample: Uso di visible()\n```js\nvar com = FIND('demo');\nconsole.log(com.visible());  // true\n```\n\n### com.width([callback])\n\nType: `method`\n\nRestituisce la larghezza dell'elemento in pixel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Riceve la larghezza. |\n\nReturns: `Number` La larghezza.\n\nCon un callback, la funzione viene eseguita non appena la larghezza è maggiore di zero.\n\nExample: Uso di width()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('width', '200px');\nconsole.log(com.width());  // 200\n```\n\n### com.height([callback])\n\nType: `method`\n\nRestituisce l'altezza dell'elemento in pixel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Riceve l'altezza. |\n\nReturns: `Number` L'altezza.\n\nCon un callback, la funzione viene eseguita non appena l'altezza è maggiore di zero.\n\nExample: Uso di height()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('height', '50px');\nconsole.log(com.height());  // 50\n```\n\n### com.autofocus([selector])\n\nType: `method`\n\nSposta il focus sul primo campo visibile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | I campi. |\n\nReturns: `Component` L'istanza.\n\nIl metodo riprova per un breve periodo quando nessun campo può ricevere il focus. Sui dispositivi mobili non fa nulla.\n\nExample: Uso di autofocus()\n```js\nvar com = FIND('demo');\ncom.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### com.faicon(value)\n\nType: `method`\n\nCompleta il nome di un'icona.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il nome dell'icona. |\n\nReturns: `String` Le classi CSS.\n\nUn nome senza spazi riceve `DEF.iconprefix`, cioè `ti ti-`. Il metodo è disponibile anche come `icon()`.\n\nExample: Uso di faicon()\n```js\nvar com = FIND('demo');\nconsole.log(com.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"init","signature":"self.init = function()","since":"","deprecated":false},{"type":"delegate","name":"done","signature":"self.done = function()","since":"","deprecated":false},{"type":"delegate","name":"released","signature":"self.released = function(hidden)","since":"","deprecated":false},{"type":"delegate","name":"configure","signature":"self.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter","signature":"self.getter(value, [realtime], [nobind])","since":"","deprecated":false},{"type":"delegate","name":"setter2","signature":"self.setter2 = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter2","signature":"self.getter2 = function(value, realtime)","since":"","deprecated":false},{"type":"delegate","name":"state","signature":"self.state = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"state2","signature":"self.state2 = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"validate","signature":"self.validate = function(value, init)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"version","signature":"self.version","since":"","deprecated":false},{"type":"property","name":"id","signature":"self.id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"self.ID","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"type","signature":"self.type","since":"","deprecated":false},{"type":"property","name":"format","signature":"self.format","since":"","deprecated":false},{"type":"property","name":"trim","signature":"self.trim","since":"","deprecated":false},{"type":"property","name":"config","signature":"self.config","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"owner","signature":"self.owner","since":"","deprecated":false},{"type":"property","name":"caller","signature":"self.caller","since":"","deprecated":false},{"type":"property","name":"global","signature":"self.global","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"property","name":"pathscope","signature":"self.pathscope","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"self.plugin","since":"","deprecated":false},{"type":"property","name":"siblings","signature":"self.siblings","since":"","deprecated":false},{"type":"property","name":"removed","signature":"self.removed","since":"","deprecated":false},{"type":"method","name":"get()","signature":"com.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"com.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"com.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"com.inc(value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"com.extend(value, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"com.push(value, [type])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"com.rewrite(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"com.update([type])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"com.refresh([notify], [type])","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"com.notify()","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"com.skip()","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"com.bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"com.reset()","since":"","deprecated":false},{"type":"method","name":"default()","signature":"com.default([reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"com.change([value])","since":"","deprecated":false},{"type":"method","name":"dirty()","signature":"com.dirty([value], [noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"com.isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"com.validate2()","since":"","deprecated":false},{"type":"method","name":"notmodified()","signature":"com.notmodified([fields])","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"com.parser(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"com.formatter(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"parsesource()","signature":"com.parsesource(value)","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"com.reconfigure(value, [callback], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"configdisplay()","signature":"com.configdisplay(key, value)","since":"","deprecated":false},{"type":"method","name":"data()","signature":"com.data(key, [value])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"com.datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"com.watch([path], callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"com.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"on()","signature":"com.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"com.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"com.emit(name, [...args])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"com.command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"com.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"com.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"com.GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"com.SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"com.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"com.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"com.makepath(path)","since":"","deprecated":false},{"type":"method","name":"scopepath()","signature":"com.scopepath(path)","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"com.setPath(path)","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"com.blind()","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"self.readonly()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"self.singleton()","since":"","deprecated":false},{"type":"method","name":"bindchanges()","signature":"self.bindchanges([enable])","since":"","deprecated":false},{"type":"method","name":"bindexact()","signature":"self.bindexact([enable])","since":"","deprecated":false},{"type":"method","name":"bindvisible()","signature":"self.bindvisible([timeout])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"self.autofill([enable])","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"com.caniuse(name)","since":"","deprecated":false},{"type":"method","name":"main()","signature":"com.main()","since":"","deprecated":false},{"type":"method","name":"compile()","signature":"com.compile([container])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"com.import(url, [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"com.replace(element, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"com.remove([noclear])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"com.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"com.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"com.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"com.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"com.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"com.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"com.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"com.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"com.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"com.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"com.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"com.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"com.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"com.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"com.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"com.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"com.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"com.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"com.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"com.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"com.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"com.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUh2gM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/component/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Component","summary":"Delegate, vlastnosti a metódy inštancie komponentu.","markdown":"---\ntitle: Component\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/component/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Component\n\n> Delegate, vlastnosti a metódy inštancie komponentu.\n\nInštancia komponentu je objekt odovzdaný deklarácii `COMPONENT()`. Prepája element s path dátového modelu. Ako ju napísať, vysvetľuje časť [Vytváranie komponentov](../../guides/creating-components/) a element popisuje časť [ui-component](../ui-component/). V príkladoch je `com` inštancia nájdená pomocou `FIND()`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nZostaví obsah komponentu.\n\nDelegate sa spustí raz, po deklarácii, keď je element v DOM.\n\nExample: Definícia make\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.html('<b>Ready</b>');\n        };\n    });\n</script>\n```\n\n### self.init = function()\n\nType: `delegate`\n\nSpustí sa raz pre všetky inštancie komponentu.\n\nTento delegate volá iba prvá inštancia na stránke.\n\nExample: Definícia init\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.init = () => console.log('once');  // once\n    });\n</script>\n```\n\n### self.done = function()\n\nType: `delegate`\n\nSpustí sa po inicializácii inštancie.\n\nDelegate sa spustí po prvých volaniach `setter` a `state`.\n\nExample: Definícia done\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.done = () => console.log('done');  // done\n    });\n</script>\n```\n\n### self.released = function(hidden)\n\nType: `delegate`\n\nUrčuje, či je element pri štarte inštancie skrytý.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `hidden` | `Boolean` | yes |  | `true`, keď je element skrytý. |\n\nDelegate sa spustí raz a pre skrytý element dostane `true`.\n\nExample: Definícia released\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.released = hidden => console.log(hidden);  // false\n    });\n</script>\n```\n\n### self.configure = function(key, value, init, prev)\n\nType: `delegate`\n\nDostáva konfiguračné kľúče.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov kľúča. |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `init` | `Boolean` | yes |  | `true` počas inicializácie. |\n| `prev` | `Object` | yes |  | Predchádzajúca hodnota. |\n\nDelegate sa spustí pre každý kľúč počas inicializácie s `init` nastaveným na `true` a znova pre každý zmenený kľúč. Dostáva aj zmeny kľúčov `modified`, `touched` a `invalid`.\n\nExample: Definícia configure\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.configure = function(key, value, init, prev) {\n            key === 'title' && console.log(value, init);  // Orders true\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nDostáva hodnotu na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na path. |\n| `path` | `String` | yes |  | Path, ktorý sa zmenil. |\n| `type` | `Number` | yes |  | Zdroj zmeny. |\n\nDefinuj ho, ak chceš hodnotu vykresliť. Predvolená implementácia zapíše naformátovanú hodnotu do vnorených polí `input`, `select` a `textarea` s atribútom `data-jc-bind`.\n\nArgument `type` hovorí, odkiaľ zmena pochádza:\n\n| Typ | Zdroj |\n| --- | --- |\n| `0` | Inicializácia. |\n| `1` | Manuálna zmena, napríklad `SET()`. |\n| `2` | Vstup používateľa. |\n| `3` | Predvolená hodnota alebo reset. |\n\nExample: Definícia setter\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter = function(value, path, type) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter(value, [realtime], [nobind])\n\nType: `delegate`\n\nZapíše hodnotu od používateľa na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nespracovaná hodnota. |\n| `realtime` | `Boolean` | no |  | `true`, keď hodnota prichádza počas písania používateľa. |\n| `nobind` | `Boolean` | no |  | `true` overí hodnotu bez jej zápisu. |\n\nPredvolená implementácia spustí parsery a zapíše výsledok. Vnorené polia s atribútom `data-jc-bind` ho volajú automaticky. Ak chceš zapísať hodnotu z vlastných ovládacích prvkov, zavolaj ho z nich.\n\nExample: Definícia getter\n```html\n<ui-component name=\"box\" path=\"form.name\"><button>Set</button></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.make = function() {\n            self.event('click', 'button', () => self.getter('Peter'));\n        };\n    });\n    setTimeout(function() {\n        $('button').click();\n        console.log(GET('form.name'));  // Peter\n    }, 500);\n</script>\n```\n\n### self.setter2 = function(value, path, type)\n\nType: `delegate`\n\nSpustí sa po delegate `setter`.\n\nDostáva rovnaké argumenty. Použi ho, keď chceš rozšíriť komponent a zachovať jeho setter.\n\nExample: Definícia setter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.setter2 = value => value && console.log(value);  // Peter\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.getter2 = function(value, realtime)\n\nType: `delegate`\n\nSpustí sa, keď `getter` dostane hodnotu.\n\nDostáva spracovanú hodnotu a argument `realtime`.\n\nExample: Definícia getter2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.getter2 = value => console.log(value);  // PETER\n        self.parser((path, value) => value.toUpperCase());\n    });\n    setTimeout(() => FIND('box').getter('peter'), 500);\n</script>\n```\n\n### self.state = function(type, what)\n\nType: `delegate`\n\nSpustí sa pri zmene stavu inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | yes |  | Zdroj zmeny. |\n| `what` | `Number` | yes |  | Druh zmeny. |\n\nArgument `type` je `0` pri inicializácii, `1` pri manuálnej zmene a `2` pri vstupe používateľa.\n\nArgument `what` hovorí, čo sa stalo:\n\n| Čo | Význam |\n| --- | --- |\n| `1` | Validácia. |\n| `2` | Zmenil sa stav dotknutia. |\n| `3` | Reset. |\n| `4` | Aktualizácia. |\n| `5` | Nová hodnota. |\n| `6` | Upozornenie. |\n\nExample: Definícia state\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state = function(type, what) {\n            console.log(type, what);  // 0 3\n        };\n    });\n</script>\n```\n\n### self.state2 = function(type, what)\n\nType: `delegate`\n\nSpustí sa po delegate `state`.\n\nDostáva rovnaké argumenty.\n\nExample: Definícia state2\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.state2 = (type, what) => console.log(type, what);  // 0 3\n    });\n</script>\n```\n\n### self.validate = function(value, init)\n\nType: `delegate`\n\nRozhodne, či je hodnota platná.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na path. |\n| `init` | `Boolean` | no |  | `true` počas inicializácie. |\n\nPre platnú hodnotu vráť `true`. Výsledok sa uloží do `config.invalid`.\n\nExample: Definícia validate\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self, config) {\n        self.validate = value => !!value;\n        self.done = () => console.log(config.invalid);  // true\n    });\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nSpúšťa sa raz za minútu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Počet spustení. |\n\nDelegate dostáva počítadlo, ktoré sa pri každom spustení zvýši o jednotku.\n\n### self.destroy = function()\n\nType: `delegate`\n\nSpustí sa pri odstránení inštancie.\n\nTu uvoľni časovače a externých poslucháčov.\n\nExample: Definícia destroy\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\n    COMPONENT('box', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => FIND('box').remove(), 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nNázov komponentu s jeho verziou.\n\nExample: Čítanie name\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.name));  // box@2\n</script>\n```\n\n### self.version\n\nType: `property`\n\nVerzia z názvu komponentu.\n\nAk názov nemá verziu, hodnota je prázdna. Element tiež dostane triedu `jc-v{version}`.\n\nExample: Čítanie version\n```html\n<ui-component name=\"box@2\"></ui-component>\n<script>\n    COMPONENT('box@2', self => console.log(self.version));  // 2\n</script>\n```\n\n### self.id\n\nType: `property`\n\nIdentifikátor inštancie.\n\nNastavuje ho konfiguračný kľúč [`$id`](../ui-component/#x-id). Inak má rovnakú hodnotu ako `ID`.\n\nExample: Čítanie id\n```html\n<ui-component name=\"box\" config=\"$id:orders\"></ui-component>\n<script>\n    COMPONENT('box', self => self.make = () => console.log(self.id));  // orders\n</script>\n```\n\n### self.ID\n\nType: `property`\n\nJedinečný vygenerovaný identifikátor inštancie.\n\nExample: Čítanie ID\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.ID.substring(0, 2)));  // jc\n</script>\n```\n\n### self.path\n\nType: `property`\n\nPath dátového modelu naviazaná na inštanciu.\n\nAk komponent nemá path, hodnota je prázdna.\n\nExample: Čítanie path\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.path));  // form.name\n</script>\n```\n\n### self.type\n\nType: `property`\n\nDátový typ inštancie.\n\nHodnota sa odovzdáva parserom a formátovačom. Nastav ju v deklarácii alebo kľúčom [`$type`](../ui-component/#x-type).\n\nExample: Čítanie type\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.type = 'number';\n        self.parser((path, value, type) => console.log(type));  // number\n        self.make = () => self.parser('1');\n    });\n</script>\n```\n\n### self.format\n\nType: `property`\n\nFormát odovzdávaný parserom a formátovačom.\n\nKeď je vlastnosť prázdna, použije sa `config.format`.\n\nExample: Čítanie format\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.format = 'dd.MM.yyyy';\n        self.formatter((path, value, type, format) => console.log(format));  // dd.MM.yyyy\n        self.make = () => self.formatter('1');\n    });\n</script>\n```\n\n### self.trim\n\nType: `property`\n\nV parseri odstráni medzery okolo textu.\n\nPredvolená hodnota je `true`.\n\nExample: Čítanie trim\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.trim = false;\n        self.make = () => console.log(self.parser('  A  ').length);  // 5\n    });\n</script>\n```\n\n### self.config\n\nType: `property`\n\nKonfiguračný objekt.\n\nObsahuje aj stavové kľúče `modified`, `touched`, `invalid` a, ak je nastavený, `disabled`.\n\nExample: Čítanie config\n```html\n<ui-component name=\"box\" config=\"title:Orders\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.config.title, self.config.touched));  // Orders false\n</script>\n```\n\n### self.element\n\nType: `property`\n\nElement inštancie ako objekt jQuery.\n\nExample: Čítanie element\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.element.prop('tagName')));  // UI-COMPONENT\n</script>\n```\n\n### self.dom\n\nType: `property`\n\nElement inštancie ako uzol DOM.\n\nExample: Čítanie dom\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', self => console.log(self.dom.tagName));  // UI-COMPONENT\n</script>\n```\n\n### self.owner\n\nType: `property`\n\nNajbližší nadradený komponent.\n\nAk komponent nemá nadradený komponent, vlastnosť chýba.\n\nExample: Čítanie owner\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', self => console.log(self.owner.name));  // parent\n</script>\n```\n\n### self.caller\n\nType: `property`\n\nKomponent, ktorý zavolal túto inštanciu cez `exec()`.\n\nExample: Čítanie caller\n```html\n<ui-component name=\"parent\"><ui-component name=\"child\"></ui-component></ui-component>\n<script>\n    COMPONENT('parent', function(self) {});\n    COMPONENT('child', function(self) {\n        self.ping = () => console.log(self.caller.name);  // parent\n    });\n    setTimeout(() => FIND('parent').exec('ping'), 500);\n</script>\n```\n\n### self.global\n\nType: `property`\n\nObjekt zdieľaný všetkými inštanciami komponentu.\n\nExample: Čítanie global\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {\n        self.global.count = (self.global.count || 0) + 1;\n    });\n    setTimeout(() => console.log(FIND('box').global.count), 500);  // 2\n</script>\n```\n\n### self.scope\n\nType: `property`\n\n[Scope](../scope/) inštancie.\n\nVlastnosť existuje, keď path obsahuje `?`.\n\nExample: Čítanie scope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.scope.path));  // users\n</script>\n```\n\n### self.pathscope\n\nType: `property`\n\nPath scopu inštancie.\n\nVlastnosť existuje, keď path obsahuje `?`.\n\nExample: Čítanie pathscope\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.pathscope));  // users\n</script>\n```\n\n### self.plugin\n\nType: `property`\n\n[Plugin](../plugin/) scopu inštancie.\n\nVlastnosť existuje, keď path obsahuje `?`.\n\nExample: Čítanie plugin\n```html\n<ui-plugin path=\"users\"><ui-component name=\"box\" path=\"?.name\"></ui-component></ui-plugin>\n<script>\n    PLUGIN('users', function(exports) {});\n    COMPONENT('box', self => console.log(self.plugin.name));  // users\n</script>\n```\n\n### self.siblings\n\nType: `property`\n\nUrčuje, či element hostí viacero komponentov.\n\nExample: Čítanie siblings\n```html\n<ui-component name=\"a,b\"></ui-component>\n<script>\n    COMPONENT('a', self => console.log(self.siblings));  // true\n    COMPONENT('b', function(self) {});\n</script>\n```\n\n### self.removed\n\nType: `property`\n\nUrčuje, či bola inštancia odstránená.\n\nExample: Čítanie removed\n```html\n<ui-component name=\"box\"></ui-component>\n<script>\n    COMPONENT('box', function(self) {});\n    setTimeout(function() {\n        var com = FIND('box');\n        com.remove();\n        console.log(com.removed);  // true\n    }, 500);\n</script>\n```\n\n### com.get([path])\n\nType: `method`\n\nVráti hodnotu na naviazanej path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Iná path. |\n\nReturns: `Object` Hodnota.\n\nS argumentom metóda prečíta inú path.\n\nExample: Použitie get()\n```js\nvar com = FIND('demo');\nSET('form.name', 'Peter');\nconsole.log(com.get());  // Peter\n```\n\n### com.set(value, [type])\n\nType: `method`\n\nZapíše hodnotu na naviazanú path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `type` | `Number` | no |  | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nInštancia sa označí ako upravená.\n\nExample: Použitie set()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(GET('form.name'), com.config.modified);  // Peter true\n```\n\n### com.modify(value, [type])\n\nType: `method`\n\nZapíše hodnotu cez parsery.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nespracovaná hodnota. |\n| `type` | `Number` | no | `2` | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nInštancia sa označí ako dotknutá.\n\nExample: Použitie modify()\n```js\nvar com = FIND('demo');\ncom.modify('  Peter  ');\nconsole.log(GET('form.name'), com.config.touched);  // Peter true\n```\n\n### com.inc(value, [type])\n\nType: `method`\n\nZvýši číslo uložené na naviazanej path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number` | yes |  | Prírastok. |\n| `type` | `Number` | no |  | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie inc()\n```js\nvar com = FIND('demo');\ncom.set(5);\ncom.inc(2);\nconsole.log(GET('form.name'));  // 7\n```\n\n### com.extend(value, [type])\n\nType: `method`\n\nZlúči objekt do naviazanej path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Polia na zlúčenie. |\n| `type` | `Number` | no |  | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie extend()\n```js\nvar com = FIND('demo');\ncom.set({ a: 1 });\ncom.extend({ b: 2 });\nconsole.log(GET('form.name'));  // {\"a\":1,\"b\":2}\n```\n\n### com.push(value, [type])\n\nType: `method`\n\nPridá položku do poľa uloženého na naviazanej path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Položka. |\n| `type` | `Number` | no |  | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie push()\n```js\nvar com = FIND('demo');\ncom.push('A');\ncom.push('B');\nconsole.log(GET('form.name'));  // [\"A\",\"B\"]\n```\n\n### com.rewrite(value, [type])\n\nType: `method`\n\nZapíše hodnotu bez upozornenia kohokoľvek.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `type` | `Number` | no |  | Typ zmeny. |\n\nReturns: `Component` Inštancia.\n\nNaviazané komponenty, bindery a sledovače sa nezavolajú.\n\nExample: Použitie rewrite()\n```js\nvar com = FIND('demo');\ncom.rewrite('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### com.update([type])\n\nType: `method`\n\nZnova zapíše aktuálnu hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number` | no |  | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nUpozornia sa všetci poslucháči path.\n\nExample: Použitie update()\n```js\nvar com = FIND('demo');\ncom.watch(function(path, value) {\n    console.log(value);  // Peter\n});\nwindow.form.name = 'Peter';\ncom.update();\n```\n\n### com.refresh([notify], [type])\n\nType: `method`\n\nZavolá setter tejto inštancie s aktuálnou hodnotou.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `notify` | `Boolean` | no |  | `true` upozorní všetkých poslucháčov. |\n| `type` | `Number|String` | no |  | Typ odovzdaný setteru. |\n\nReturns: `Component` Inštancia.\n\nS `notify` sa hodnota zapíše na path a upozornia sa všetci poslucháči.\n\nExample: Použitie refresh()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.refresh();\nconsole.log(com.text());  // Peter\n```\n\n### com.notify()\n\nType: `method`\n\nUpozorní poslucháčov presne naviazanej path.\n\nReturns: `Component` Inštancia.\n\nMetóda zavolá `NOTIFY()` s path inštancie.\n\nExample: Použitie notify()\n```js\nvar com = FIND('demo');\nwindow.form.name = 'Peter';\ncom.notify();\nconsole.log(com.text());  // Peter\n```\n\n### com.skip()\n\nType: `method`\n\nPreskočí nasledujúce volanie setteru.\n\nReturns: `Component` Inštancia.\n\nExample: Použitie skip()\n```js\nvar com = FIND('demo');\ncom.skip();\ncom.set('Peter');\nsetTimeout(() => console.log(com.text() || 'empty'), 500);  // empty\n```\n\n### com.bind(flags, [value])\n\nType: `method`\n\nZmení stav a voliteľne zapíše hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Flagy. |\n| `value` | `Object` | no |  | Hodnota na zápis. |\n\nArgument `flags` je zoznam slov oddelených medzerou, čiarkou alebo `|`. Voliteľná predpona `@` sa ignoruje.\n\n| Flag | Účinok |\n| --- | --- |\n| `touched`, `touch` | Označí inštanciu ako dotknutú. |\n| `modified`, `modify`, `changed`, `change` | Označí inštanciu ako upravenú. |\n| `reset` | Vymaže stav dotknutia a úpravy. |\n| `validate` | Overí hodnotu. |\n| `setter` | Zavolá setter. |\n\nKeď odovzdáš `value`, zapíše sa na path a setter tejto inštancie sa spustí iba s flagom `setter`.\n\nExample: Použitie bind()\n```js\nvar com = FIND('demo');\ncom.bind('@touched @modified', 'Peter');\nconsole.log(GET('form.name'), com.config.touched, com.config.modified);  // Peter true true\n```\n\n### com.reset()\n\nType: `method`\n\nVymaže stav dotknutia a úpravy.\n\nReturns: `Component` Inštancia.\n\nHodnota sa znova overí.\n\nExample: Použitie reset()\n```js\nvar com = FIND('demo');\ncom.modify('Peter');\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);  // false false\n```\n\n### com.default([reset])\n\nType: `method`\n\nObnoví predvolenú hodnotu inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `reset` | `Boolean` | no | `true` | `false` zachová stav inštancie. |\n\nReturns: `Component` Inštancia.\n\nPredvolená hodnota pochádza z atribútu [`default`](../ui-component/#default).\n\nExample: Použitie default()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\ncom.default();\nconsole.log(GET('form.name'));  // Anonymous\n```\n\n### com.change([value])\n\nType: `method`\n\nNastaví stav dotknutia a úpravy komponentov na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no | `true` | Nový stav. |\n\nReturns: `Component` Inštancia.\n\nMetóda sa vzťahuje na všetky komponenty naviazané na path a na jej vnorené path. Metóda je dostupná aj ako `touched()`.\n\nExample: Použitie change()\n```js\nvar com = FIND('demo');\ncom.change();\nconsole.log(com.config.touched, com.config.modified);  // true true\n```\n\n### com.dirty([value], [noemit])\n\nType: `method`\n\nPrečíta alebo nastaví stav nedotknutia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Boolean` | no |  | `false` označí inštanciu ako dotknutú. |\n| `noemit` | `Boolean` | no |  | `true` preskočí delegate `state`. |\n\nReturns: `Boolean|Component` Stav, alebo inštancia, keď odovzdáš `value`.\n\nBez argumentov metóda vráti `true` pre nedotknutú inštanciu.\n\nExample: Použitie dirty()\n```js\nvar com = FIND('demo');\nconsole.log(com.dirty());  // true\ncom.dirty(false);\nconsole.log(com.config.touched);  // true\n```\n\n### com.isInvalid()\n\nType: `method`\n\nUrčuje, či je inštancia dotknutá a neplatná.\n\nReturns: `Boolean` Výsledok.\n\nExample: Použitie isInvalid()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\ncom.modify('');\ncom.validate2();\ncom.bind('touched');\nconsole.log(com.isInvalid());  // true\n```\n\n### com.validate2()\n\nType: `method`\n\nSpustí delegate `validate` a aktualizuje stav.\n\nReturns: `Boolean` `true` pre platnú hodnotu.\n\nExample: Použitie validate2()\n```js\nvar com = FIND('demo');\ncom.validate = value => !!value;\nconsole.log(com.validate2());  // false\n```\n\n### com.notmodified([fields])\n\nType: `method`\n\nUrčuje, či je hodnota rovnaká ako pri poslednej kontrole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fields` | `String|Array` | no |  | Polia na porovnanie. |\n\nReturns: `Boolean` `true`, keď sa hodnota nezmenila.\n\nPrvá kontrola vráti `false`.\n\nExample: Použitie notmodified()\n```js\nvar com = FIND('demo');\ncom.set('Peter');\nconsole.log(com.notmodified());  // false\nconsole.log(com.notmodified());  // true\n```\n\n### com.parser(value, [prepend])\n\nType: `method`\n\nPridá parser alebo spracuje hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Parser alebo hodnota na spracovanie. |\n| `prepend` | `Boolean` | no |  | `true` pridá parser na začiatok. |\n\nReturns: `Object` Spracovaná hodnota, alebo inštancia, keď sa pridáva parser.\n\nFunkcia sa pridá medzi parsery inštancie. Dostane `path`, `value`, `type` a `format` a vráti novú hodnotu. Akýkoľvek iný argument sa spracuje a vráti.\n\nExample: Použitie parser()\n```js\nvar com = FIND('demo');\ncom.parser((path, value) => value.toUpperCase());\nconsole.log(com.parser('peter'));  // PETER\n```\n\n### com.formatter(value, [prepend])\n\nType: `method`\n\nPridá formátovač alebo naformátuje hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Function|Object` | yes |  | Formátovač alebo hodnota na naformátovanie. |\n| `prepend` | `Boolean` | no |  | `true` pridá formátovač na začiatok. |\n\nReturns: `Object` Naformátovaná hodnota, alebo inštancia, keď sa pridáva formátovač.\n\nFunkcia sa pridá medzi formátovače inštancie. Dostane `path`, `value`, `type` a `format` a vráti novú hodnotu. Akýkoľvek iný argument sa naformátuje a vráti.\n\nExample: Použitie formatter()\n```js\nvar com = FIND('demo');\ncom.formatter((path, value) => value + '!');\nconsole.log(com.formatter('Peter'));  // Peter!\n```\n\n### com.parsesource(value)\n\nType: `method`\n\nPrevedie textový zoznam na pole položiek.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Zoznam. |\n\nReturns: `Array` Objekty s `id`, `name` a `icon`.\n\nPoložky sú oddelené čiarkou. Každá položka má tvar `id|name|icon`. Keď má inštancia typ `number`, identifikátory sa prevedú na čísla.\n\nExample: Použitie parsesource()\n```js\nvar com = FIND('demo');\nconsole.log(com.parsesource('1|One,2|Two|home')[1]);  // {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n\n### com.reconfigure(value, [callback], [init], [noemit])\n\nType: `method`\n\nZmení konfiguráciu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Konfigurácia. |\n| `callback` | `Function` | no |  | Dostane `key`, `value`, `init` a `prev` namiesto delegate `configure`. |\n| `init` | `Boolean` | no |  | Argument `init` delegate. |\n| `noemit` | `Boolean` | no |  | `true` preskočí delegate. |\n\nReturns: `Component` Inštancia.\n\nHodnota môže byť reťazec dvojíc `key:value`, objekt alebo `=path` na načítanie objektu z path. Delegate `configure` dostane každý kľúč.\n\nExample: Použitie reconfigure()\n```js\nvar com = FIND('demo');\ncom.reconfigure('title:Orders;limit:10');\nconsole.log(com.config.title, com.config.limit);  // Orders 10\n```\n\n### com.configdisplay(key, value)\n\nType: `method`\n\nVyhodnotí hodnotu, ktorá závisí od displeja.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov kľúča. |\n| `value` | `Object` | yes |  | Hodnota. |\n\nReturns: `Object` Vyhodnotená hodnota.\n\nHodnota má tvar `@xs=1,@md=2`. Ostatné hodnoty sa vrátia bez zmeny. Pozri [Responzívna konfigurácia](../ui-component/#responsive-configuration).\n\nExample: Použitie configdisplay()\n```js\nvar com = FIND('demo');\nconsole.log(com.configdisplay('size', '@xs=1,@lg=4'), WIDTH());  // 1 xs\n```\n\n### com.data(key, [value])\n\nType: `method`\n\nPrečíta alebo zapíše údaje inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov kľúča. |\n| `value` | `Object` | no |  | Hodnota na zápis. |\n\nReturns: `Object` Hodnota.\n\nVnorené elementy čítajú kľúče pomocou path `@key`. Prázdny kľúč je aktuálna hodnota inštancie.\n\nExample: Použitie data()\n```js\nvar com = FIND('demo');\ncom.data('title', 'Orders');\nconsole.log(com.data('title'));  // Orders\n```\n\n### com.datasource(path, callback, [init])\n\nType: `method`\n\nSleduje path, na ktorej je zdroj údajov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path zdroja údajov. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostáva údaje. |\n| `init` | `Boolean` | no | `true` | `false` preskočí úvodné volanie. |\n\nReturns: `Component` Inštancia.\n\nCallback dostane `path`, `value` a `type`. Ak `init` nie je `false`, spustí sa aj po načítaní konfigurácie. Nové volanie nahradí predchádzajúci zdroj údajov.\n\nExample: Použitie datasource()\n```js\nvar com = FIND('demo');\ncom.datasource('common.items', function(path, value) {\n    console.log(value);  // [1,2]\n}, false);\nSET('common.items', [1, 2]);\n```\n\n### com.watch([path], callback, [init])\n\nType: `method`\n\nSleduje path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Path, ktorý sa má sledovať. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostáva zmeny. |\n| `init` | `Boolean` | no |  | `true` zavolá callback okamžite. |\n\nReturns: `Component` Inštancia.\n\nCallback dostane `path`, `value` a `type` a `this` je inštancia. Bez path metóda sleduje path inštancie. Sledovač sa odstráni spolu s inštanciou.\n\nExample: Použitie watch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', function(path, value) {\n    console.log(path, value);  // form.age 30\n});\nSET('form.age', 30);\n```\n\n### com.unwatch(path)\n\nType: `method`\n\nOdstráni sledovače path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Sledovaný path. |\n\nReturns: `Component` Inštancia.\n\nMetóda odstráni všetky sledovače, ktoré má táto inštancia na danej path.\n\nExample: Použitie unwatch()\n```js\nvar com = FIND('demo');\ncom.watch('form.age', () => console.log('called'));\ncom.unwatch('form.age');\nSET('form.age', 30);\nconsole.log('end');  // end\n```\n\n### com.on(name, callback)\n\nType: `method`\n\nPočúva globálnu udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | yes |  | Poslucháč. |\n\nReturns: `Component` Inštancia.\n\nPoslucháč sa odstráni spolu s inštanciou. Predpona `^` v názve zaradí poslucháča na prvé miesto.\n\nExample: Použitie on()\n```js\nvar com = FIND('demo');\ncom.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### com.off(name, [callback])\n\nType: `method`\n\nOdstráni poslucháča globálnej udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | no |  | Poslucháč. |\n\nReturns: `Component` Inštancia.\n\nBez callbacku sa odstránia všetci poslucháči udalosti v tejto inštancii.\n\nExample: Použitie off()\n```js\nvar com = FIND('demo');\nvar fn = () => console.log('called');\ncom.on('saved', fn);\ncom.off('saved', fn);\nconsole.log(EMIT('saved'));  // false\n```\n\n### com.emit(name, [...args])\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| `args` | `Object` | no |  | Argumenty udalosti. |\n\nReturns: `Component` Inštancia.\n\nMetóda volá `EMIT()`.\n\nExample: Použitie emit()\n```js\nvar com = FIND('demo');\nON('saved', value => console.log(value));  // 5\ncom.emit('saved', 5);\n```\n\n### com.command(name, callback)\n\nType: `method`\n\nZaregistruje príkaz 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\nReturns: `Component` Inštancia.\n\nPredpona `^` v názve zaradí obslužnú funkciu na prvé miesto. Príkazy volá [`CMD()`](#cmd) alebo globálna funkcia `CMD()`.\n\nExample: Použitie command()\n```js\nvar com = FIND('demo');\ncom.command('clear', () => console.log('cleared'));  // cleared\nCMD('clear');\n```\n\n### com.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nZavolá príkaz tejto inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov príkazu. |\n\nReturns: `Component` Inštancia.\n\nMetóda prijíma najviac päť argumentov.\n\nExample: Použitie CMD()\n```js\nvar com = FIND('demo');\ncom.command('add', (a, b) => console.log(a + b));  // 3\ncom.CMD('add', 1, 2);\n```\n\n### com.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nZavolá metódu všetkých vnorených komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov metódy. |\n\nReturns: `Component` Inštancia.\n\nKaždý vnorený komponent dostane túto inštanciu v `caller`.\n\nExample: Použitie exec()\n```js\nvar com = FIND('demo');\ncom.exec('ping', 5);\n```\n\n### com.GET(path)\n\nType: `method`\n\nPrečíta path relatívnu k scopu inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `Object` Hodnota.\n\nZnak `?` sa nahradí za path scopu.\n\nExample: Použitie GET()\n```js\nvar com = FIND('demo');\nSET('users.name', 'Peter');\nconsole.log(com.GET('?.name'));  // Peter\n```\n\n### com.SET(path, value)\n\nType: `method`\n\nZapíše na path relatívnu k scopu inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Object` | yes |  | Hodnota. |\n\nZnak `?` sa nahradí za path scopu.\n\nExample: Použitie SET()\n```js\nvar com = FIND('demo');\ncom.SET('?.age', 30);\nconsole.log(GET('users.age'));  // 30\n```\n\n### com.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá funkciu podľa jej path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path funkcie. |\n\nReturns: `Component` Inštancia.\n\nZnak `?` sa nahradí za path scopu. Path s predponou `@` zavolá metódu nadradeného komponentu.\n\nExample: Použitie EXEC()\n```js\nvar com = FIND('child');\ncom.EXEC('@ping', 5);\n```\n\n### com.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá funkciu alebo zapíše hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `Component` Inštancia.\n\nMetóda zavolá funkciu na path. Keď na path nie je žiadna funkcia, zapíše sa na ňu prvý argument. Predpona `@` funguje s nadradeným komponentom.\n\nExample: Použitie SEEX()\n```js\nvar com = FIND('child');\ncom.SEEX('@title', 'Orders');\nconsole.log(FIND('demo').title);  // Orders\n```\n\n### com.makepath(path)\n\nType: `method`\n\nPreloží path v scope inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `String` Preložená path.\n\nExample: Použitie makepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.makepath('?.age'));  // users.age\n```\n\n### com.scopepath(path)\n\nType: `method`\n\nNahradí `?` v path za path scopu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `String` Preložená path.\n\nPath bez `?` sa vráti bez zmeny.\n\nExample: Použitie scopepath()\n```js\nvar com = FIND('demo');\nconsole.log(com.scopepath('?.age'), com.scopepath('form.age'));  // users.age form.age\n```\n\n### com.setPath(path)\n\nType: `method`\n\nZmení naviazanú path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Nový path. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie setPath()\n```js\nvar com = FIND('demo');\ncom.setPath('form.other');\nSET('form.other', 5);\nconsole.log(com.path, com.get());  // form.other 5\n```\n\n### com.blind()\n\nType: `method`\n\nOdpojí inštanciu od jej path.\n\nReturns: `Component` Inštancia.\n\nExample: Použitie blind()\n```js\nvar com = FIND('demo');\ncom.blind();\nSET('form.name', 'Peter');\nconsole.log(com.path, com.text() || 'empty');  // null empty\n```\n\n### self.readonly()\n\nType: `method`\n\nOdstráni delegate `setter`, `getter` a `validate`.\n\nReturns: `Component` Inštancia.\n\nPouži ju v komponentoch, ktoré iba zobrazujú obsah.\n\nExample: Použitie readonly()\n```js\nvar com = FIND('demo');\nconsole.log(com.setter, com.getter);  // null null\n```\n\n### self.singleton()\n\nType: `method`\n\nPovolí na stránke iba jednu inštanciu komponentu.\n\nReturns: `Component` Inštancia.\n\nOstatné elementy toho istého komponentu sa odstránia.\n\nExample: Použitie singleton()\n```js\nconsole.log(FIND('demo', true).length, $('ui-component').length);  // 1 1\n```\n\n### self.bindchanges([enable])\n\nType: `method`\n\nPreskočí setter, keď sa hodnota nezmenila.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` túto funkciu vypne. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie bindchanges()\n```js\nSET('form.name', 'A');\nSET('form.name', 'A');\nsetTimeout(() => console.log(window.calls), 500);  // 2\n```\n\n### self.bindexact([enable])\n\nType: `method`\n\nIgnoruje zmeny vnorených path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` túto funkciu vypne. |\n\nReturns: `Component` Inštancia.\n\nSetter sa spustí iba pre presnú path alebo jej nadradené path.\n\nExample: Použitie bindexact()\n```js\nSET('form.user.name', 'Peter');\nsetTimeout(() => console.log(window.calls), 500);  // 1\n```\n\n### self.bindvisible([timeout])\n\nType: `method`\n\nOdloží setter, kým nebude element viditeľný.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `timeout` | `Number|Boolean` | no | `DEF.delaybinder` | Oneskorenie v milisekundách po tom, ako sa element stane viditeľným. `false` túto funkciu vypne. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie bindvisible()\n```js\nSET('form.name', 'Peter');\nsetTimeout(() => $('#tab').show(), 500);\nsetTimeout(() => console.log($('ui-component').text()), 1500);  // Peter\n```\n\n### self.autofill([enable])\n\nType: `method`\n\nPrečíta hodnoty vyplnené prehliadačom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enable` | `Boolean` | no | `true` | `false` túto funkciu vypne. |\n\nReturns: `Component` Inštancia.\n\nKeď je stránka pripravená, hodnota vnorených polí s atribútom `data-jc-bind` sa zapíše na path.\n\nExample: Použitie autofill()\n```js\n$('input').val('Peter');\nsetTimeout(() => console.log(GET('form.name')), 1400);  // Peter\n```\n\n### com.caniuse(name)\n\nType: `method`\n\nUrčuje, či je komponent dostupný.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov komponentu. |\n\nReturns: `Number` `1` pre deklarovaný komponent, `2` pre lazy komponent, `undefined` pre neznámy komponent.\n\nExample: Použitie caniuse()\n```js\nvar com = FIND('demo');\nconsole.log(com.caniuse('demo'));  // 1\n```\n\n### com.main()\n\nType: `method`\n\nVráti najbližší nadradený komponent.\n\nReturns: `Component` Nadradený komponent alebo `null`.\n\nExample: Použitie main()\n```js\nvar com = FIND('child');\nconsole.log(com.main().name);  // demo\n```\n\n### com.compile([container])\n\nType: `method`\n\nSkompiluje nový obsah elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `container` | `jQuery|Element` | no | `the component element` | Element, ktorý sa má skompilovať. |\n\nReturns: `Component` Inštancia.\n\nZavolaj ju po pridaní elementov s väzbami alebo komponentmi.\n\nExample: Použitie compile()\n```js\nvar com = FIND('demo');\ncom.append('<div data-bind=\"form.name__text\"></div>');\ncom.compile();\nSET('form.name', 'Peter');\nsetTimeout(() => console.log(com.find('div').text()), 500);  // Peter\n```\n\n### com.import(url, [callback], [insert], [preparator])\n\nType: `method`\n\nImportuje obsah do elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL. |\n| `callback` | `Function` | no |  | Spustí sa po importe. |\n| `insert` | `Boolean` | no |  | Argument `insert` funkcie `IMPORT()`. |\n| `preparator` | `Function` | no |  | Zmení odpoveď pred vložením. |\n\nReturns: `Component` Inštancia.\n\nMetóda zavolá `IMPORT()` s elementom ako cieľom.\n\nExample: Použitie import()\n```js\nvar com = FIND('demo');\ncom.import('/part.html', () => console.log('imported'));  // imported\n```\n\n### com.replace(element, [remove])\n\nType: `method`\n\nPresunie inštanciu na iný element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Nový element. |\n| `remove` | `Boolean` | no |  | `true` odstráni pôvodný element. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie replace()\n```js\nvar com = FIND('demo');\ncom.replace($('#target'), true);\nconsole.log(com.dom.id, $('ui-component').length);  // target 0\n```\n\n### com.remove([noclear])\n\nType: `method`\n\nOdstráni inštanciu a jej element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noclear` | `Boolean` | no |  | `true` nespustí čistenie okamžite. |\n\nReturns: `Boolean` Vždy `true`.\n\nPočas čistenia sa spustí delegate `destroy`. Metóda je dostupná aj ako `kill()`.\n\nExample: Použitie remove()\n```js\nvar com = FIND('demo');\nconsole.log(com.remove());  // true\n```\n\n### com.find(selector)\n\nType: `method`\n\nNájde vnorené elementy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Selektor alebo objekt selektorov. |\n\nReturns: `jQuery|Object` Výsledok.\n\nObjekt selektorov vráti objekt výsledkov jQuery s rovnakými kľúčmi.\n\nExample: Použitie find()\n```js\nvar com = FIND('demo');\nconsole.log(com.find('.label').text());  // Text\n```\n\n### com.closest(selector)\n\nType: `method`\n\nNájde najbližší zodpovedajúci nadradený element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor. |\n\nReturns: `jQuery` Výsledok.\n\nExample: Použitie closest()\n```js\nvar com = FIND('demo');\nconsole.log(com.closest('body').length);  // 1\n```\n\n### com.parent([selector])\n\nType: `method`\n\nVráti nadradený element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Selektor. |\n\nReturns: `jQuery` Výsledok.\n\nArgument môže byť:\n\n| Hodnota | Výsledok |\n| --- | --- |\n| vynechaný | Priamy nadradený element. |\n| Selektor | Najbližší zodpovedajúci element. |\n| `auto` | Najbližší nadradený element s definovanou výškou, inak `window`. |\n| `window` | `window` ako objekt jQuery. |\n| `document` | Objekt `document`. |\n| `parent` | Priamy nadradený element. |\n| `parent2` | Element o dve úrovne nad priamym nadradeným elementom. |\n\nExample: Použitie parent()\n```js\nvar com = FIND('demo');\nconsole.log(com.parent().prop('tagName'));  // BODY\n```\n\n### com.html([value])\n\nType: `method`\n\nPrečíta alebo nahradí obsah HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Nový obsah. |\n\nReturns: `String|jQuery` Obsah, alebo element, keď odovzdáš `value`.\n\nPole sa spojí.\n\nExample: Použitie html()\n```js\nvar com = FIND('demo');\ncom.html('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.text([value])\n\nType: `method`\n\nPrečíta alebo nahradí textový obsah.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Nový obsah. |\n\nReturns: `String|jQuery` Obsah, alebo element, keď odovzdáš `value`.\n\nPole sa spojí.\n\nExample: Použitie text()\n```js\nvar com = FIND('demo');\ncom.text('<b>A</b>');\nconsole.log(com.html());  // &lt;b&gt;A&lt;/b&gt;\n```\n\n### com.append(value)\n\nType: `method`\n\nPridá obsah na koniec elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Obsah. |\n\nReturns: `jQuery` Element.\n\nPole sa spojí.\n\nExample: Použitie append()\n```js\nvar com = FIND('demo');\ncom.empty();\ncom.append('<b>A</b>');\nconsole.log(com.html());  // <b>A</b>\n```\n\n### com.empty()\n\nType: `method`\n\nOdstráni obsah elementu.\n\nReturns: `jQuery` Element.\n\nOdstránia sa aj vnorené komponenty.\n\nExample: Použitie empty()\n```js\nvar com = FIND('demo');\ncom.empty();\nconsole.log(com.html() === '');  // true\n```\n\n### com.event(name, [selector], callback)\n\nType: `method`\n\nPripojí k elementu udalosť jQuery.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `selector` | `String` | no |  | Delegovaný selektor. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nReturns: `Component` Inštancia.\n\nArgumenty sú rovnaké ako pri metóde jQuery `on()`.\n\nExample: Použitie event()\n```js\nvar com = FIND('demo');\ncom.event('click', '.label', () => console.log('clicked'));  // clicked\ncom.find('.label').click();\n```\n\n### com.aclass(classes, [timeout])\n\nType: `method`\n\nPridá triedy CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Triedy. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie aclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.rclass([classes], [timeout])\n\nType: `method`\n\nOdstráni triedy CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Triedy. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `Component` Inštancia.\n\nBez argumentu sa odstránia všetky triedy.\n\nExample: Použitie rclass()\n```js\nvar com = FIND('demo');\ncom.aclass('active');\ncom.rclass('active');\nconsole.log(com.hclass('active'));  // false\n```\n\n### com.rclass2(search)\n\nType: `method`\n\nOdstráni triedy CSS, ktoré obsahujú zadaný text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Text alebo regulárny výraz. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie rclass2()\n```js\nvar com = FIND('demo');\ncom.aclass('col-1 col-2');\ncom.rclass2('col-');\nconsole.log(com.hclass('col-1'));  // false\n```\n\n### com.tclass(classes, [state])\n\nType: `method`\n\nPrepne triedy CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Triedy. |\n| `state` | `Boolean` | no |  | Vynúti stav. |\n\nReturns: `Component` Inštancia.\n\nExample: Použitie tclass()\n```js\nvar com = FIND('demo');\ncom.tclass('active', true);\nconsole.log(com.hclass('active'));  // true\n```\n\n### com.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` Výsledok.\n\nExample: Použitie hclass()\n```js\nvar com = FIND('demo');\nconsole.log(com.hclass('missing'));  // false\n```\n\n### com.attr(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše atribút.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Atribút. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Component` Hodnota, alebo inštancia, keď odovzdáš `value`.\n\nExample: Použitie attr()\n```js\nvar com = FIND('demo');\ncom.attr('title', 'Orders');\nconsole.log(com.attr('title'));  // Orders\n```\n\n### com.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 bez prefixu `data-`. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Component` Hodnota, alebo inštancia, keď odovzdáš `value`.\n\nExample: Použitie attrd()\n```js\nvar com = FIND('demo');\ncom.attrd('id', '5');\nconsole.log(com.attr('data-id'));  // 5\n```\n\n### com.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 bez prefixu `data-`. |\n\nReturns: `String` Hodnota.\n\nExample: Použitie attrd2()\n```js\nvar com = FIND('demo');\nconsole.log(com.attrd2('group'));  // main\n```\n\n### com.css(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše vlastnosť CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Vlastnosť. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Component` Hodnota, alebo inštancia, keď odovzdáš `value`.\n\nExample: Použitie css()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\nconsole.log(com.css('display'));  // block\n```\n\n### com.visible([callback])\n\nType: `method`\n\nUrčuje, či je element viditeľný.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Spustí sa, keď je element viditeľný. |\n\nReturns: `Boolean` Aktuálna viditeľnosť.\n\nS callbackom sa funkcia spustí, hneď ako je element viditeľný.\n\nExample: Použitie visible()\n```js\nvar com = FIND('demo');\nconsole.log(com.visible());  // true\n```\n\n### com.width([callback])\n\nType: `method`\n\nVráti šírku elementu v pixeloch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Dostane šírku. |\n\nReturns: `Number` Šírka.\n\nS callbackom sa funkcia spustí, hneď ako je šírka väčšia ako nula.\n\nExample: Použitie width()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('width', '200px');\nconsole.log(com.width());  // 200\n```\n\n### com.height([callback])\n\nType: `method`\n\nVráti výšku elementu v pixeloch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Dostane výšku. |\n\nReturns: `Number` Výška.\n\nS callbackom sa funkcia spustí, hneď ako je výška väčšia ako nula.\n\nExample: Použitie height()\n```js\nvar com = FIND('demo');\ncom.css('display', 'block');\ncom.css('height', '50px');\nconsole.log(com.height());  // 50\n```\n\n### com.autofocus([selector])\n\nType: `method`\n\nPresunie fokus na prvé viditeľné pole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Polia. |\n\nReturns: `Component` Inštancia.\n\nKeď žiadne pole nemôže prijať fokus, metóda to krátko skúša znova. Na mobilných zariadeniach nerobí nič.\n\nExample: Použitie autofocus()\n```js\nvar com = FIND('demo');\ncom.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### com.faicon(value)\n\nType: `method`\n\nDoplní názov ikony.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Názov ikony. |\n\nReturns: `String` Triedy CSS.\n\nNázov bez medzery dostane `DEF.iconprefix`, čo je `ti ti-`. Metóda je dostupná aj ako `icon()`.\n\nExample: Použitie faicon()\n```js\nvar com = FIND('demo');\nconsole.log(com.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"init","signature":"self.init = function()","since":"","deprecated":false},{"type":"delegate","name":"done","signature":"self.done = function()","since":"","deprecated":false},{"type":"delegate","name":"released","signature":"self.released = function(hidden)","since":"","deprecated":false},{"type":"delegate","name":"configure","signature":"self.configure = function(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter","signature":"self.getter(value, [realtime], [nobind])","since":"","deprecated":false},{"type":"delegate","name":"setter2","signature":"self.setter2 = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"getter2","signature":"self.getter2 = function(value, realtime)","since":"","deprecated":false},{"type":"delegate","name":"state","signature":"self.state = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"state2","signature":"self.state2 = function(type, what)","since":"","deprecated":false},{"type":"delegate","name":"validate","signature":"self.validate = function(value, init)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"version","signature":"self.version","since":"","deprecated":false},{"type":"property","name":"id","signature":"self.id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"self.ID","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"type","signature":"self.type","since":"","deprecated":false},{"type":"property","name":"format","signature":"self.format","since":"","deprecated":false},{"type":"property","name":"trim","signature":"self.trim","since":"","deprecated":false},{"type":"property","name":"config","signature":"self.config","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"owner","signature":"self.owner","since":"","deprecated":false},{"type":"property","name":"caller","signature":"self.caller","since":"","deprecated":false},{"type":"property","name":"global","signature":"self.global","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"property","name":"pathscope","signature":"self.pathscope","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"self.plugin","since":"","deprecated":false},{"type":"property","name":"siblings","signature":"self.siblings","since":"","deprecated":false},{"type":"property","name":"removed","signature":"self.removed","since":"","deprecated":false},{"type":"method","name":"get()","signature":"com.get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"com.set(value, [type])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"com.modify(value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"com.inc(value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"com.extend(value, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"com.push(value, [type])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"com.rewrite(value, [type])","since":"","deprecated":false},{"type":"method","name":"update()","signature":"com.update([type])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"com.refresh([notify], [type])","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"com.notify()","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"com.skip()","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"com.bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"com.reset()","since":"","deprecated":false},{"type":"method","name":"default()","signature":"com.default([reset])","since":"","deprecated":false},{"type":"method","name":"change()","signature":"com.change([value])","since":"","deprecated":false},{"type":"method","name":"dirty()","signature":"com.dirty([value], [noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"com.isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"com.validate2()","since":"","deprecated":false},{"type":"method","name":"notmodified()","signature":"com.notmodified([fields])","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"com.parser(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"com.formatter(value, [prepend])","since":"","deprecated":false},{"type":"method","name":"parsesource()","signature":"com.parsesource(value)","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"com.reconfigure(value, [callback], [init], [noemit])","since":"","deprecated":false},{"type":"method","name":"configdisplay()","signature":"com.configdisplay(key, value)","since":"","deprecated":false},{"type":"method","name":"data()","signature":"com.data(key, [value])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"com.datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"com.watch([path], callback, [init])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"com.unwatch(path)","since":"","deprecated":false},{"type":"method","name":"on()","signature":"com.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"com.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"com.emit(name, [...args])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"com.command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"com.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"com.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"com.GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"com.SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"com.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"com.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"com.makepath(path)","since":"","deprecated":false},{"type":"method","name":"scopepath()","signature":"com.scopepath(path)","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"com.setPath(path)","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"com.blind()","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"self.readonly()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"self.singleton()","since":"","deprecated":false},{"type":"method","name":"bindchanges()","signature":"self.bindchanges([enable])","since":"","deprecated":false},{"type":"method","name":"bindexact()","signature":"self.bindexact([enable])","since":"","deprecated":false},{"type":"method","name":"bindvisible()","signature":"self.bindvisible([timeout])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"self.autofill([enable])","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"com.caniuse(name)","since":"","deprecated":false},{"type":"method","name":"main()","signature":"com.main()","since":"","deprecated":false},{"type":"method","name":"compile()","signature":"com.compile([container])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"com.import(url, [callback], [insert], [preparator])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"com.replace(element, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"com.remove([noclear])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"com.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"com.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"com.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"com.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"com.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"com.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"com.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"com.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"com.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"com.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"com.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"com.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"com.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"com.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"com.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"com.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"com.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"com.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"com.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"com.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"com.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"com.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammfd6gj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/macro/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Macro","summary":"The delegates, properties and methods of a macro instance.","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/macro/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Macro\n\n> The delegates, properties and methods of a macro instance.\n\nA macro instance is the object passed to the declaration of `MACRO()`. It adds behaviour to an element with the [`macro`](../ui-bind/#macro) command of `<ui-bind>`. [Macros](../../guides/macros/) explains the concept. In the examples, `macro` is an instance attached to a `<ui-bind>` bound to `form.name`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nRuns once after the declaration.\n\nExample: Preparing the element\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self, element, cls) {\n        self.make = function() {\n            element.aclass(cls);\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nReceives the value of the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value of the path. |\n| `path` | `String` | yes |  | The path that changed. |\n| `type` | `Number` | yes |  | The type of the change. |\n\nThe delegate runs on each update of the binder.\n\nExample: Rendering the value\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nRuns once per minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | The number of runs. |\n\nThe delegate receives a counter that grows by one on each run.\n\n### self.destroy = function()\n\nType: `delegate`\n\nRuns when the element of the binder is removed.\n\nExample: Releasing resources\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(function() {\n        $('ui-bind').remove();\n        FREE();\n    }, 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nThe name of the macro.\n\nExample: Reading name\n```js\nconsole.log(macro.name);  // demo\n```\n\n### self.path\n\nType: `property`\n\nThe path of the binder.\n\nExample: Reading path\n```js\nconsole.log(macro.path);  // form.name\n```\n\n### self.element\n\nType: `property`\n\nThe element of the binder as a jQuery object.\n\nExample: Reading element\n```js\nconsole.log(macro.element.attr('id'));  // box\n```\n\n### self.dom\n\nType: `property`\n\nThe element of the binder as a DOM node.\n\nExample: Reading dom\n```js\nconsole.log(macro.dom.id);  // box\n```\n\n### self.binder\n\nType: `property`\n\nThe binder that created the macro.\n\nSee the [`refresh()`](../ui-bind/#refresh) and [`exec()`](../ui-bind/#exec) methods.\n\nExample: Reading binder\n```js\nconsole.log(macro.binder.path);  // form.name\n```\n\n### self.scope\n\nType: `property`\n\nThe [Scope](../scope/) of the binder.\n\nThe property is assigned after the `make` delegate and exists when the path contains `?`.\n\nExample: Reading scope\n```js\nconsole.log(macro.scope.path);  // users\n```\n\n### self.get()\n\nType: `method`\n\nReads the value of the path.\n\nReturns: `Object` The value.\n\nExample: Using get()\n```js\nSET('form.name', 'Peter');\nconsole.log(macro.get());  // Peter\n```\n\n### self.set(value)\n\nType: `method`\n\nWrites a value to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The new value. |\n\nExample: Using set()\n```js\nmacro.set('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### self.refresh()\n\nType: `method`\n\nRuns the binder again with the current value.\n\nReturns: `Macro` The macro.\n\nExample: Using refresh()\n```js\nmacro.setter = value => console.log(value);  // Peter\nwindow.form.name = 'Peter';\nmacro.refresh();\n```\n\n### self.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function by its path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of the function. |\n\nReturns: `Macro` The macro.\n\nThe `?` character is replaced with the path of the scope. The `@` prefix calls a method of the parent component.\n\nExample: Using EXEC()\n```js\nmacro.EXEC('@ping', 5);\n```\n\n### self.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function or writes a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `Macro` The macro.\n\nWhen the path holds no function, the first argument is written to it.\n\nExample: Using SEEX()\n```js\nmacro.SEEX('@title', 'Orders');\nconsole.log(FIND('owner').title);  // Orders\n```\n\n### self.find(selector)\n\nType: `method`\n\nFinds nested elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | A selector or an object of selectors. |\n\nReturns: `jQuery|Object` The result.\n\nAn object of selectors returns an object of jQuery results with the same keys.\n\nExample: Using find()\n```js\nconsole.log(macro.find('.label').text());  // Text\n```\n\n### self.closest(selector)\n\nType: `method`\n\nFinds the closest matching parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The selector. |\n\nReturns: `jQuery` The result.\n\nExample: Using closest()\n```js\nconsole.log(macro.closest('body').length);  // 1\n```\n\n### self.parent([selector])\n\nType: `method`\n\nReturns a parent element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | The selector. |\n\nReturns: `jQuery` The result.\n\nThe argument accepts the same values as [`parent()`](../component/#parent) of a component.\n\nExample: Using parent()\n```js\nconsole.log(macro.parent().prop('tagName'));  // BODY\n```\n\n### self.html([value])\n\nType: `method`\n\nReads or replaces the HTML content.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | The new content. |\n\nReturns: `String|jQuery` The content, or the element when `value` is passed.\n\nAn array is joined.\n\nExample: Using html()\n```js\nmacro.html('<i>A</i>');\nconsole.log(macro.html());  // <i>A</i>\n```\n\n### self.text([value])\n\nType: `method`\n\nReads or replaces the text content.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | The new content. |\n\nReturns: `String|jQuery` The content, or the element when `value` is passed.\n\nAn array is joined.\n\nExample: Using text()\n```js\nmacro.text('A');\nconsole.log(macro.text());  // A\n```\n\n### self.append(value)\n\nType: `method`\n\nAdds content to the end of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | The content. |\n\nReturns: `jQuery` The element.\n\nAn array is joined.\n\nExample: Using append()\n```js\nmacro.append('<i>A</i>');\nconsole.log(macro.find('i').length);  // 1\n```\n\n### self.empty()\n\nType: `method`\n\nRemoves the content of the element.\n\nReturns: `jQuery` The element.\n\nExample: Using empty()\n```js\nmacro.empty();\nconsole.log(macro.html() === '');  // true\n```\n\n### self.event(name, [selector], callback)\n\nType: `method`\n\nAttaches a jQuery event to the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `selector` | `String` | no |  | The delegated selector. |\n| `callback` | `Function` | yes |  | The handler. |\n\nReturns: `Macro` The macro.\n\nThe arguments are the same as in the jQuery `on()` method.\n\nExample: Using event()\n```js\nmacro.event('click', '.label', () => console.log('clicked'));  // clicked\nmacro.find('.label').click();\n```\n\n### self.aclass(classes, [timeout])\n\nType: `method`\n\nAdds CSS classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | The classes. |\n| `timeout` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `Macro` The macro.\n\nExample: Using aclass()\n```js\nmacro.aclass('active');\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.rclass([classes], [timeout])\n\nType: `method`\n\nRemoves CSS classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | The classes. |\n| `timeout` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `Macro` The macro.\n\nWithout an argument, all classes are removed.\n\nExample: Using rclass()\n```js\nmacro.aclass('active');\nmacro.rclass('active');\nconsole.log(macro.hclass('active'));  // false\n```\n\n### self.rclass2(search)\n\nType: `method`\n\nRemoves CSS classes that contain a text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | The text or a regular expression. |\n\nReturns: `Macro` The macro.\n\nExample: Using rclass2()\n```js\nmacro.aclass('col-1 col-2');\nmacro.rclass2('col-');\nconsole.log(macro.hclass('col-2'));  // false\n```\n\n### self.tclass(classes, [state])\n\nType: `method`\n\nToggles CSS classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | The classes. |\n| `state` | `Boolean` | no |  | Forces the state. |\n\nReturns: `Macro` The macro.\n\nExample: Using tclass()\n```js\nmacro.tclass('active', true);\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.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` The result.\n\nExample: Using hclass()\n```js\nconsole.log(macro.hclass('missing'));  // false\n```\n\n### self.attr(name, [value])\n\nType: `method`\n\nReads or writes an attribute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String|Macro` The value, or the macro when `value` is passed.\n\nExample: Using attr()\n```js\nmacro.attr('title', 'Orders');\nconsole.log(macro.attr('title'));  // Orders\n```\n\n### self.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 name without the `data-` prefix. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String|Macro` The value, or the macro when `value` is passed.\n\nExample: Using attrd()\n```js\nmacro.attrd('id', '5');\nconsole.log(macro.attr('data-id'));  // 5\n```\n\n### self.attrd2(name)\n\nType: `method`\n\nReads a `data-` attribute from the element or its closest parent that has it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name without the `data-` prefix. |\n\nReturns: `String` The value.\n\nExample: Using attrd2()\n```js\nconsole.log(macro.attrd2('area'));  // main\n```\n\n### self.css(name, [value])\n\nType: `method`\n\nReads or writes a CSS property.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The property. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String|Macro` The value, or the macro when `value` is passed.\n\nExample: Using css()\n```js\nmacro.css('display', 'block');\nconsole.log(macro.css('display'));  // block\n```\n\n### self.visible([callback])\n\nType: `method`\n\nTells whether the element is visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Runs when the element is visible. |\n\nReturns: `Boolean` The current visibility.\n\nWith a callback, the function runs as soon as the element is visible.\n\nExample: Using visible()\n```js\nconsole.log(macro.visible());  // true\n```\n\n### self.width([callback])\n\nType: `method`\n\nReturns the width of the element in pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Receives the width. |\n\nReturns: `Number` The width.\n\nWith a callback, the function runs as soon as the width is greater than zero.\n\nExample: Using width()\n```js\nmacro.css('display', 'block');\nmacro.css('width', '200px');\nconsole.log(macro.width());  // 200\n```\n\n### self.height([callback])\n\nType: `method`\n\nReturns the height of the element in pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Receives the height. |\n\nReturns: `Number` The height.\n\nWith a callback, the function runs as soon as the height is greater than zero.\n\nExample: Using height()\n```js\nmacro.css('display', 'block');\nmacro.css('height', '50px');\nconsole.log(macro.height());  // 50\n```\n\n### self.autofocus([selector])\n\nType: `method`\n\nMoves the focus to the first visible field.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | The fields. |\n\nReturns: `Macro` The macro.\n\nThe method does nothing on mobile devices.\n\nExample: Using autofocus()\n```js\nmacro.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### self.faicon(value)\n\nType: `method`\n\nCompletes the name of an icon.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The name of the icon. |\n\nReturns: `String` The CSS classes.\n\nA name without a space receives `DEF.iconprefix`, which is `ti ti-`.\n\nExample: Using faicon()\n```js\nconsole.log(macro.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"binder","signature":"self.binder","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"method","name":"get()","signature":"self.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"self.set(value)","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"self.refresh()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"self.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"self.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"self.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"self.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"self.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"self.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"self.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"self.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"self.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"self.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"self.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"self.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"self.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"self.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"self.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"self.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"self.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"self.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"self.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"self.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"self.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"self.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"self.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"self.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammfd6gj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/macro/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Macro","summary":"Die Delegates, Eigenschaften und Methoden einer Macro-Instanz.","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/macro/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Macro\n\n> Die Delegates, Eigenschaften und Methoden einer Macro-Instanz.\n\nEine Macro-Instanz ist das Objekt, das an die Deklaration von `MACRO()` übergeben wird. Die Instanz ergänzt ein Element über den Befehl [`macro`](../ui-bind/#macro) von `<ui-bind>` um Verhalten. [Macros](../../guides/macros/) erklärt das Konzept. In den Beispielen ist `macro` eine Instanz, die an ein an `form.name` gebundenes `<ui-bind>` angehängt ist.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nLäuft einmal nach der Deklaration.\n\nExample: Das Element vorbereiten\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self, element, cls) {\n        self.make = function() {\n            element.aclass(cls);\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nErhält den Wert des Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Wert des Paths. |\n| `path` | `String` | yes |  | Der Path, der sich geändert hat. |\n| `type` | `Number` | yes |  | Der Typ der Änderung. |\n\nDer Delegate läuft bei jeder Aktualisierung des Binders.\n\nExample: Den Wert rendern\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nLäuft einmal pro Minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Die Anzahl der Durchläufe. |\n\nDer Delegate erhält einen Zähler, der bei jedem Lauf um eins steigt.\n\n### self.destroy = function()\n\nType: `delegate`\n\nLäuft, wenn das Element des Binders entfernt wird.\n\nExample: Ressourcen freigeben\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(function() {\n        $('ui-bind').remove();\n        FREE();\n    }, 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nDer Name des Macros.\n\nExample: name lesen\n```js\nconsole.log(macro.name);  // demo\n```\n\n### self.path\n\nType: `property`\n\nDer Path des Binders.\n\nExample: path lesen\n```js\nconsole.log(macro.path);  // form.name\n```\n\n### self.element\n\nType: `property`\n\nDas Element des Binders als jQuery-Objekt.\n\nExample: element lesen\n```js\nconsole.log(macro.element.attr('id'));  // box\n```\n\n### self.dom\n\nType: `property`\n\nDas Element des Binders als DOM-Knoten.\n\nExample: dom lesen\n```js\nconsole.log(macro.dom.id);  // box\n```\n\n### self.binder\n\nType: `property`\n\nDer Binder, der das Macro erstellt hat.\n\nSiehe die Methoden [`refresh()`](../ui-bind/#refresh) und [`exec()`](../ui-bind/#exec).\n\nExample: binder lesen\n```js\nconsole.log(macro.binder.path);  // form.name\n```\n\n### self.scope\n\nType: `property`\n\nDer [Scope](../scope/) des Binders.\n\nDie Eigenschaft wird nach dem Delegate `make` zugewiesen und existiert, wenn der Path `?` enthält.\n\nExample: scope lesen\n```js\nconsole.log(macro.scope.path);  // users\n```\n\n### self.get()\n\nType: `method`\n\nLiest den Wert des Paths.\n\nReturns: `Object` Der Wert.\n\nExample: get() verwenden\n```js\nSET('form.name', 'Peter');\nconsole.log(macro.get());  // Peter\n```\n\n### self.set(value)\n\nType: `method`\n\nSchreibt einen Wert in den Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der neue Wert. |\n\nExample: set() verwenden\n```js\nmacro.set('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### self.refresh()\n\nType: `method`\n\nFührt den Binder erneut mit dem aktuellen Wert aus.\n\nReturns: `Macro` Das Macro.\n\nExample: refresh() verwenden\n```js\nmacro.setter = value => console.log(value);  // Peter\nwindow.form.name = 'Peter';\nmacro.refresh();\n```\n\n### self.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Funktion über ihren Path auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path der Funktion. |\n\nReturns: `Macro` Das Macro.\n\nDas Zeichen `?` wird durch den Path des Scopes ersetzt. Das Präfix `@` ruft eine Methode der übergeordneten Komponente auf.\n\nExample: EXEC() verwenden\n```js\nmacro.EXEC('@ping', 5);\n```\n\n### self.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Funktion auf oder schreibt einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `Macro` Das Macro.\n\nEnthält der Path keine Funktion, wird das erste Argument hineingeschrieben.\n\nExample: SEEX() verwenden\n```js\nmacro.SEEX('@title', 'Orders');\nconsole.log(FIND('owner').title);  // Orders\n```\n\n### self.find(selector)\n\nType: `method`\n\nFindet verschachtelte Elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Ein Selektor oder ein Objekt aus Selektoren. |\n\nReturns: `jQuery|Object` Das Ergebnis.\n\nEin Objekt aus Selektoren liefert ein Objekt aus jQuery-Ergebnissen mit denselben Schlüsseln.\n\nExample: find() verwenden\n```js\nconsole.log(macro.find('.label').text());  // Text\n```\n\n### self.closest(selector)\n\nType: `method`\n\nFindet das nächstgelegene passende Elternelement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Selektor. |\n\nReturns: `jQuery` Das Ergebnis.\n\nExample: closest() verwenden\n```js\nconsole.log(macro.closest('body').length);  // 1\n```\n\n### self.parent([selector])\n\nType: `method`\n\nGibt ein Elternelement zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Der Selektor. |\n\nReturns: `jQuery` Das Ergebnis.\n\nDas Argument akzeptiert dieselben Werte wie [`parent()`](../component/#parent) einer Komponente.\n\nExample: parent() verwenden\n```js\nconsole.log(macro.parent().prop('tagName'));  // BODY\n```\n\n### self.html([value])\n\nType: `method`\n\nLiest oder ersetzt den HTML-Inhalt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Der neue Inhalt. |\n\nReturns: `String|jQuery` Der Inhalt oder, wenn `value` übergeben wird, das Element.\n\nEin Array wird zusammengefügt.\n\nExample: html() verwenden\n```js\nmacro.html('<i>A</i>');\nconsole.log(macro.html());  // <i>A</i>\n```\n\n### self.text([value])\n\nType: `method`\n\nLiest oder ersetzt den Textinhalt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Der neue Inhalt. |\n\nReturns: `String|jQuery` Der Inhalt oder, wenn `value` übergeben wird, das Element.\n\nEin Array wird zusammengefügt.\n\nExample: text() verwenden\n```js\nmacro.text('A');\nconsole.log(macro.text());  // A\n```\n\n### self.append(value)\n\nType: `method`\n\nFügt Inhalt am Ende des Elements hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Der Inhalt. |\n\nReturns: `jQuery` Das Element.\n\nEin Array wird zusammengefügt.\n\nExample: append() verwenden\n```js\nmacro.append('<i>A</i>');\nconsole.log(macro.find('i').length);  // 1\n```\n\n### self.empty()\n\nType: `method`\n\nEntfernt den Inhalt des Elements.\n\nReturns: `jQuery` Das Element.\n\nExample: empty() verwenden\n```js\nmacro.empty();\nconsole.log(macro.html() === '');  // true\n```\n\n### self.event(name, [selector], callback)\n\nType: `method`\n\nHängt ein jQuery-Event an das Element an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `selector` | `String` | no |  | Der delegierte Selektor. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nReturns: `Macro` Das Macro.\n\nDie Argumente sind dieselben wie bei der jQuery-Methode `on()`.\n\nExample: event() verwenden\n```js\nmacro.event('click', '.label', () => console.log('clicked'));  // clicked\nmacro.find('.label').click();\n```\n\n### self.aclass(classes, [timeout])\n\nType: `method`\n\nFügt CSS-Klassen hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Die Klassen. |\n| `timeout` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `Macro` Das Macro.\n\nExample: aclass() verwenden\n```js\nmacro.aclass('active');\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.rclass([classes], [timeout])\n\nType: `method`\n\nEntfernt CSS-Klassen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Die Klassen. |\n| `timeout` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `Macro` Das Macro.\n\nOhne Argument werden alle Klassen entfernt.\n\nExample: rclass() verwenden\n```js\nmacro.aclass('active');\nmacro.rclass('active');\nconsole.log(macro.hclass('active'));  // false\n```\n\n### self.rclass2(search)\n\nType: `method`\n\nEntfernt CSS-Klassen, die einen bestimmten Text enthalten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Der Text oder ein regulärer Ausdruck. |\n\nReturns: `Macro` Das Macro.\n\nExample: rclass2() verwenden\n```js\nmacro.aclass('col-1 col-2');\nmacro.rclass2('col-');\nconsole.log(macro.hclass('col-2'));  // false\n```\n\n### self.tclass(classes, [state])\n\nType: `method`\n\nSchaltet CSS-Klassen um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Die Klassen. |\n| `state` | `Boolean` | no |  | Erzwingt den Zustand. |\n\nReturns: `Macro` Das Macro.\n\nExample: tclass() verwenden\n```js\nmacro.tclass('active', true);\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.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` Das Ergebnis.\n\nExample: hclass() verwenden\n```js\nconsole.log(macro.hclass('missing'));  // false\n```\n\n### self.attr(name, [value])\n\nType: `method`\n\nLiest oder schreibt ein Attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Attribut. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String|Macro` Der Wert oder, wenn `value` übergeben wird, das Macro.\n\nExample: attr() verwenden\n```js\nmacro.attr('title', 'Orders');\nconsole.log(macro.attr('title'));  // Orders\n```\n\n### self.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 Name ohne das Präfix `data-`. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String|Macro` Der Wert oder, wenn `value` übergeben wird, das Macro.\n\nExample: attrd() verwenden\n```js\nmacro.attrd('id', '5');\nconsole.log(macro.attr('data-id'));  // 5\n```\n\n### self.attrd2(name)\n\nType: `method`\n\nLiest ein `data-`-Attribut vom Element oder von seinem nächstgelegenen Elternelement, das es besitzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name ohne das Präfix `data-`. |\n\nReturns: `String` Der Wert.\n\nExample: attrd2() verwenden\n```js\nconsole.log(macro.attrd2('area'));  // main\n```\n\n### self.css(name, [value])\n\nType: `method`\n\nLiest oder schreibt eine CSS-Eigenschaft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Eigenschaft. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String|Macro` Der Wert oder, wenn `value` übergeben wird, das Macro.\n\nExample: css() verwenden\n```js\nmacro.css('display', 'block');\nconsole.log(macro.css('display'));  // block\n```\n\n### self.visible([callback])\n\nType: `method`\n\nGibt an, ob das Element sichtbar ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Läuft, wenn das Element sichtbar ist. |\n\nReturns: `Boolean` Die aktuelle Sichtbarkeit.\n\nMit einem Callback läuft die Funktion, sobald das Element sichtbar ist.\n\nExample: visible() verwenden\n```js\nconsole.log(macro.visible());  // true\n```\n\n### self.width([callback])\n\nType: `method`\n\nGibt die Breite des Elements in Pixeln zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Erhält die Breite. |\n\nReturns: `Number` Die Breite.\n\nMit einem Callback läuft die Funktion, sobald die Breite größer als null ist.\n\nExample: width() verwenden\n```js\nmacro.css('display', 'block');\nmacro.css('width', '200px');\nconsole.log(macro.width());  // 200\n```\n\n### self.height([callback])\n\nType: `method`\n\nGibt die Höhe des Elements in Pixeln zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Erhält die Höhe. |\n\nReturns: `Number` Die Höhe.\n\nMit einem Callback läuft die Funktion, sobald die Höhe größer als null ist.\n\nExample: height() verwenden\n```js\nmacro.css('display', 'block');\nmacro.css('height', '50px');\nconsole.log(macro.height());  // 50\n```\n\n### self.autofocus([selector])\n\nType: `method`\n\nSetzt den Fokus auf das erste sichtbare Feld.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Die Felder. |\n\nReturns: `Macro` Das Macro.\n\nAuf Mobilgeräten macht die Methode nichts.\n\nExample: autofocus() verwenden\n```js\nmacro.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### self.faicon(value)\n\nType: `method`\n\nVervollständigt den Namen eines Icons.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Der Name des Icons. |\n\nReturns: `String` Die CSS-Klassen.\n\nEin Name ohne Leerzeichen erhält `DEF.iconprefix`, also `ti ti-`.\n\nExample: faicon() verwenden\n```js\nconsole.log(macro.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"binder","signature":"self.binder","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"method","name":"get()","signature":"self.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"self.set(value)","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"self.refresh()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"self.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"self.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"self.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"self.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"self.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"self.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"self.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"self.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"self.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"self.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"self.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"self.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"self.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"self.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"self.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"self.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"self.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"self.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"self.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"self.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"self.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"self.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"self.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"self.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammfd6gj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/macro/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Macro","summary":"Los delegates, las propiedades y los métodos de una instancia de macro.","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/macro/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Macro\n\n> Los delegates, las propiedades y los métodos de una instancia de macro.\n\nUna instancia de macro es el objeto que se pasa a la declaración de `MACRO()`. Añade comportamiento a un elemento con el comando [`macro`](../ui-bind/#macro) de `<ui-bind>`. En [Macros](../../guides/macros/) se explica el concepto. En los ejemplos, `macro` es una instancia asociada a un `<ui-bind>` enlazado a `form.name`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nSe ejecuta una sola vez después de la declaración.\n\nExample: Preparar el elemento\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self, element, cls) {\n        self.make = function() {\n            element.aclass(cls);\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nRecibe el valor del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor del path. |\n| `path` | `String` | yes |  | El path que ha cambiado. |\n| `type` | `Number` | yes |  | El tipo del cambio. |\n\nEl delegate se ejecuta en cada actualización del binder.\n\nExample: Renderizar el valor\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nSe ejecuta una vez por minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | El número de ejecuciones. |\n\nEl delegate recibe un contador que aumenta en uno en cada ejecución.\n\n### self.destroy = function()\n\nType: `delegate`\n\nSe ejecuta cuando se elimina el elemento del binder.\n\nExample: Liberar recursos\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(function() {\n        $('ui-bind').remove();\n        FREE();\n    }, 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nEl nombre de la macro.\n\nExample: Leer name\n```js\nconsole.log(macro.name);  // demo\n```\n\n### self.path\n\nType: `property`\n\nEl path del binder.\n\nExample: Leer path\n```js\nconsole.log(macro.path);  // form.name\n```\n\n### self.element\n\nType: `property`\n\nEl elemento del binder como objeto de jQuery.\n\nExample: Leer element\n```js\nconsole.log(macro.element.attr('id'));  // box\n```\n\n### self.dom\n\nType: `property`\n\nEl elemento del binder como nodo del DOM.\n\nExample: Leer dom\n```js\nconsole.log(macro.dom.id);  // box\n```\n\n### self.binder\n\nType: `property`\n\nEl binder que ha creado la macro.\n\nConsulta los métodos [`refresh()`](../ui-bind/#refresh) y [`exec()`](../ui-bind/#exec).\n\nExample: Leer binder\n```js\nconsole.log(macro.binder.path);  // form.name\n```\n\n### self.scope\n\nType: `property`\n\nEl [Scope](../scope/) del binder.\n\nLa propiedad se asigna después del delegate `make` y existe cuando el path contiene `?`.\n\nExample: Leer scope\n```js\nconsole.log(macro.scope.path);  // users\n```\n\n### self.get()\n\nType: `method`\n\nLee el valor del path.\n\nReturns: `Object` El valor.\n\nExample: Usar get()\n```js\nSET('form.name', 'Peter');\nconsole.log(macro.get());  // Peter\n```\n\n### self.set(value)\n\nType: `method`\n\nEscribe un valor en el path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El nuevo valor. |\n\nExample: Usar set()\n```js\nmacro.set('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### self.refresh()\n\nType: `method`\n\nVuelve a ejecutar el binder con el valor actual.\n\nReturns: `Macro` La macro.\n\nExample: Usar refresh()\n```js\nmacro.setter = value => console.log(value);  // Peter\nwindow.form.name = 'Peter';\nmacro.refresh();\n```\n\n### self.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función por su path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path de la función. |\n\nReturns: `Macro` La macro.\n\nEl carácter `?` se sustituye por el path del scope. El prefijo `@` llama a un método del componente padre.\n\nExample: Usar EXEC()\n```js\nmacro.EXEC('@ping', 5);\n```\n\n### self.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función o escribe un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `Macro` La macro.\n\nCuando el path no contiene ninguna función, se escribe en él el primer argumento.\n\nExample: Usar SEEX()\n```js\nmacro.SEEX('@title', 'Orders');\nconsole.log(FIND('owner').title);  // Orders\n```\n\n### self.find(selector)\n\nType: `method`\n\nBusca elementos anidados.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un selector o un objeto de selectores. |\n\nReturns: `jQuery|Object` El resultado.\n\nUn objeto de selectores devuelve un objeto de resultados de jQuery con las mismas claves.\n\nExample: Usar find()\n```js\nconsole.log(macro.find('.label').text());  // Text\n```\n\n### self.closest(selector)\n\nType: `method`\n\nBusca el padre coincidente más cercano.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector. |\n\nReturns: `jQuery` El resultado.\n\nExample: Usar closest()\n```js\nconsole.log(macro.closest('body').length);  // 1\n```\n\n### self.parent([selector])\n\nType: `method`\n\nDevuelve un elemento padre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | El selector. |\n\nReturns: `jQuery` El resultado.\n\nEl argumento admite los mismos valores que [`parent()`](../component/#parent) de un componente.\n\nExample: Usar parent()\n```js\nconsole.log(macro.parent().prop('tagName'));  // BODY\n```\n\n### self.html([value])\n\nType: `method`\n\nLee o sustituye el contenido HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | El contenido nuevo. |\n\nReturns: `String|jQuery` El contenido, o el elemento cuando se pasa `value`.\n\nSi es un array, se une.\n\nExample: Usar html()\n```js\nmacro.html('<i>A</i>');\nconsole.log(macro.html());  // <i>A</i>\n```\n\n### self.text([value])\n\nType: `method`\n\nLee o sustituye el contenido de texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | El contenido nuevo. |\n\nReturns: `String|jQuery` El contenido, o el elemento cuando se pasa `value`.\n\nSi es un array, se une.\n\nExample: Usar text()\n```js\nmacro.text('A');\nconsole.log(macro.text());  // A\n```\n\n### self.append(value)\n\nType: `method`\n\nAñade contenido al final del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | El contenido. |\n\nReturns: `jQuery` El elemento.\n\nSi es un array, se une.\n\nExample: Usar append()\n```js\nmacro.append('<i>A</i>');\nconsole.log(macro.find('i').length);  // 1\n```\n\n### self.empty()\n\nType: `method`\n\nElimina el contenido del elemento.\n\nReturns: `jQuery` El elemento.\n\nExample: Usar empty()\n```js\nmacro.empty();\nconsole.log(macro.html() === '');  // true\n```\n\n### self.event(name, [selector], callback)\n\nType: `method`\n\nAsocia un evento de jQuery al elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `selector` | `String` | no |  | El selector delegado. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nReturns: `Macro` La macro.\n\nLos argumentos son los mismos que en el método `on()` de jQuery.\n\nExample: Usar event()\n```js\nmacro.event('click', '.label', () => console.log('clicked'));  // clicked\nmacro.find('.label').click();\n```\n\n### self.aclass(classes, [timeout])\n\nType: `method`\n\nAñade clases CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Las clases. |\n| `timeout` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `Macro` La macro.\n\nExample: Usar aclass()\n```js\nmacro.aclass('active');\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.rclass([classes], [timeout])\n\nType: `method`\n\nElimina clases CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Las clases. |\n| `timeout` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `Macro` La macro.\n\nSin argumento, se eliminan todas las clases.\n\nExample: Usar rclass()\n```js\nmacro.aclass('active');\nmacro.rclass('active');\nconsole.log(macro.hclass('active'));  // false\n```\n\n### self.rclass2(search)\n\nType: `method`\n\nElimina las clases CSS que contienen un texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | El texto o una expresión regular. |\n\nReturns: `Macro` La macro.\n\nExample: Usar rclass2()\n```js\nmacro.aclass('col-1 col-2');\nmacro.rclass2('col-');\nconsole.log(macro.hclass('col-2'));  // false\n```\n\n### self.tclass(classes, [state])\n\nType: `method`\n\nAlterna clases CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Las clases. |\n| `state` | `Boolean` | no |  | Fuerza el estado. |\n\nReturns: `Macro` La macro.\n\nExample: Usar tclass()\n```js\nmacro.tclass('active', true);\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.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` El resultado.\n\nExample: Usar hclass()\n```js\nconsole.log(macro.hclass('missing'));  // false\n```\n\n### self.attr(name, [value])\n\nType: `method`\n\nLee o escribe un atributo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El atributo. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String|Macro` El valor, o la macro cuando se pasa `value`.\n\nExample: Usar attr()\n```js\nmacro.attr('title', 'Orders');\nconsole.log(macro.attr('title'));  // Orders\n```\n\n### self.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 sin el prefijo `data-`. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String|Macro` El valor, o la macro cuando se pasa `value`.\n\nExample: Usar attrd()\n```js\nmacro.attrd('id', '5');\nconsole.log(macro.attr('data-id'));  // 5\n```\n\n### self.attrd2(name)\n\nType: `method`\n\nLee un atributo `data-` del elemento o del padre más cercano que lo tenga.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre sin el prefijo `data-`. |\n\nReturns: `String` El valor.\n\nExample: Usar attrd2()\n```js\nconsole.log(macro.attrd2('area'));  // main\n```\n\n### self.css(name, [value])\n\nType: `method`\n\nLee o escribe una propiedad CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La propiedad. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String|Macro` El valor, o la macro cuando se pasa `value`.\n\nExample: Usar css()\n```js\nmacro.css('display', 'block');\nconsole.log(macro.css('display'));  // block\n```\n\n### self.visible([callback])\n\nType: `method`\n\nIndica si el elemento está visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Se ejecuta cuando el elemento es visible. |\n\nReturns: `Boolean` La visibilidad actual.\n\nCon un callback, la función se ejecuta en cuanto el elemento es visible.\n\nExample: Usar visible()\n```js\nconsole.log(macro.visible());  // true\n```\n\n### self.width([callback])\n\nType: `method`\n\nDevuelve el ancho del elemento en píxeles.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Recibe el ancho. |\n\nReturns: `Number` El ancho.\n\nCon un callback, la función se ejecuta en cuanto el ancho es mayor que cero.\n\nExample: Usar width()\n```js\nmacro.css('display', 'block');\nmacro.css('width', '200px');\nconsole.log(macro.width());  // 200\n```\n\n### self.height([callback])\n\nType: `method`\n\nDevuelve la altura del elemento en píxeles.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Recibe la altura. |\n\nReturns: `Number` La altura.\n\nCon un callback, la función se ejecuta en cuanto la altura es mayor que cero.\n\nExample: Usar height()\n```js\nmacro.css('display', 'block');\nmacro.css('height', '50px');\nconsole.log(macro.height());  // 50\n```\n\n### self.autofocus([selector])\n\nType: `method`\n\nMueve el foco al primer campo visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Los campos. |\n\nReturns: `Macro` La macro.\n\nEl método no hace nada en dispositivos móviles.\n\nExample: Usar autofocus()\n```js\nmacro.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### self.faicon(value)\n\nType: `method`\n\nCompleta el nombre de un icono.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El nombre del icono. |\n\nReturns: `String` Las clases CSS.\n\nUn nombre sin espacios recibe `DEF.iconprefix`, que es `ti ti-`.\n\nExample: Usar faicon()\n```js\nconsole.log(macro.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"binder","signature":"self.binder","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"method","name":"get()","signature":"self.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"self.set(value)","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"self.refresh()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"self.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"self.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"self.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"self.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"self.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"self.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"self.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"self.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"self.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"self.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"self.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"self.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"self.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"self.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"self.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"self.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"self.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"self.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"self.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"self.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"self.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"self.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"self.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"self.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammfd6gj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/macro/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Macro","summary":"Les delegates, les propriétés et les méthodes d'une instance de macro.","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/macro/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Macro\n\n> Les delegates, les propriétés et les méthodes d'une instance de macro.\n\nUne instance de macro est l'objet passé à la déclaration de `MACRO()`. Elle ajoute un comportement à un élément grâce à la commande [`macro`](../ui-bind/#macro) de `<ui-bind>`. [Macros](../../guides/macros/) explique le concept. Dans les exemples, `macro` est une instance attachée à un `<ui-bind>` lié à `form.name`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nS'exécute une seule fois après la déclaration.\n\nExample: Préparer l'élément\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self, element, cls) {\n        self.make = function() {\n            element.aclass(cls);\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nReçoit la valeur du path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur du path. |\n| `path` | `String` | yes |  | Le path qui a changé. |\n| `type` | `Number` | yes |  | Le type de la modification. |\n\nLe delegate s'exécute à chaque mise à jour du binder.\n\nExample: Effectuer le rendu de la valeur\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nS'exécute une fois par minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Le nombre d'exécutions. |\n\nLe delegate reçoit un compteur qui augmente de un à chaque exécution.\n\n### self.destroy = function()\n\nType: `delegate`\n\nS'exécute quand l'élément du binder est supprimé.\n\nExample: Libérer les ressources\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(function() {\n        $('ui-bind').remove();\n        FREE();\n    }, 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nLe nom de la macro.\n\nExample: Lire name\n```js\nconsole.log(macro.name);  // demo\n```\n\n### self.path\n\nType: `property`\n\nLe path du binder.\n\nExample: Lire path\n```js\nconsole.log(macro.path);  // form.name\n```\n\n### self.element\n\nType: `property`\n\nL'élément du binder sous forme d'objet jQuery.\n\nExample: Lire element\n```js\nconsole.log(macro.element.attr('id'));  // box\n```\n\n### self.dom\n\nType: `property`\n\nL'élément du binder sous forme de nœud DOM.\n\nExample: Lire dom\n```js\nconsole.log(macro.dom.id);  // box\n```\n\n### self.binder\n\nType: `property`\n\nLe binder qui a créé la macro.\n\nConsulte les méthodes [`refresh()`](../ui-bind/#refresh) et [`exec()`](../ui-bind/#exec).\n\nExample: Lire binder\n```js\nconsole.log(macro.binder.path);  // form.name\n```\n\n### self.scope\n\nType: `property`\n\nLe [Scope](../scope/) du binder.\n\nLa propriété est assignée après le delegate `make` et existe quand le path contient `?`.\n\nExample: Lire scope\n```js\nconsole.log(macro.scope.path);  // users\n```\n\n### self.get()\n\nType: `method`\n\nLit la valeur du path.\n\nReturns: `Object` La valeur.\n\nExample: Utiliser get()\n```js\nSET('form.name', 'Peter');\nconsole.log(macro.get());  // Peter\n```\n\n### self.set(value)\n\nType: `method`\n\nÉcrit une valeur dans le path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n\nExample: Utiliser set()\n```js\nmacro.set('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### self.refresh()\n\nType: `method`\n\nExécute de nouveau le binder avec la valeur actuelle.\n\nReturns: `Macro` La macro.\n\nExample: Utiliser refresh()\n```js\nmacro.setter = value => console.log(value);  // Peter\nwindow.form.name = 'Peter';\nmacro.refresh();\n```\n\n### self.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction par son path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path de la fonction. |\n\nReturns: `Macro` La macro.\n\nLe caractère `?` est remplacé par le path du scope. Le préfixe `@` appelle une méthode du composant parent.\n\nExample: Utiliser EXEC()\n```js\nmacro.EXEC('@ping', 5);\n```\n\n### self.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction ou écrit une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `Macro` La macro.\n\nQuand le path ne contient pas de fonction, le premier argument y est écrit.\n\nExample: Utiliser SEEX()\n```js\nmacro.SEEX('@title', 'Orders');\nconsole.log(FIND('owner').title);  // Orders\n```\n\n### self.find(selector)\n\nType: `method`\n\nTrouve des éléments imbriqués.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un sélecteur ou un objet de sélecteurs. |\n\nReturns: `jQuery|Object` Le résultat.\n\nUn objet de sélecteurs renvoie un objet de résultats jQuery avec les mêmes clés.\n\nExample: Utiliser find()\n```js\nconsole.log(macro.find('.label').text());  // Text\n```\n\n### self.closest(selector)\n\nType: `method`\n\nTrouve le parent correspondant le plus proche.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur. |\n\nReturns: `jQuery` Le résultat.\n\nExample: Utiliser closest()\n```js\nconsole.log(macro.closest('body').length);  // 1\n```\n\n### self.parent([selector])\n\nType: `method`\n\nRenvoie un élément parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Le sélecteur. |\n\nReturns: `jQuery` Le résultat.\n\nL'argument accepte les mêmes valeurs que [`parent()`](../component/#parent) d'un composant.\n\nExample: Utiliser parent()\n```js\nconsole.log(macro.parent().prop('tagName'));  // BODY\n```\n\n### self.html([value])\n\nType: `method`\n\nLit ou remplace le contenu HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Le nouveau contenu. |\n\nReturns: `String|jQuery` Le contenu, ou l'élément quand `value` est passé.\n\nUn tableau est concaténé.\n\nExample: Utiliser html()\n```js\nmacro.html('<i>A</i>');\nconsole.log(macro.html());  // <i>A</i>\n```\n\n### self.text([value])\n\nType: `method`\n\nLit ou remplace le contenu textuel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Le nouveau contenu. |\n\nReturns: `String|jQuery` Le contenu, ou l'élément quand `value` est passé.\n\nUn tableau est concaténé.\n\nExample: Utiliser text()\n```js\nmacro.text('A');\nconsole.log(macro.text());  // A\n```\n\n### self.append(value)\n\nType: `method`\n\nAjoute du contenu à la fin de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Le contenu. |\n\nReturns: `jQuery` L'élément.\n\nUn tableau est concaténé.\n\nExample: Utiliser append()\n```js\nmacro.append('<i>A</i>');\nconsole.log(macro.find('i').length);  // 1\n```\n\n### self.empty()\n\nType: `method`\n\nSupprime le contenu de l'élément.\n\nReturns: `jQuery` L'élément.\n\nExample: Utiliser empty()\n```js\nmacro.empty();\nconsole.log(macro.html() === '');  // true\n```\n\n### self.event(name, [selector], callback)\n\nType: `method`\n\nAttache un événement jQuery à l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `selector` | `String` | no |  | Le sélecteur de délégation. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nReturns: `Macro` La macro.\n\nLes arguments sont les mêmes que ceux de la méthode jQuery `on()`.\n\nExample: Utiliser event()\n```js\nmacro.event('click', '.label', () => console.log('clicked'));  // clicked\nmacro.find('.label').click();\n```\n\n### self.aclass(classes, [timeout])\n\nType: `method`\n\nAjoute des classes CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Les classes. |\n| `timeout` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `Macro` La macro.\n\nExample: Utiliser aclass()\n```js\nmacro.aclass('active');\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.rclass([classes], [timeout])\n\nType: `method`\n\nSupprime des classes CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Les classes. |\n| `timeout` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `Macro` La macro.\n\nSans argument, toutes les classes sont supprimées.\n\nExample: Utiliser rclass()\n```js\nmacro.aclass('active');\nmacro.rclass('active');\nconsole.log(macro.hclass('active'));  // false\n```\n\n### self.rclass2(search)\n\nType: `method`\n\nSupprime les classes CSS qui contiennent un texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Le texte ou une expression régulière. |\n\nReturns: `Macro` La macro.\n\nExample: Utiliser rclass2()\n```js\nmacro.aclass('col-1 col-2');\nmacro.rclass2('col-');\nconsole.log(macro.hclass('col-2'));  // false\n```\n\n### self.tclass(classes, [state])\n\nType: `method`\n\nBascule des classes CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Les classes. |\n| `state` | `Boolean` | no |  | Force l'état. |\n\nReturns: `Macro` La macro.\n\nExample: Utiliser tclass()\n```js\nmacro.tclass('active', true);\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.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` Le résultat.\n\nExample: Utiliser hclass()\n```js\nconsole.log(macro.hclass('missing'));  // false\n```\n\n### self.attr(name, [value])\n\nType: `method`\n\nLit ou écrit un attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'attribut. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String|Macro` La valeur, ou la macro quand `value` est passé.\n\nExample: Utiliser attr()\n```js\nmacro.attr('title', 'Orders');\nconsole.log(macro.attr('title'));  // Orders\n```\n\n### self.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 sans le préfixe `data-`. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String|Macro` La valeur, ou la macro quand `value` est passé.\n\nExample: Utiliser attrd()\n```js\nmacro.attrd('id', '5');\nconsole.log(macro.attr('data-id'));  // 5\n```\n\n### self.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 sans le préfixe `data-`. |\n\nReturns: `String` La valeur.\n\nExample: Utiliser attrd2()\n```js\nconsole.log(macro.attrd2('area'));  // main\n```\n\n### self.css(name, [value])\n\nType: `method`\n\nLit ou écrit une propriété CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La propriété. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String|Macro` La valeur, ou la macro quand `value` est passé.\n\nExample: Utiliser css()\n```js\nmacro.css('display', 'block');\nconsole.log(macro.css('display'));  // block\n```\n\n### self.visible([callback])\n\nType: `method`\n\nIndique si l'élément est visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | S'exécute quand l'élément est visible. |\n\nReturns: `Boolean` La visibilité actuelle.\n\nAvec un callback, la fonction s'exécute dès que l'élément est visible.\n\nExample: Utiliser visible()\n```js\nconsole.log(macro.visible());  // true\n```\n\n### self.width([callback])\n\nType: `method`\n\nRenvoie la largeur de l'élément en pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Reçoit la largeur. |\n\nReturns: `Number` La largeur.\n\nAvec un callback, la fonction s'exécute dès que la largeur est supérieure à zéro.\n\nExample: Utiliser width()\n```js\nmacro.css('display', 'block');\nmacro.css('width', '200px');\nconsole.log(macro.width());  // 200\n```\n\n### self.height([callback])\n\nType: `method`\n\nRenvoie la hauteur de l'élément en pixels.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Reçoit la hauteur. |\n\nReturns: `Number` La hauteur.\n\nAvec un callback, la fonction s'exécute dès que la hauteur est supérieure à zéro.\n\nExample: Utiliser height()\n```js\nmacro.css('display', 'block');\nmacro.css('height', '50px');\nconsole.log(macro.height());  // 50\n```\n\n### self.autofocus([selector])\n\nType: `method`\n\nDéplace le focus vers le premier champ visible.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Les champs. |\n\nReturns: `Macro` La macro.\n\nLa méthode ne fait rien sur les appareils mobiles.\n\nExample: Utiliser autofocus()\n```js\nmacro.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### self.faicon(value)\n\nType: `method`\n\nComplète le nom d'une icône.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Le nom de l'icône. |\n\nReturns: `String` Les classes CSS.\n\nUn nom sans espace reçoit `DEF.iconprefix`, qui vaut `ti ti-`.\n\nExample: Utiliser faicon()\n```js\nconsole.log(macro.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"binder","signature":"self.binder","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"method","name":"get()","signature":"self.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"self.set(value)","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"self.refresh()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"self.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"self.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"self.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"self.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"self.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"self.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"self.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"self.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"self.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"self.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"self.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"self.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"self.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"self.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"self.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"self.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"self.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"self.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"self.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"self.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"self.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"self.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"self.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"self.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammfd6gj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/macro/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Macro","summary":"I delegate, le proprietà e i metodi di un'istanza di macro.","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/macro/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Macro\n\n> I delegate, le proprietà e i metodi di un'istanza di macro.\n\nUn'istanza di macro è l'oggetto passato alla dichiarazione di `MACRO()`. Aggiunge un comportamento a un elemento con il comando [`macro`](../ui-bind/#macro) di `<ui-bind>`. [Macro](../../guides/macros/) spiega il concetto. Negli esempi, `macro` è un'istanza collegata a un `<ui-bind>` associato a `form.name`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nViene eseguito una sola volta dopo la dichiarazione.\n\nExample: Preparare l'elemento\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self, element, cls) {\n        self.make = function() {\n            element.aclass(cls);\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nRiceve il valore del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore del path. |\n| `path` | `String` | yes |  | Il path che è cambiato. |\n| `type` | `Number` | yes |  | Il tipo della modifica. |\n\nIl delegate viene eseguito a ogni aggiornamento del binder.\n\nExample: Eseguire il rendering del valore\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nViene eseguito una volta al minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Il numero di esecuzioni. |\n\nIl delegate riceve un contatore che aumenta di uno a ogni esecuzione.\n\n### self.destroy = function()\n\nType: `delegate`\n\nViene eseguito quando l'elemento del binder viene rimosso.\n\nExample: Rilasciare le risorse\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(function() {\n        $('ui-bind').remove();\n        FREE();\n    }, 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nIl nome della macro.\n\nExample: Lettura di name\n```js\nconsole.log(macro.name);  // demo\n```\n\n### self.path\n\nType: `property`\n\nIl path del binder.\n\nExample: Lettura di path\n```js\nconsole.log(macro.path);  // form.name\n```\n\n### self.element\n\nType: `property`\n\nL'elemento del binder come oggetto jQuery.\n\nExample: Lettura di element\n```js\nconsole.log(macro.element.attr('id'));  // box\n```\n\n### self.dom\n\nType: `property`\n\nL'elemento del binder come nodo DOM.\n\nExample: Lettura di dom\n```js\nconsole.log(macro.dom.id);  // box\n```\n\n### self.binder\n\nType: `property`\n\nIl binder che ha creato la macro.\n\nVedi i metodi [`refresh()`](../ui-bind/#refresh) ed [`exec()`](../ui-bind/#exec).\n\nExample: Lettura di binder\n```js\nconsole.log(macro.binder.path);  // form.name\n```\n\n### self.scope\n\nType: `property`\n\nLo [Scope](../scope/) del binder.\n\nLa proprietà viene assegnata dopo il delegate `make` ed esiste quando il path contiene `?`.\n\nExample: Lettura di scope\n```js\nconsole.log(macro.scope.path);  // users\n```\n\n### self.get()\n\nType: `method`\n\nLegge il valore del path.\n\nReturns: `Object` Il valore.\n\nExample: Uso di get()\n```js\nSET('form.name', 'Peter');\nconsole.log(macro.get());  // Peter\n```\n\n### self.set(value)\n\nType: `method`\n\nScrive un valore nel path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n\nExample: Uso di set()\n```js\nmacro.set('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### self.refresh()\n\nType: `method`\n\nEsegue di nuovo il binder con il valore corrente.\n\nReturns: `Macro` La macro.\n\nExample: Uso di refresh()\n```js\nmacro.setter = value => console.log(value);  // Peter\nwindow.form.name = 'Peter';\nmacro.refresh();\n```\n\n### self.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione tramite il suo path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path della funzione. |\n\nReturns: `Macro` La macro.\n\nIl carattere `?` viene sostituito con il path dello scope. Il prefisso `@` chiama un metodo del componente padre.\n\nExample: Uso di EXEC()\n```js\nmacro.EXEC('@ping', 5);\n```\n\n### self.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione o scrive un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `Macro` La macro.\n\nQuando il path non contiene una funzione, vi viene scritto il primo argomento.\n\nExample: Uso di SEEX()\n```js\nmacro.SEEX('@title', 'Orders');\nconsole.log(FIND('owner').title);  // Orders\n```\n\n### self.find(selector)\n\nType: `method`\n\nTrova gli elementi annidati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Un selettore o un oggetto di selettori. |\n\nReturns: `jQuery|Object` Il risultato.\n\nUn oggetto di selettori restituisce un oggetto di risultati jQuery con le stesse chiavi.\n\nExample: Uso di find()\n```js\nconsole.log(macro.find('.label').text());  // Text\n```\n\n### self.closest(selector)\n\nType: `method`\n\nTrova il genitore corrispondente più vicino.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore. |\n\nReturns: `jQuery` Il risultato.\n\nExample: Uso di closest()\n```js\nconsole.log(macro.closest('body').length);  // 1\n```\n\n### self.parent([selector])\n\nType: `method`\n\nRestituisce un elemento genitore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Il selettore. |\n\nReturns: `jQuery` Il risultato.\n\nL'argomento accetta gli stessi valori di [`parent()`](../component/#parent) di un componente.\n\nExample: Uso di parent()\n```js\nconsole.log(macro.parent().prop('tagName'));  // BODY\n```\n\n### self.html([value])\n\nType: `method`\n\nLegge o sostituisce il contenuto HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Il nuovo contenuto. |\n\nReturns: `String|jQuery` Il contenuto, oppure l'elemento quando passi `value`.\n\nUn array viene unito.\n\nExample: Uso di html()\n```js\nmacro.html('<i>A</i>');\nconsole.log(macro.html());  // <i>A</i>\n```\n\n### self.text([value])\n\nType: `method`\n\nLegge o sostituisce il contenuto testuale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Il nuovo contenuto. |\n\nReturns: `String|jQuery` Il contenuto, oppure l'elemento quando passi `value`.\n\nUn array viene unito.\n\nExample: Uso di text()\n```js\nmacro.text('A');\nconsole.log(macro.text());  // A\n```\n\n### self.append(value)\n\nType: `method`\n\nAggiunge contenuto alla fine dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Il contenuto. |\n\nReturns: `jQuery` L'elemento.\n\nUn array viene unito.\n\nExample: Uso di append()\n```js\nmacro.append('<i>A</i>');\nconsole.log(macro.find('i').length);  // 1\n```\n\n### self.empty()\n\nType: `method`\n\nRimuove il contenuto dell'elemento.\n\nReturns: `jQuery` L'elemento.\n\nExample: Uso di empty()\n```js\nmacro.empty();\nconsole.log(macro.html() === '');  // true\n```\n\n### self.event(name, [selector], callback)\n\nType: `method`\n\nCollega un evento jQuery all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `selector` | `String` | no |  | Il selettore delegato. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nReturns: `Macro` La macro.\n\nGli argomenti sono gli stessi del metodo jQuery `on()`.\n\nExample: Uso di event()\n```js\nmacro.event('click', '.label', () => console.log('clicked'));  // clicked\nmacro.find('.label').click();\n```\n\n### self.aclass(classes, [timeout])\n\nType: `method`\n\nAggiunge classi CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Le classi. |\n| `timeout` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `Macro` La macro.\n\nExample: Uso di aclass()\n```js\nmacro.aclass('active');\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.rclass([classes], [timeout])\n\nType: `method`\n\nRimuove classi CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Le classi. |\n| `timeout` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `Macro` La macro.\n\nSenza argomenti, vengono rimosse tutte le classi.\n\nExample: Uso di rclass()\n```js\nmacro.aclass('active');\nmacro.rclass('active');\nconsole.log(macro.hclass('active'));  // false\n```\n\n### self.rclass2(search)\n\nType: `method`\n\nRimuove le classi CSS che contengono un testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Il testo o un'espressione regolare. |\n\nReturns: `Macro` La macro.\n\nExample: Uso di rclass2()\n```js\nmacro.aclass('col-1 col-2');\nmacro.rclass2('col-');\nconsole.log(macro.hclass('col-2'));  // false\n```\n\n### self.tclass(classes, [state])\n\nType: `method`\n\nAttiva o disattiva classi CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Le classi. |\n| `state` | `Boolean` | no |  | Forza lo stato. |\n\nReturns: `Macro` La macro.\n\nExample: Uso di tclass()\n```js\nmacro.tclass('active', true);\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.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` Il risultato.\n\nExample: Uso di hclass()\n```js\nconsole.log(macro.hclass('missing'));  // false\n```\n\n### self.attr(name, [value])\n\nType: `method`\n\nLegge o scrive un attributo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'attributo. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String|Macro` Il valore, oppure la macro quando passi `value`.\n\nExample: Uso di attr()\n```js\nmacro.attr('title', 'Orders');\nconsole.log(macro.attr('title'));  // Orders\n```\n\n### self.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 senza il prefisso `data-`. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String|Macro` Il valore, oppure la macro quando passi `value`.\n\nExample: Uso di attrd()\n```js\nmacro.attrd('id', '5');\nconsole.log(macro.attr('data-id'));  // 5\n```\n\n### self.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 senza il prefisso `data-`. |\n\nReturns: `String` Il valore.\n\nExample: Uso di attrd2()\n```js\nconsole.log(macro.attrd2('area'));  // main\n```\n\n### self.css(name, [value])\n\nType: `method`\n\nLegge o scrive una proprietà CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La proprietà. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String|Macro` Il valore, oppure la macro quando passi `value`.\n\nExample: Uso di css()\n```js\nmacro.css('display', 'block');\nconsole.log(macro.css('display'));  // block\n```\n\n### self.visible([callback])\n\nType: `method`\n\nIndica se l'elemento è visibile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Viene eseguito quando l'elemento è visibile. |\n\nReturns: `Boolean` La visibilità corrente.\n\nCon un callback, la funzione viene eseguita non appena l'elemento è visibile.\n\nExample: Uso di visible()\n```js\nconsole.log(macro.visible());  // true\n```\n\n### self.width([callback])\n\nType: `method`\n\nRestituisce la larghezza dell'elemento in pixel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Riceve la larghezza. |\n\nReturns: `Number` La larghezza.\n\nCon un callback, la funzione viene eseguita non appena la larghezza è maggiore di zero.\n\nExample: Uso di width()\n```js\nmacro.css('display', 'block');\nmacro.css('width', '200px');\nconsole.log(macro.width());  // 200\n```\n\n### self.height([callback])\n\nType: `method`\n\nRestituisce l'altezza dell'elemento in pixel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Riceve l'altezza. |\n\nReturns: `Number` L'altezza.\n\nCon un callback, la funzione viene eseguita non appena l'altezza è maggiore di zero.\n\nExample: Uso di height()\n```js\nmacro.css('display', 'block');\nmacro.css('height', '50px');\nconsole.log(macro.height());  // 50\n```\n\n### self.autofocus([selector])\n\nType: `method`\n\nSposta il focus sul primo campo visibile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | I campi. |\n\nReturns: `Macro` La macro.\n\nSui dispositivi mobili il metodo non fa nulla.\n\nExample: Uso di autofocus()\n```js\nmacro.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### self.faicon(value)\n\nType: `method`\n\nCompleta il nome di un'icona.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il nome dell'icona. |\n\nReturns: `String` Le classi CSS.\n\nUn nome senza spazi riceve `DEF.iconprefix`, cioè `ti ti-`.\n\nExample: Uso di faicon()\n```js\nconsole.log(macro.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"binder","signature":"self.binder","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"method","name":"get()","signature":"self.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"self.set(value)","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"self.refresh()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"self.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"self.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"self.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"self.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"self.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"self.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"self.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"self.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"self.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"self.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"self.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"self.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"self.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"self.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"self.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"self.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"self.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"self.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"self.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"self.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"self.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"self.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"self.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"self.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammfd6gj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/macro/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Macro","summary":"Delegate, vlastnosti a metódy inštancie macro.","markdown":"---\ntitle: Macro\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/macro/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Macro\n\n> Delegate, vlastnosti a metódy inštancie macro.\n\nInštancia macro je objekt odovzdaný deklarácii `MACRO()`. Pridáva elementu správanie pomocou príkazu [`macro`](../ui-bind/#macro) elementu `<ui-bind>`. Koncept vysvetľuje časť [Macro](../../guides/macros/). V príkladoch je `macro` inštancia pripojená k `<ui-bind>` naviazanému na `form.name`.\n\n## API\n\n### self.make = function()\n\nType: `delegate`\n\nSpustí sa raz po deklarácii.\n\nExample: Príprava elementu\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self, element, cls) {\n        self.make = function() {\n            element.aclass(cls);\n        };\n    });\n</script>\n```\n\n### self.setter = function(value, path, type)\n\nType: `delegate`\n\nDostáva hodnotu na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na path. |\n| `path` | `String` | yes |  | Path, ktorý sa zmenil. |\n| `type` | `Number` | yes |  | Typ zmeny. |\n\nDelegate sa spustí pri každej aktualizácii binderu.\n\nExample: Vykreslenie hodnoty\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.setter = function(value) {\n            self.text(value);\n        };\n    });\n    SET('form.name', 'Peter');\n</script>\n```\n\n### self.service = function(counter)\n\nType: `delegate`\n\nSpúšťa sa raz za minútu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Počet spustení. |\n\nDelegate dostáva počítadlo, ktoré sa pri každom spustení zvýši o jednotku.\n\n### self.destroy = function()\n\nType: `delegate`\n\nSpustí sa, keď sa odstráni element binderu.\n\nExample: Uvoľnenie zdrojov\n```html\n<ui-bind path=\"form.name\" config=\"macro:card\"></ui-bind>\n\n<script>\n    MACRO('card', function(self) {\n        self.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(function() {\n        $('ui-bind').remove();\n        FREE();\n    }, 500);\n</script>\n```\n\n### self.name\n\nType: `property`\n\nNázov macra.\n\nExample: Čítanie name\n```js\nconsole.log(macro.name);  // demo\n```\n\n### self.path\n\nType: `property`\n\nPath binderu.\n\nExample: Čítanie path\n```js\nconsole.log(macro.path);  // form.name\n```\n\n### self.element\n\nType: `property`\n\nElement binderu ako objekt jQuery.\n\nExample: Čítanie element\n```js\nconsole.log(macro.element.attr('id'));  // box\n```\n\n### self.dom\n\nType: `property`\n\nElement binderu ako uzol DOM.\n\nExample: Čítanie dom\n```js\nconsole.log(macro.dom.id);  // box\n```\n\n### self.binder\n\nType: `property`\n\nBinder, ktorý vytvoril macro.\n\nPozri metódy [`refresh()`](../ui-bind/#refresh) a [`exec()`](../ui-bind/#exec).\n\nExample: Čítanie binder\n```js\nconsole.log(macro.binder.path);  // form.name\n```\n\n### self.scope\n\nType: `property`\n\n[Scope](../scope/) binderu.\n\nVlastnosť sa priradí po delegate `make` a existuje, keď path obsahuje `?`.\n\nExample: Čítanie scope\n```js\nconsole.log(macro.scope.path);  // users\n```\n\n### self.get()\n\nType: `method`\n\nPrečíta hodnotu na path.\n\nReturns: `Object` Hodnota.\n\nExample: Použitie get()\n```js\nSET('form.name', 'Peter');\nconsole.log(macro.get());  // Peter\n```\n\n### self.set(value)\n\nType: `method`\n\nZapíše hodnotu na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Nová hodnota. |\n\nExample: Použitie set()\n```js\nmacro.set('Peter');\nconsole.log(GET('form.name'));  // Peter\n```\n\n### self.refresh()\n\nType: `method`\n\nZnova spustí binder s aktuálnou hodnotou.\n\nReturns: `Macro` Macro.\n\nExample: Použitie refresh()\n```js\nmacro.setter = value => console.log(value);  // Peter\nwindow.form.name = 'Peter';\nmacro.refresh();\n```\n\n### self.EXEC(path, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá funkciu podľa jej path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path funkcie. |\n\nReturns: `Macro` Macro.\n\nZnak `?` sa nahradí za path scopu. Predpona `@` zavolá metódu nadradeného komponentu.\n\nExample: Použitie EXEC()\n```js\nmacro.EXEC('@ping', 5);\n```\n\n### self.SEEX(path, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá funkciu alebo zapíše hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `Macro` Macro.\n\nKeď na path nie je žiadna funkcia, zapíše sa na ňu prvý argument.\n\nExample: Použitie SEEX()\n```js\nmacro.SEEX('@title', 'Orders');\nconsole.log(FIND('owner').title);  // Orders\n```\n\n### self.find(selector)\n\nType: `method`\n\nNájde vnorené elementy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Object` | yes |  | Selektor alebo objekt selektorov. |\n\nReturns: `jQuery|Object` Výsledok.\n\nObjekt selektorov vráti objekt výsledkov jQuery s rovnakými kľúčmi.\n\nExample: Použitie find()\n```js\nconsole.log(macro.find('.label').text());  // Text\n```\n\n### self.closest(selector)\n\nType: `method`\n\nNájde najbližší zodpovedajúci nadradený element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor. |\n\nReturns: `jQuery` Výsledok.\n\nExample: Použitie closest()\n```js\nconsole.log(macro.closest('body').length);  // 1\n```\n\n### self.parent([selector])\n\nType: `method`\n\nVráti nadradený element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Selektor. |\n\nReturns: `jQuery` Výsledok.\n\nArgument prijíma rovnaké hodnoty ako [`parent()`](../component/#parent) komponentu.\n\nExample: Použitie parent()\n```js\nconsole.log(macro.parent().prop('tagName'));  // BODY\n```\n\n### self.html([value])\n\nType: `method`\n\nPrečíta alebo nahradí obsah HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Nový obsah. |\n\nReturns: `String|jQuery` Obsah, alebo element, keď odovzdáš `value`.\n\nPole sa spojí.\n\nExample: Použitie html()\n```js\nmacro.html('<i>A</i>');\nconsole.log(macro.html());  // <i>A</i>\n```\n\n### self.text([value])\n\nType: `method`\n\nPrečíta alebo nahradí textový obsah.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | no |  | Nový obsah. |\n\nReturns: `String|jQuery` Obsah, alebo element, keď odovzdáš `value`.\n\nPole sa spojí.\n\nExample: Použitie text()\n```js\nmacro.text('A');\nconsole.log(macro.text());  // A\n```\n\n### self.append(value)\n\nType: `method`\n\nPridá obsah na koniec elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Obsah. |\n\nReturns: `jQuery` Element.\n\nPole sa spojí.\n\nExample: Použitie append()\n```js\nmacro.append('<i>A</i>');\nconsole.log(macro.find('i').length);  // 1\n```\n\n### self.empty()\n\nType: `method`\n\nOdstráni obsah elementu.\n\nReturns: `jQuery` Element.\n\nExample: Použitie empty()\n```js\nmacro.empty();\nconsole.log(macro.html() === '');  // true\n```\n\n### self.event(name, [selector], callback)\n\nType: `method`\n\nPripojí k elementu udalosť jQuery.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `selector` | `String` | no |  | Delegovaný selektor. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nReturns: `Macro` Macro.\n\nArgumenty sú rovnaké ako pri metóde jQuery `on()`.\n\nExample: Použitie event()\n```js\nmacro.event('click', '.label', () => console.log('clicked'));  // clicked\nmacro.find('.label').click();\n```\n\n### self.aclass(classes, [timeout])\n\nType: `method`\n\nPridá triedy CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Triedy. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `Macro` Macro.\n\nExample: Použitie aclass()\n```js\nmacro.aclass('active');\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.rclass([classes], [timeout])\n\nType: `method`\n\nOdstráni triedy CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | no |  | Triedy. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `Macro` Macro.\n\nBez argumentu sa odstránia všetky triedy.\n\nExample: Použitie rclass()\n```js\nmacro.aclass('active');\nmacro.rclass('active');\nconsole.log(macro.hclass('active'));  // false\n```\n\n### self.rclass2(search)\n\nType: `method`\n\nOdstráni triedy CSS, ktoré obsahujú zadaný text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String|RegExp` | yes |  | Text alebo regulárny výraz. |\n\nReturns: `Macro` Macro.\n\nExample: Použitie rclass2()\n```js\nmacro.aclass('col-1 col-2');\nmacro.rclass2('col-');\nconsole.log(macro.hclass('col-2'));  // false\n```\n\n### self.tclass(classes, [state])\n\nType: `method`\n\nPrepne triedy CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `classes` | `String` | yes |  | Triedy. |\n| `state` | `Boolean` | no |  | Vynúti stav. |\n\nReturns: `Macro` Macro.\n\nExample: Použitie tclass()\n```js\nmacro.tclass('active', true);\nconsole.log(macro.hclass('active'));  // true\n```\n\n### self.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` Výsledok.\n\nExample: Použitie hclass()\n```js\nconsole.log(macro.hclass('missing'));  // false\n```\n\n### self.attr(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše atribút.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Atribút. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Macro` Hodnota, alebo macro, keď odovzdáš `value`.\n\nExample: Použitie attr()\n```js\nmacro.attr('title', 'Orders');\nconsole.log(macro.attr('title'));  // Orders\n```\n\n### self.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 bez prefixu `data-`. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Macro` Hodnota, alebo macro, keď odovzdáš `value`.\n\nExample: Použitie attrd()\n```js\nmacro.attrd('id', '5');\nconsole.log(macro.attr('data-id'));  // 5\n```\n\n### self.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 bez prefixu `data-`. |\n\nReturns: `String` Hodnota.\n\nExample: Použitie attrd2()\n```js\nconsole.log(macro.attrd2('area'));  // main\n```\n\n### self.css(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše vlastnosť CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Vlastnosť. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String|Macro` Hodnota, alebo macro, keď odovzdáš `value`.\n\nExample: Použitie css()\n```js\nmacro.css('display', 'block');\nconsole.log(macro.css('display'));  // block\n```\n\n### self.visible([callback])\n\nType: `method`\n\nUrčuje, či je element viditeľný.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Spustí sa, keď je element viditeľný. |\n\nReturns: `Boolean` Aktuálna viditeľnosť.\n\nS callbackom sa funkcia spustí, hneď ako je element viditeľný.\n\nExample: Použitie visible()\n```js\nconsole.log(macro.visible());  // true\n```\n\n### self.width([callback])\n\nType: `method`\n\nVráti šírku elementu v pixeloch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Dostane šírku. |\n\nReturns: `Number` Šírka.\n\nS callbackom sa funkcia spustí, hneď ako je šírka väčšia ako nula.\n\nExample: Použitie width()\n```js\nmacro.css('display', 'block');\nmacro.css('width', '200px');\nconsole.log(macro.width());  // 200\n```\n\n### self.height([callback])\n\nType: `method`\n\nVráti výšku elementu v pixeloch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | no |  | Dostane výšku. |\n\nReturns: `Number` Výška.\n\nS callbackom sa funkcia spustí, hneď ako je výška väčšia ako nula.\n\nExample: Použitie height()\n```js\nmacro.css('display', 'block');\nmacro.css('height', '50px');\nconsole.log(macro.height());  // 50\n```\n\n### self.autofocus([selector])\n\nType: `method`\n\nPresunie fokus na prvé viditeľné pole.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Polia. |\n\nReturns: `Macro` Macro.\n\nNa mobilných zariadeniach metóda nerobí nič.\n\nExample: Použitie autofocus()\n```js\nmacro.autofocus();\nconsole.log(document.activeElement.tagName);  // INPUT\n```\n\n### self.faicon(value)\n\nType: `method`\n\nDoplní názov ikony.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Názov ikony. |\n\nReturns: `String` Triedy CSS.\n\nNázov bez medzery dostane `DEF.iconprefix`, čo je `ti ti-`.\n\nExample: Použitie faicon()\n```js\nconsole.log(macro.faicon('home'));  // ti ti-home\n```\n","entries":[{"type":"delegate","name":"make","signature":"self.make = function()","since":"","deprecated":false},{"type":"delegate","name":"setter","signature":"self.setter = function(value, path, type)","since":"","deprecated":false},{"type":"delegate","name":"service","signature":"self.service = function(counter)","since":"","deprecated":false},{"type":"delegate","name":"destroy","signature":"self.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"self.name","since":"","deprecated":false},{"type":"property","name":"path","signature":"self.path","since":"","deprecated":false},{"type":"property","name":"element","signature":"self.element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"self.dom","since":"","deprecated":false},{"type":"property","name":"binder","signature":"self.binder","since":"","deprecated":false},{"type":"property","name":"scope","signature":"self.scope","since":"","deprecated":false},{"type":"method","name":"get()","signature":"self.get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"self.set(value)","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"self.refresh()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"self.EXEC(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"self.SEEX(path, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"self.find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"self.closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"self.parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"self.html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"self.text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"self.append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"self.empty()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"self.event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"self.aclass(classes, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"self.rclass([classes], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"self.rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"self.tclass(classes, [state])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"self.hclass(name)","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"self.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"self.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"self.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"css()","signature":"self.css(name, [value])","since":"","deprecated":false},{"type":"method","name":"visible()","signature":"self.visible([callback])","since":"","deprecated":false},{"type":"method","name":"width()","signature":"self.width([callback])","since":"","deprecated":false},{"type":"method","name":"height()","signature":"self.height([callback])","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"self.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"faicon()","signature":"self.faicon(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammn63sr61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"ui-plugin","summary":"The attributes and configuration keys of the ui-plugin element.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-plugin\n\n> The attributes and configuration keys of the ui-plugin element.\n\nThe `<ui-plugin>` element creates a [Scope](../scope/) for its content and connects it to the [Plugin](../plugin/) with the same path. The concept is explained in [Scopes](../../guides/scopes/) and [Plugins](../../guides/plugins/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nSets the path of the scope and selects the plugin.\n\nThe path of a nested element is appended to the path of its parent scope. The attribute accepts these forms:\n\n| Value | Meaning |\n| --- | --- |\n| `users` | The scope `users`, or `parent.users` inside another scope. |\n| `!users` | An isolated scope. Its path ignores the parent scope. |\n| `?` | A scope with a generated unique path. An empty or missing path does the same. |\n| `*` | The scope `common`, taken from `DEF.pathcommon`. |\n| `users template` | The scope `users` with a new plugin created from `PLUGIN('* template', fn)`. |\n| `users__config__default` | The path, configuration and default value in one attribute. |\n\nThe plugin of an element without content is removed when the library cleans up unused objects.\n\nExample: Nested scopes\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"detail\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('users.detail', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail\n</script>\n```\n\nExample: An isolated scope\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"!settings\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\nExample: A reusable plugin template\n```html\n<ui-plugin path=\"orders counter\"><span></span></ui-plugin>\n<ui-plugin path=\"invoices counter\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('* counter', function(exports) {\n        console.log(exports.name);\n    });\n</script>\n```\n\nExample: Path, configuration and default value together\n```html\n<ui-plugin path=\"users__aclass:1__{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users\n</script>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigures the scope.\n\nThe value is a list of `key:value` pairs. The keys are listed on this page, and all of them are available in [`scope.config`](../scope/#config).\n\nExample: Reading the configuration\n```html\n<ui-plugin path=\"users\" config=\"limit:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nSets the initial value of the scope path.\n\nThe attribute contains a JavaScript expression. The [`default()`](../scope/#default) method of the scope restores the value.\n\nExample: An initial model\n```html\n<ui-plugin path=\"users\" default=\"{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users')), 500);  // {\"page\":1}\n</script>\n```\n\n### data-jc-value=\"expression\"\n\nType: `property`\n\nSets the initial value of the scope path.\n\nIt is used when the `default` attribute is missing.\n\nExample: An initial model\n```html\n<ui-plugin path=\"users\" data-jc-value=\"{ page: 2 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page')), 500);  // 2\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nToggles CSS classes on the element.\n\nIt is used when the `class` configuration key is missing.\n\nExample: A class after the initialization\n```html\n<ui-plugin path=\"users\" data-jc-class=\"ready\" config=\"delay:10\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### data-jc-init=\"path\"\n\nType: `property`\n\nCalls a function when the scope is created.\n\nIt is used when the `init` configuration key is missing. The function has the same arguments as [`init`](#init).\n\nExample: An initialization function\n```html\n<ui-plugin path=\"users\" data-jc-init=\"common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = { onscope: path => console.log(path) };  // users\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### isolated:true\n\nType: `config`\n\nMakes the path of the scope independent of the parent scope.\n\nIt has the same effect as the `!` prefix of the path.\n\nExample: An isolated scope\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"settings\" config=\"isolated:true\"><span></span></ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAdds the path of the scope to the element as a CSS class.\n\nExample: The path as a class\n```html\n<ui-plugin path=\"users\" config=\"aclass:true\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### class:classes\n\nType: `config`\n\nToggles CSS classes on the element after a delay.\n\nSeparate several classes with a space. The [`delay`](#delay) key sets the delay.\n\nExample: Classes after the delay\n```html\n<ui-plugin path=\"users\" config=\"class:ready\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### delay:milliseconds\n\nType: `config`\n\nSets the delay of the `class` key in milliseconds.\n\nThe default value is `300`.\n\nExample: A shorter delay\n```html\n<ui-plugin path=\"users\" config=\"class:ready;delay:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true\n</script>\n```\n\n### init:path\n\nType: `config`\n\nCalls a function when the scope is created.\n\nThe function receives the path and the element of the scope, and `this` is the [Scope](../scope/). A `?` in the value is replaced with the path of the scope.\n\nExample: An initialization function\n```html\n<ui-plugin path=\"users\" config=\"init:common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = {\n        onscope: function(path, element) {\n            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users\n        }\n    };\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### plugin=\"path\"\n\nType: `type`\n\nOther elements can create a scope with an attribute.\n\nUse `plugin`, `data-plugin`, `scope` or `data-scope` on any element. The `<ui-component>`, `<ui-bind>` and `<ui-import>` elements accept only the `plugin` attribute. The value has the same forms as `path`.\n\nExample: A scope on a div\n```html\n<div plugin=\"users\"><span></span></div>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-value","signature":"data-jc-value=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-init","signature":"data-jc-init=\"path\"","since":"","deprecated":false},{"type":"config","name":"isolated","signature":"isolated:true","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:classes","since":"","deprecated":false},{"type":"config","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"type","name":"Scope on another element","signature":"plugin=\"path\"","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammn63sr61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"ui-plugin","summary":"Die Attribute und Konfigurationsschlüssel des Elements ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-plugin\n\n> Die Attribute und Konfigurationsschlüssel des Elements ui-plugin.\n\nDas Element `<ui-plugin>` erstellt einen [Scope](../scope/) für seinen Inhalt und verbindet ihn mit dem [Plugin](../plugin/), das denselben Path hat. Das Konzept wird unter [Scopes](../../guides/scopes/) und [Plugins](../../guides/plugins/) erklärt.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nLegt den Path des Scopes fest und wählt das Plugin aus.\n\nDer Path eines verschachtelten Elements wird an den Path seines übergeordneten Scopes angehängt. Das Attribut akzeptiert diese Formen:\n\n| Wert | Bedeutung |\n| --- | --- |\n| `users` | Der Scope `users` oder, innerhalb eines anderen Scopes, `parent.users`. |\n| `!users` | Ein isolierter Scope. Sein Path ignoriert den übergeordneten Scope. |\n| `?` | Ein Scope mit einem generierten, eindeutigen Path. Ein leerer oder fehlender Path bewirkt dasselbe. |\n| `*` | Der Scope `common`, entnommen aus `DEF.pathcommon`. |\n| `users template` | Der Scope `users` mit einem neuen Plugin, das aus `PLUGIN('* template', fn)` erstellt wird. |\n| `users__config__default` | Path, Konfiguration und Standardwert in einem Attribut. |\n\nDas Plugin eines Elements ohne Inhalt wird entfernt, wenn die Bibliothek ungenutzte Objekte bereinigt.\n\nExample: Verschachtelte Scopes\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"detail\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('users.detail', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail\n</script>\n```\n\nExample: Ein isolierter Scope\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"!settings\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\nExample: Ein wiederverwendbares Plugin-Template\n```html\n<ui-plugin path=\"orders counter\"><span></span></ui-plugin>\n<ui-plugin path=\"invoices counter\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('* counter', function(exports) {\n        console.log(exports.name);\n    });\n</script>\n```\n\nExample: Path, Konfiguration und Standardwert zusammen\n```html\n<ui-plugin path=\"users__aclass:1__{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users\n</script>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nKonfiguriert den Scope.\n\nDer Wert ist eine Liste von `key:value`-Paaren. Die Schlüssel sind auf dieser Seite aufgeführt und stehen alle in [`scope.config`](../scope/#config) zur Verfügung.\n\nExample: Die Konfiguration lesen\n```html\n<ui-plugin path=\"users\" config=\"limit:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nLegt den Anfangswert des Scope-Paths fest.\n\nDas Attribut enthält einen JavaScript-Ausdruck. Die Methode [`default()`](../scope/#default) des Scopes stellt den Wert wieder her.\n\nExample: Ein Anfangsmodell\n```html\n<ui-plugin path=\"users\" default=\"{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users')), 500);  // {\"page\":1}\n</script>\n```\n\n### data-jc-value=\"expression\"\n\nType: `property`\n\nLegt den Anfangswert des Scope-Paths fest.\n\nWird verwendet, wenn das Attribut `default` fehlt.\n\nExample: Ein Anfangsmodell\n```html\n<ui-plugin path=\"users\" data-jc-value=\"{ page: 2 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page')), 500);  // 2\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nSchaltet CSS-Klassen auf dem Element um.\n\nWird verwendet, wenn der Konfigurationsschlüssel `class` fehlt.\n\nExample: Eine Klasse nach der Initialisierung\n```html\n<ui-plugin path=\"users\" data-jc-class=\"ready\" config=\"delay:10\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### data-jc-init=\"path\"\n\nType: `property`\n\nRuft eine Funktion auf, wenn der Scope erstellt wird.\n\nWird verwendet, wenn der Konfigurationsschlüssel `init` fehlt. Die Funktion hat dieselben Argumente wie [`init`](#init).\n\nExample: Eine Initialisierungsfunktion\n```html\n<ui-plugin path=\"users\" data-jc-init=\"common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = { onscope: path => console.log(path) };  // users\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### isolated:true\n\nType: `config`\n\nMacht den Path des Scopes unabhängig vom übergeordneten Scope.\n\nDas hat dieselbe Wirkung wie das Präfix `!` des Paths.\n\nExample: Ein isolierter Scope\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"settings\" config=\"isolated:true\"><span></span></ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nFügt den Path des Scopes dem Element als CSS-Klasse hinzu.\n\nExample: Der Path als Klasse\n```html\n<ui-plugin path=\"users\" config=\"aclass:true\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### class:classes\n\nType: `config`\n\nSchaltet CSS-Klassen auf dem Element nach einer Verzögerung um.\n\nTrenne mehrere Klassen durch ein Leerzeichen. Der Schlüssel [`delay`](#delay) legt die Verzögerung fest.\n\nExample: Klassen nach der Verzögerung\n```html\n<ui-plugin path=\"users\" config=\"class:ready\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### delay:milliseconds\n\nType: `config`\n\nLegt die Verzögerung des Schlüssels `class` in Millisekunden fest.\n\nDer Standardwert ist `300`.\n\nExample: Eine kürzere Verzögerung\n```html\n<ui-plugin path=\"users\" config=\"class:ready;delay:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true\n</script>\n```\n\n### init:path\n\nType: `config`\n\nRuft eine Funktion auf, wenn der Scope erstellt wird.\n\nDie Funktion erhält den Path und das Element des Scopes, und `this` ist der [Scope](../scope/). Ein `?` im Wert wird durch den Path des Scopes ersetzt.\n\nExample: Eine Initialisierungsfunktion\n```html\n<ui-plugin path=\"users\" config=\"init:common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = {\n        onscope: function(path, element) {\n            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users\n        }\n    };\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### plugin=\"path\"\n\nType: `type`\n\nAndere Elemente können über ein Attribut einen Scope erstellen.\n\nVerwende `plugin`, `data-plugin`, `scope` oder `data-scope` auf einem beliebigen Element. Die Elemente `<ui-component>`, `<ui-bind>` und `<ui-import>` akzeptieren nur das Attribut `plugin`. Der Wert hat dieselben Formen wie `path`.\n\nExample: Ein Scope auf einem div\n```html\n<div plugin=\"users\"><span></span></div>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-value","signature":"data-jc-value=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-init","signature":"data-jc-init=\"path\"","since":"","deprecated":false},{"type":"config","name":"isolated","signature":"isolated:true","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:classes","since":"","deprecated":false},{"type":"config","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"type","name":"Scope on another element","signature":"plugin=\"path\"","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammn63sr61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-plugin/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-plugin/\nupdated: 2026-11-18T13:58:29.465Z\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 un [Scope](../scope/) para su contenido y lo conecta con el [Plugin](../plugin/) que tiene el mismo path. El concepto se explica en [Scopes](../../guides/scopes/) y [Plugins](../../guides/plugins/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nDefine el path del scope y selecciona el plugin.\n\nEl path de un elemento anidado se añade al path de su scope padre. El atributo admite estas formas:\n\n| Valor | Significado |\n| --- | --- |\n| `users` | El scope `users`, o `parent.users` dentro de otro scope. |\n| `!users` | Un scope aislado. Su path ignora el scope padre. |\n| `?` | Un scope con un path único generado. Un path vacío o ausente hace lo mismo. |\n| `*` | El scope `common`, tomado de `DEF.pathcommon`. |\n| `users template` | El scope `users` con un plugin nuevo creado a partir de `PLUGIN('* template', fn)`. |\n| `users__config__default` | El path, la configuración y el valor predeterminado en un solo atributo. |\n\nEl plugin de un elemento sin contenido se elimina cuando la biblioteca limpia los objetos que no se usan.\n\nExample: Scopes anidados\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"detail\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('users.detail', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail\n</script>\n```\n\nExample: Un scope aislado\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"!settings\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\nExample: Una plantilla de plugin reutilizable\n```html\n<ui-plugin path=\"orders counter\"><span></span></ui-plugin>\n<ui-plugin path=\"invoices counter\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('* counter', function(exports) {\n        console.log(exports.name);\n    });\n</script>\n```\n\nExample: Path, configuración y valor predeterminado juntos\n```html\n<ui-plugin path=\"users__aclass:1__{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users\n</script>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigura el scope.\n\nEl valor es una lista de pares `key:value`. Las claves aparecen en esta página, y todas están disponibles en [`scope.config`](../scope/#config).\n\nExample: Leer la configuración\n```html\n<ui-plugin path=\"users\" config=\"limit:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nDefine el valor inicial del path del scope.\n\nEl atributo contiene una expresión de JavaScript. El método [`default()`](../scope/#default) del scope restaura el valor.\n\nExample: Un modelo inicial\n```html\n<ui-plugin path=\"users\" default=\"{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users')), 500);  // {\"page\":1}\n</script>\n```\n\n### data-jc-value=\"expression\"\n\nType: `property`\n\nDefine el valor inicial del path del scope.\n\nSe usa cuando falta el atributo `default`.\n\nExample: Un modelo inicial\n```html\n<ui-plugin path=\"users\" data-jc-value=\"{ page: 2 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page')), 500);  // 2\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nAlterna clases CSS en el elemento.\n\nSe usa cuando falta la clave de configuración `class`.\n\nExample: Una clase después de la inicialización\n```html\n<ui-plugin path=\"users\" data-jc-class=\"ready\" config=\"delay:10\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### data-jc-init=\"path\"\n\nType: `property`\n\nLlama a una función cuando se crea el scope.\n\nSe usa cuando falta la clave de configuración `init`. La función tiene los mismos argumentos que [`init`](#init).\n\nExample: Una función de inicialización\n```html\n<ui-plugin path=\"users\" data-jc-init=\"common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = { onscope: path => console.log(path) };  // users\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### isolated:true\n\nType: `config`\n\nHace que el path del scope sea independiente del scope padre.\n\nTiene el mismo efecto que el prefijo `!` del path.\n\nExample: Un scope aislado\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"settings\" config=\"isolated:true\"><span></span></ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAñade el path del scope al elemento como clase CSS.\n\nExample: El path como clase\n```html\n<ui-plugin path=\"users\" config=\"aclass:true\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### class:classes\n\nType: `config`\n\nAlterna clases CSS en el elemento después de un retardo.\n\nSepara varias clases con un espacio. La clave [`delay`](#delay) define el retardo.\n\nExample: Clases después del retardo\n```html\n<ui-plugin path=\"users\" config=\"class:ready\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### delay:milliseconds\n\nType: `config`\n\nDefine el retardo de la clave `class` en milisegundos.\n\nEl valor predeterminado es `300`.\n\nExample: Un retardo más corto\n```html\n<ui-plugin path=\"users\" config=\"class:ready;delay:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true\n</script>\n```\n\n### init:path\n\nType: `config`\n\nLlama a una función cuando se crea el scope.\n\nLa función recibe el path y el elemento del scope, y `this` es el [Scope](../scope/). Un `?` en el valor se sustituye por el path del scope.\n\nExample: Una función de inicialización\n```html\n<ui-plugin path=\"users\" config=\"init:common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = {\n        onscope: function(path, element) {\n            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users\n        }\n    };\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### plugin=\"path\"\n\nType: `type`\n\nOtros elementos pueden crear un scope con un atributo.\n\nUsa `plugin`, `data-plugin`, `scope` o `data-scope` en cualquier elemento. Los elementos `<ui-component>`, `<ui-bind>` y `<ui-import>` solo aceptan el atributo `plugin`. El valor tiene las mismas formas que `path`.\n\nExample: Un scope en un div\n```html\n<div plugin=\"users\"><span></span></div>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-value","signature":"data-jc-value=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-init","signature":"data-jc-init=\"path\"","since":"","deprecated":false},{"type":"config","name":"isolated","signature":"isolated:true","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:classes","since":"","deprecated":false},{"type":"config","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"type","name":"Scope on another element","signature":"plugin=\"path\"","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammn63sr61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-plugin/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-plugin/\nupdated: 2026-11-18T13:58:29.465Z\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 un [Scope](../scope/) pour son contenu et le connecte au [Plugin](../plugin/) qui a le même path. Le concept est expliqué dans [Scopes](../../guides/scopes/) et [Plugins](../../guides/plugins/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nDéfinit le path du scope et sélectionne le plugin.\n\nLe path d'un élément imbriqué est ajouté à la suite du path de son scope parent. L'attribut accepte ces formes :\n\n| Valeur | Signification |\n| --- | --- |\n| `users` | Le scope `users`, ou `parent.users` à l'intérieur d'un autre scope. |\n| `!users` | Un scope isolé. Son path ignore le scope parent. |\n| `?` | Un scope avec un path unique généré. Un path vide ou absent produit le même résultat. |\n| `*` | Le scope `common`, issu de `DEF.pathcommon`. |\n| `users template` | Le scope `users` avec un nouveau plugin créé à partir de `PLUGIN('* template', fn)`. |\n| `users__config__default` | Le path, la configuration et la valeur par défaut dans un seul attribut. |\n\nLe plugin d'un élément sans contenu est supprimé quand la bibliothèque nettoie les objets inutilisés.\n\nExample: Scopes imbriqués\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"detail\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('users.detail', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail\n</script>\n```\n\nExample: Un scope isolé\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"!settings\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\nExample: Un modèle de plugin réutilisable\n```html\n<ui-plugin path=\"orders counter\"><span></span></ui-plugin>\n<ui-plugin path=\"invoices counter\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('* counter', function(exports) {\n        console.log(exports.name);\n    });\n</script>\n```\n\nExample: Path, configuration et valeur par défaut ensemble\n```html\n<ui-plugin path=\"users__aclass:1__{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users\n</script>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigure le scope.\n\nLa valeur est une liste de paires `key:value`. Les clés sont listées sur cette page, et toutes sont disponibles dans [`scope.config`](../scope/#config).\n\nExample: Lire la configuration\n```html\n<ui-plugin path=\"users\" config=\"limit:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nDéfinit la valeur initiale du path du scope.\n\nL'attribut contient une expression JavaScript. La méthode [`default()`](../scope/#default) du scope restaure la valeur.\n\nExample: Un modèle de données initial\n```html\n<ui-plugin path=\"users\" default=\"{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users')), 500);  // {\"page\":1}\n</script>\n```\n\n### data-jc-value=\"expression\"\n\nType: `property`\n\nDéfinit la valeur initiale du path du scope.\n\nElle est utilisée quand l'attribut `default` est absent.\n\nExample: Un modèle de données initial\n```html\n<ui-plugin path=\"users\" data-jc-value=\"{ page: 2 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page')), 500);  // 2\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nBascule des classes CSS sur l'élément.\n\nElle est utilisée quand la clé de configuration `class` est absente.\n\nExample: Une classe après l'initialisation\n```html\n<ui-plugin path=\"users\" data-jc-class=\"ready\" config=\"delay:10\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### data-jc-init=\"path\"\n\nType: `property`\n\nAppelle une fonction à la création du scope.\n\nElle est utilisée quand la clé de configuration `init` est absente. La fonction a les mêmes arguments que [`init`](#init).\n\nExample: Une fonction d'initialisation\n```html\n<ui-plugin path=\"users\" data-jc-init=\"common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = { onscope: path => console.log(path) };  // users\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### isolated:true\n\nType: `config`\n\nRend le path du scope indépendant du scope parent.\n\nL'effet est le même que celui du préfixe `!` du path.\n\nExample: Un scope isolé\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"settings\" config=\"isolated:true\"><span></span></ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAjoute le path du scope à l'élément comme classe CSS.\n\nExample: Le path comme classe\n```html\n<ui-plugin path=\"users\" config=\"aclass:true\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### class:classes\n\nType: `config`\n\nBascule des classes CSS sur l'élément après un délai.\n\nSépare plusieurs classes par un espace. La clé [`delay`](#delay) définit le délai.\n\nExample: Classes après le délai\n```html\n<ui-plugin path=\"users\" config=\"class:ready\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### delay:milliseconds\n\nType: `config`\n\nDéfinit le délai de la clé `class`, en millisecondes.\n\nLa valeur par défaut est `300`.\n\nExample: Un délai plus court\n```html\n<ui-plugin path=\"users\" config=\"class:ready;delay:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true\n</script>\n```\n\n### init:path\n\nType: `config`\n\nAppelle une fonction à la création du scope.\n\nLa fonction reçoit le path et l'élément du scope, et `this` est le [Scope](../scope/). Un `?` dans la valeur est remplacé par le path du scope.\n\nExample: Une fonction d'initialisation\n```html\n<ui-plugin path=\"users\" config=\"init:common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = {\n        onscope: function(path, element) {\n            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users\n        }\n    };\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### plugin=\"path\"\n\nType: `type`\n\nD'autres éléments peuvent créer un scope avec un attribut.\n\nUtilise `plugin`, `data-plugin`, `scope` ou `data-scope` sur n'importe quel élément. Les éléments `<ui-component>`, `<ui-bind>` et `<ui-import>` n'acceptent que l'attribut `plugin`. La valeur a les mêmes formes que `path`.\n\nExample: Un scope sur un div\n```html\n<div plugin=\"users\"><span></span></div>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-value","signature":"data-jc-value=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-init","signature":"data-jc-init=\"path\"","since":"","deprecated":false},{"type":"config","name":"isolated","signature":"isolated:true","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:classes","since":"","deprecated":false},{"type":"config","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"type","name":"Scope on another element","signature":"plugin=\"path\"","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammn63sr61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-plugin/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-plugin\n\n> Gli attributi e le chiavi di configurazione dell'elemento ui-plugin.\n\nL'elemento `<ui-plugin>` crea uno [Scope](../scope/) per il proprio contenuto e lo collega al [Plugin](../plugin/) con lo stesso path. Il concetto è spiegato in [Scope](../../guides/scopes/) e [Plugin](../../guides/plugins/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nImposta il path dello scope e seleziona il plugin.\n\nIl path di un elemento annidato viene aggiunto al path del suo scope padre. L'attributo accetta queste forme:\n\n| Valore | Significato |\n| --- | --- |\n| `users` | Lo scope `users`, oppure `parent.users` dentro un altro scope. |\n| `!users` | Uno scope isolato. Il suo path ignora lo scope padre. |\n| `?` | Uno scope con un path univoco generato. Un path vuoto o mancante fa lo stesso. |\n| `*` | Lo scope `common`, preso da `DEF.pathcommon`. |\n| `users template` | Lo scope `users` con un nuovo plugin creato da `PLUGIN('* template', fn)`. |\n| `users__config__default` | Il path, la configurazione e il valore predefinito in un solo attributo. |\n\nIl plugin di un elemento senza contenuto viene rimosso quando la libreria elimina gli oggetti inutilizzati.\n\nExample: Scope annidati\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"detail\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('users.detail', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail\n</script>\n```\n\nExample: Uno scope isolato\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"!settings\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\nExample: Un template di plugin riutilizzabile\n```html\n<ui-plugin path=\"orders counter\"><span></span></ui-plugin>\n<ui-plugin path=\"invoices counter\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('* counter', function(exports) {\n        console.log(exports.name);\n    });\n</script>\n```\n\nExample: Path, configurazione e valore predefinito insieme\n```html\n<ui-plugin path=\"users__aclass:1__{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users\n</script>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigura lo scope.\n\nIl valore è un elenco di coppie `key:value`. Le chiavi sono elencate in questa pagina e sono tutte disponibili in [`scope.config`](../scope/#config).\n\nExample: Leggere la configurazione\n```html\n<ui-plugin path=\"users\" config=\"limit:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nImposta il valore iniziale del path dello scope.\n\nL'attributo contiene un'espressione JavaScript. Il metodo [`default()`](../scope/#default) dello scope ripristina il valore.\n\nExample: Un modello iniziale\n```html\n<ui-plugin path=\"users\" default=\"{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users')), 500);  // {\"page\":1}\n</script>\n```\n\n### data-jc-value=\"expression\"\n\nType: `property`\n\nImposta il valore iniziale del path dello scope.\n\nViene usato quando manca l'attributo `default`.\n\nExample: Un modello iniziale\n```html\n<ui-plugin path=\"users\" data-jc-value=\"{ page: 2 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page')), 500);  // 2\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nAttiva o disattiva le classi CSS sull'elemento.\n\nViene usato quando manca la chiave di configurazione `class`.\n\nExample: Una classe dopo l'inizializzazione\n```html\n<ui-plugin path=\"users\" data-jc-class=\"ready\" config=\"delay:10\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### data-jc-init=\"path\"\n\nType: `property`\n\nChiama una funzione quando viene creato lo scope.\n\nViene usato quando manca la chiave di configurazione `init`. La funzione ha gli stessi argomenti di [`init`](#init).\n\nExample: Una funzione di inizializzazione\n```html\n<ui-plugin path=\"users\" data-jc-init=\"common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = { onscope: path => console.log(path) };  // users\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### isolated:true\n\nType: `config`\n\nRende il path dello scope indipendente dallo scope padre.\n\nHa lo stesso effetto del prefisso `!` del path.\n\nExample: Uno scope isolato\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"settings\" config=\"isolated:true\"><span></span></ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAggiunge il path dello scope all'elemento come classe CSS.\n\nExample: Il path come classe\n```html\n<ui-plugin path=\"users\" config=\"aclass:true\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### class:classes\n\nType: `config`\n\nAttiva o disattiva le classi CSS sull'elemento dopo un ritardo.\n\nSepara più classi con uno spazio. La chiave [`delay`](#delay) imposta il ritardo.\n\nExample: Classi dopo il ritardo\n```html\n<ui-plugin path=\"users\" config=\"class:ready\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### delay:milliseconds\n\nType: `config`\n\nImposta il ritardo della chiave `class` in millisecondi.\n\nIl valore predefinito è `300`.\n\nExample: Un ritardo più breve\n```html\n<ui-plugin path=\"users\" config=\"class:ready;delay:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true\n</script>\n```\n\n### init:path\n\nType: `config`\n\nChiama una funzione quando viene creato lo scope.\n\nLa funzione riceve il path e l'elemento dello scope, e `this` è lo [Scope](../scope/). Un `?` nel valore viene sostituito con il path dello scope.\n\nExample: Una funzione di inizializzazione\n```html\n<ui-plugin path=\"users\" config=\"init:common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = {\n        onscope: function(path, element) {\n            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users\n        }\n    };\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### plugin=\"path\"\n\nType: `type`\n\nAltri elementi possono creare uno scope con un attributo.\n\nUsa `plugin`, `data-plugin`, `scope` o `data-scope` su qualsiasi elemento. Gli elementi `<ui-component>`, `<ui-bind>` e `<ui-import>` accettano solo l'attributo `plugin`. Il valore ha le stesse forme di `path`.\n\nExample: Uno scope su un div\n```html\n<div plugin=\"users\"><span></span></div>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-value","signature":"data-jc-value=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-init","signature":"data-jc-init=\"path\"","since":"","deprecated":false},{"type":"config","name":"isolated","signature":"isolated:true","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:classes","since":"","deprecated":false},{"type":"config","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"type","name":"Scope on another element","signature":"plugin=\"path\"","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammn63sr61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"ui-plugin","summary":"Atribúty a konfiguračné kľúče elementu ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-plugin\n\n> Atribúty a konfiguračné kľúče elementu ui-plugin.\n\nElement `<ui-plugin>` vytvorí pre svoj obsah [Scope](../scope/) a prepojí ho s [Pluginom](../plugin/) s rovnakou path. Koncept vysvetľujú časti [Scopy](../../guides/scopes/) a [Pluginy](../../guides/plugins/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nNastaví path scopu a vyberie plugin.\n\nPath vnoreného elementu sa pripojí k path jeho nadradeného scopu. Atribút prijíma tieto tvary:\n\n| Hodnota | Význam |\n| --- | --- |\n| `users` | Scope `users`, alebo `parent.users` vnútri iného scopu. |\n| `!users` | Izolovaný scope. Jeho path ignoruje nadradený scope. |\n| `?` | Scope s vygenerovanou jedinečnou path. Rovnako funguje prázdna alebo chýbajúca path. |\n| `*` | Scope `common` prevzatý z `DEF.pathcommon`. |\n| `users template` | Scope `users` s novým pluginom vytvoreným z `PLUGIN('* template', fn)`. |\n| `users__config__default` | Path, konfigurácia a predvolená hodnota v jednom atribúte. |\n\nPlugin elementu bez obsahu sa odstráni, keď knižnica čistí nepoužívané objekty.\n\nExample: Vnorené scopy\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"detail\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('users.detail', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail\n</script>\n```\n\nExample: Izolovaný scope\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"!settings\">\n        <span></span>\n    </ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\nExample: Opakovane použiteľná šablóna pluginu\n```html\n<ui-plugin path=\"orders counter\"><span></span></ui-plugin>\n<ui-plugin path=\"invoices counter\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('* counter', function(exports) {\n        console.log(exports.name);\n    });\n</script>\n```\n\nExample: Path, konfigurácia a predvolená hodnota spolu\n```html\n<ui-plugin path=\"users__aclass:1__{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users\n</script>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nKonfiguruje scope.\n\nHodnota je zoznam dvojíc `key:value`. Kľúče sú uvedené na tejto stránke a všetky sú dostupné v [`scope.config`](../scope/#config).\n\nExample: Čítanie konfigurácie\n```html\n<ui-plugin path=\"users\" config=\"limit:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nNastaví počiatočnú hodnotu path scopu.\n\nAtribút obsahuje výraz JavaScriptu. Metóda scopu [`default()`](../scope/#default) hodnotu obnoví.\n\nExample: Počiatočný model\n```html\n<ui-plugin path=\"users\" default=\"{ page: 1 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users')), 500);  // {\"page\":1}\n</script>\n```\n\n### data-jc-value=\"expression\"\n\nType: `property`\n\nNastaví počiatočnú hodnotu path scopu.\n\nPoužije sa, keď chýba atribút `default`.\n\nExample: Počiatočný model\n```html\n<ui-plugin path=\"users\" data-jc-value=\"{ page: 2 }\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log(GET('users.page')), 500);  // 2\n</script>\n```\n\n### data-jc-class=\"classes\"\n\nType: `property`\n\nPrepína triedy CSS na elemente.\n\nPoužije sa, keď chýba konfiguračný kľúč `class`.\n\nExample: Trieda po inicializácii\n```html\n<ui-plugin path=\"users\" data-jc-class=\"ready\" config=\"delay:10\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### data-jc-init=\"path\"\n\nType: `property`\n\nZavolá funkciu pri vytvorení scopu.\n\nPoužije sa, keď chýba konfiguračný kľúč `init`. Funkcia má rovnaké argumenty ako [`init`](#init).\n\nExample: Inicializačná funkcia\n```html\n<ui-plugin path=\"users\" data-jc-init=\"common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = { onscope: path => console.log(path) };  // users\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### isolated:true\n\nType: `config`\n\nUrobí path scopu nezávislou od nadradeného scopu.\n\nMá rovnaký účinok ako predpona `!` v path.\n\nExample: Izolovaný scope\n```html\n<ui-plugin path=\"users\">\n    <ui-plugin path=\"settings\" config=\"isolated:true\"><span></span></ui-plugin>\n</ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    PLUGIN('settings', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // settings\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nPridá path scopu k elementu ako triedu CSS.\n\nExample: Path ako trieda\n```html\n<ui-plugin path=\"users\" config=\"aclass:true\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### class:classes\n\nType: `config`\n\nPo oneskorení prepne triedy CSS na elemente.\n\nViacero tried oddeľ medzerou. Oneskorenie nastavuje kľúč [`delay`](#delay).\n\nExample: Triedy po oneskorení\n```html\n<ui-plugin path=\"users\" config=\"class:ready\"><span></span></ui-plugin>\n<script>PLUGIN('users', function(exports) {});</script>\n```\n\n### delay:milliseconds\n\nType: `config`\n\nNastaví oneskorenie kľúča `class` v milisekundách.\n\nPredvolená hodnota je `300`.\n\nExample: Kratšie oneskorenie\n```html\n<ui-plugin path=\"users\" config=\"class:ready;delay:10\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true\n</script>\n```\n\n### init:path\n\nType: `config`\n\nZavolá funkciu pri vytvorení scopu.\n\nFunkcia dostane path a element scopu a `this` je [Scope](../scope/). Znak `?` v hodnote sa nahradí za path scopu.\n\nExample: Inicializačná funkcia\n```html\n<ui-plugin path=\"users\" config=\"init:common.onscope\"><span></span></ui-plugin>\n\n<script>\n    window.common = {\n        onscope: function(path, element) {\n            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users\n        }\n    };\n    PLUGIN('users', function(exports) {});\n</script>\n```\n\n### plugin=\"path\"\n\nType: `type`\n\nScope môžu vytvoriť atribútom aj iné elementy.\n\nNa ľubovoľnom elemente použi `plugin`, `data-plugin`, `scope` alebo `data-scope`. Elementy `<ui-component>`, `<ui-bind>` a `<ui-import>` prijímajú iba atribút `plugin`. Hodnota má rovnaké tvary ako `path`.\n\nExample: Scope na elemente div\n```html\n<div plugin=\"users\"><span></span></div>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('span').scope().path), 500);  // users\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-value","signature":"data-jc-value=\"expression\"","since":"","deprecated":false},{"type":"property","name":"data-jc-class","signature":"data-jc-class=\"classes\"","since":"","deprecated":false},{"type":"property","name":"data-jc-init","signature":"data-jc-init=\"path\"","since":"","deprecated":false},{"type":"config","name":"isolated","signature":"isolated:true","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:classes","since":"","deprecated":false},{"type":"config","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"type","name":"Scope on another element","signature":"plugin=\"path\"","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammh68Qj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Plugin","summary":"The properties, delegates and methods of a plugin instance.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Plugin\n\n> The properties, delegates and methods of a plugin instance.\n\nA plugin instance is the object passed to the declaration of `PLUGIN()`. It holds the logic of a part of the page and works with the data under its own path. [Plugins](../../guides/plugins/) explains the concept, and [ui-plugin](../ui-plugin/) describes the element. In the examples, `plugin` is the instance of the `users` plugin.\n\n## API\n\n### exports.destroy = function()\n\nType: `delegate`\n\nRuns when the plugin is removed.\n\nExample: Releasing resources\n```html\n<ui-plugin path=\"users\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => PLUGINS.users.remove(), 500);\n</script>\n```\n\n### plugin.name\n\nType: `property`\n\nThe path of the plugin.\n\nExample: Reading name\n```js\nconsole.log(plugin.name);  // users\n```\n\n### plugin.id\n\nType: `property`\n\nThe identifier of the plugin.\n\nIt is the name with the `plug` prefix.\n\nExample: Reading id\n```js\nconsole.log(plugin.id);  // plugusers\n```\n\n### plugin.element\n\nType: `property`\n\nThe element of the plugin as a jQuery object.\n\nIt is the element of the scope. A plugin without a scope uses `body`.\n\nExample: Reading element\n```js\nconsole.log(plugin.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### plugin.model\n\nType: `property`\n\nReads or replaces the whole model of the plugin.\n\nReading a missing model returns an empty object.\n\nExample: Reading model\n```js\nplugin.model = { name: 'Peter' };\nconsole.log(plugin.model.name);  // Peter\n```\n\n### plugin.data\n\nType: `property`\n\nReads or replaces the whole model of the plugin.\n\nIt is the same as `model`.\n\nExample: Reading data\n```js\nplugin.data = { name: 'Anna' };\nconsole.log(plugin.data.name);  // Anna\n```\n\n### plugin.form\n\nType: `property`\n\nReturns the model and resets the state of its components.\n\nReading the property clears the touched and modified state of the components bound to the model.\n\nExample: Reading form\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.form);  // {\"name\":\"Peter\"}\n```\n\n### plugin.modified\n\nType: `property`\n\nReturns the fields changed by components.\n\nReading the property clears the touched and modified state of the components bound to the model.\n\nExample: Reading modified\n```js\nFIND('field').modify('Peter');\nconsole.log(plugin.modified);  // {\"name\":\"Peter\"}\n```\n\n### plugin.parent\n\nType: `property`\n\nThe plugin of the parent scope.\n\nThe value is `null` when there is no parent scope.\n\nExample: Reading parent\n```js\nconsole.log(PLUGINS['users.detail'].parent.name);  // users\n```\n\n### plugin.caller\n\nType: `property`\n\nThe plugin that was active when this plugin was created.\n\nThe value is `null` when no plugin was active.\n\nExample: Reading caller\n```js\nconsole.log(plugin.caller);  // null\n```\n\n### plugin.set([path], value, [type])\n\nType: `method`\n\nWrites a value to a path of the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `value` | `Object` | yes |  | The value. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nWith one argument, the value replaces the whole model.\n\nExample: Using set()\n```js\nplugin.set('name', 'Peter');\nconsole.log(GET('users.name'));  // Peter\n```\n\n### plugin.get([path])\n\nType: `method`\n\nReads a path of the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n\nReturns: `Object` The value.\n\nWithout an argument, the method returns the whole model.\n\nExample: Using get()\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.get('name'));  // Peter\n```\n\n### plugin.nul(path, [type])\n\nType: `method`\n\nWrites `null` to a path of the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nExample: Using nul()\n```js\nplugin.set('name', 'Peter');\nplugin.nul('name');\nconsole.log(plugin.get('name'));  // null\n```\n\n### plugin.push([path], value, [type])\n\nType: `method`\n\nAdds an item to an array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `value` | `Object` | yes |  | The item. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nWith one argument, the item is added to the model itself.\n\nExample: Using push()\n```js\nplugin.push('items', 'A');\nplugin.push('items', 'B');\nconsole.log(plugin.get('items'));  // [\"A\",\"B\"]\n```\n\n### plugin.extend([path], value, [type])\n\nType: `method`\n\nMerges an object into a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `value` | `Object` | yes |  | The fields. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nWith one argument, the object is merged into the model itself.\n\nExample: Using extend()\n```js\nplugin.extend('user', { name: 'Peter' });\nplugin.extend('user', { age: 30 });\nconsole.log(plugin.get('user'));  // {\"name\":\"Peter\",\"age\":30}\n```\n\n### plugin.inc([path], value, [type])\n\nType: `method`\n\nIncreases a number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `value` | `Number` | yes |  | The increment. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nWith one argument, the model itself is increased.\n\nExample: Using inc()\n```js\nplugin.inc('count', 2);\nplugin.inc('count', 3);\nconsole.log(plugin.get('count'));  // 5\n```\n\n### plugin.toggle(path, [type])\n\nType: `method`\n\nInverts a boolean value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nExample: Using toggle()\n```js\nplugin.toggle('open');\nconsole.log(plugin.get('open'));  // true\n```\n\n### plugin.upd([path], [type])\n\nType: `method`\n\nNotifies the listeners of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n| `type` | `Number` | no |  | The type of the change. A value of `10` or more is a delay in milliseconds. |\n\nReturns: `Plugin` The plugin.\n\nExample: Using upd()\n```js\nplugin.watch('name', value => console.log(value));  // Peter\nwindow.users.name = 'Peter';\nplugin.upd('name');\n```\n\n### plugin.reset([path])\n\nType: `method`\n\nClears the state of components bound to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The relative path. |\n\nReturns: `Plugin` The plugin.\n\nThe touched and modified state is cleared. The value does not change.\n\nExample: Using reset()\n```js\nvar com = FIND('field');\ncom.modify('Peter');\nplugin.reset();\nconsole.log(com.config.touched, GET('users.name'));  // false Peter\n```\n\n### plugin.watch(path, callback, [init])\n\nType: `method`\n\nWatches a path of the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n| `callback` | `Function` | yes |  | The function that receives the changes. |\n| `init` | `Boolean` | no |  | `true` calls the callback immediately. |\n\nReturns: `Plugin` The plugin.\n\nThe callback receives `value`, `path` and `type`. Several paths are separated by a comma or ` + `.\n\nExample: Using watch()\n```js\nplugin.watch('name', (value, path) => console.log(value, path));  // Peter users.name\nplugin.set('name', 'Peter');\n```\n\n### plugin.on(name, callback)\n\nType: `method`\n\nListens for a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | yes |  | The listener. |\n\nReturns: `Plugin` The plugin.\n\nThe scope of the plugin is active when the listener is registered.\n\nExample: Using on()\n```js\nplugin.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### plugin.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nCalls a method of the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the method. |\n\nReturns: `Plugin` The plugin.\n\nAn unknown method is ignored. The method accepts up to five arguments.\n\nExample: Using exec()\n```js\nplugin.hello = name => console.log('Hello ' + name);  // Hello Peter\nplugin.exec('hello', 'Peter');\n```\n\n### plugin.makepath([path])\n\nType: `method`\n\nResolves a path relative to the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The path. |\n\nReturns: `String` The resolved path.\n\nThe forms are:\n\n| Argument | Result for the `users` plugin |\n| --- | --- |\n| omitted | `users` |\n| `name` or `?.name` | `users.name` |\n| `*name` | `common.name` |\n| `@flag` | `users @flag` |\n| `^name` | `^users.name` |\n| `+name` | `+users.name` |\n| `\\|name` | `users\\|name` |\n| `%name` | `%name` |\n| `#name` | `#name` |\n\nExample: Using makepath()\n```js\nconsole.log(plugin.makepath('name'));  // users.name\n```\n\n### plugin.format([text])\n\nType: `method`\n\nInserts the name of the plugin into a text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no |  | The text. |\n\nReturns: `String` The result.\n\nThe name replaces `{0}`. A text without a placeholder receives the name at the end.\n\nExample: Using format()\n```js\nconsole.log(plugin.format('/api/{0}/'));  // /api/users/\n```\n\n### plugin.scope([path])\n\nType: `method`\n\nMakes the plugin the active scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The scope to activate. |\n\nReturns: `Plugin` The plugin.\n\nOther functions then resolve `?` to this plugin. Another path can be passed, and `null` clears the active scope. The method is also available as `plugin()`.\n\nExample: Using scope()\n```js\nplugin.scope();\nconsole.log(M.scope());  // users\n```\n\n### plugin.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 URL. |\n| `data` | `Object` | no |  | The data of the request. |\n| `callback` | `Function|String` | no |  | A function or a relative path. |\n\nReturns: `Plugin|Promise` The plugin, or a `Promise` without a callback.\n\nThe method calls `AJAX()`. A text callback is a path relative to the plugin, which receives the response. Without `data` and a callback, the method returns a `Promise`.\n\nExample: Using ajax()\n```js\nplugin.ajax('GET /api/users/', 'response');\nconsole.log(plugin.get('response.url'));  // GET /api/users/\n```\n\n### plugin.api(url, [data], [callback])\n\nType: `method`\n\nCalls an API endpoint.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The name of the endpoint. |\n| `data` | `Object` | no |  | The data of the request. |\n| `callback` | `Function|String` | no |  | A function or a relative path. |\n\nReturns: `Plugin|Promise` The plugin, or a `Promise` without a callback.\n\nThe method calls `API()` and accepts the same callback forms as [`ajax()`](#ajax).\n\nExample: Using api()\n```js\nplugin.api('users_read', function(response) {\n    console.log(response);  // users_read\n});\n```\n\n### plugin.dapi(name, [data], [callback])\n\nType: `method`\n\nCalls a DAPI endpoint.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the endpoint. |\n| `data` | `Object` | no |  | The data of the request. |\n| `callback` | `Function|String` | no |  | A function or a relative path. |\n\nReturns: `Plugin|Promise` The plugin, or a `Promise` without a callback.\n\nThe method calls `DAPI()` and accepts the same callback forms as [`ajax()`](#ajax).\n\nExample: Using dapi()\n```js\nplugin.dapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.tapi(name, [data], [callback])\n\nType: `method`\n\nCalls a TAPI endpoint.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the endpoint. |\n| `data` | `Object` | no |  | The data of the request. |\n| `callback` | `Function|String` | no |  | A function or a relative path. |\n\nReturns: `Plugin|Promise` The plugin, or a `Promise` without a callback.\n\nThe method calls `TAPI()` and accepts the same callback forms as [`ajax()`](#ajax).\n\nExample: Using tapi()\n```js\nplugin.tapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.upload(url, data, [callback])\n\nType: `method`\n\nUploads data.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL. |\n| `data` | `FormData|Object` | yes |  | The data. |\n| `callback` | `Function|String` | no |  | A function or a relative path. |\n\nReturns: `Plugin|Promise` The plugin, or a `Promise` without a callback.\n\nThe method calls `UPLOAD()` and accepts the same callback forms as [`ajax()`](#ajax).\n\nExample: Using upload()\n```js\nplugin.upload('/upload/', new FormData(), function(response) {\n    console.log(response);  // /upload/\n});\n```\n\n### plugin.remove()\n\nType: `method`\n\nRemoves the plugin.\n\nReturns: `Boolean` Always `true`.\n\nThe `destroy` delegate runs, and the events and watchers registered during the declaration are removed. The element stays in the page.\n\nExample: Using remove()\n```js\nconsole.log(plugin.remove(), PLUGINS.users === undefined);  // true true\n```\n","entries":[{"type":"delegate","name":"destroy","signature":"exports.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"plugin.name","since":"","deprecated":false},{"type":"property","name":"id","signature":"plugin.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"plugin.element","since":"","deprecated":false},{"type":"property","name":"model","signature":"plugin.model","since":"","deprecated":false},{"type":"property","name":"data","signature":"plugin.data","since":"","deprecated":false},{"type":"property","name":"form","signature":"plugin.form","since":"","deprecated":false},{"type":"property","name":"modified","signature":"plugin.modified","since":"","deprecated":false},{"type":"property","name":"parent","signature":"plugin.parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"plugin.caller","since":"","deprecated":false},{"type":"method","name":"set()","signature":"plugin.set([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"plugin.get([path])","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"plugin.nul(path, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"plugin.push([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"plugin.extend([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"plugin.inc([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"plugin.toggle(path, [type])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"plugin.upd([path], [type])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"plugin.reset([path])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"plugin.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"plugin.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"plugin.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"plugin.makepath([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"plugin.format([text])","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"plugin.scope([path])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"plugin.ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"api()","signature":"plugin.api(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"dapi()","signature":"plugin.dapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"plugin.tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"upload()","signature":"plugin.upload(url, data, [callback])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"plugin.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammh68Qj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Plugin","summary":"Die Eigenschaften, Delegates und Methoden einer Plugin-Instanz.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Plugin\n\n> Die Eigenschaften, Delegates und Methoden einer Plugin-Instanz.\n\nEine Plugin-Instanz ist das Objekt, das an die Deklaration von `PLUGIN()` übergeben wird. Die Instanz enthält die Logik eines Seitenbereichs und arbeitet mit den Daten unter ihrem eigenen Path. [Plugins](../../guides/plugins/) erklärt das Konzept und [ui-plugin](../ui-plugin/) beschreibt das Element. In den Beispielen ist `plugin` die Instanz des Plugins `users`.\n\n## API\n\n### exports.destroy = function()\n\nType: `delegate`\n\nWird ausgeführt, wenn das Plugin entfernt wird.\n\nExample: Ressourcen freigeben\n```html\n<ui-plugin path=\"users\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => PLUGINS.users.remove(), 500);\n</script>\n```\n\n### plugin.name\n\nType: `property`\n\nDer Path des Plugins.\n\nExample: name lesen\n```js\nconsole.log(plugin.name);  // users\n```\n\n### plugin.id\n\nType: `property`\n\nDie Kennung des Plugins.\n\nDas ist der Name mit dem Präfix `plug`.\n\nExample: id lesen\n```js\nconsole.log(plugin.id);  // plugusers\n```\n\n### plugin.element\n\nType: `property`\n\nDas Element des Plugins als jQuery-Objekt.\n\nDas ist das Element des Scopes. Ein Plugin ohne Scope verwendet `body`.\n\nExample: element lesen\n```js\nconsole.log(plugin.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### plugin.model\n\nType: `property`\n\nLiest oder ersetzt das gesamte Modell des Plugins.\n\nDas Lesen eines fehlenden Modells gibt ein leeres Objekt zurück.\n\nExample: model lesen\n```js\nplugin.model = { name: 'Peter' };\nconsole.log(plugin.model.name);  // Peter\n```\n\n### plugin.data\n\nType: `property`\n\nLiest oder ersetzt das gesamte Modell des Plugins.\n\nDas ist dasselbe wie `model`.\n\nExample: data lesen\n```js\nplugin.data = { name: 'Anna' };\nconsole.log(plugin.data.name);  // Anna\n```\n\n### plugin.form\n\nType: `property`\n\nGibt das Modell zurück und setzt den Zustand seiner Komponenten zurück.\n\nDas Lesen der Eigenschaft löscht den Zustand „berührt“ und „geändert“ der an das Modell gebundenen Komponenten.\n\nExample: form lesen\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.form);  // {\"name\":\"Peter\"}\n```\n\n### plugin.modified\n\nType: `property`\n\nGibt die von Komponenten geänderten Felder zurück.\n\nDas Lesen der Eigenschaft löscht den Zustand „berührt“ und „geändert“ der an das Modell gebundenen Komponenten.\n\nExample: modified lesen\n```js\nFIND('field').modify('Peter');\nconsole.log(plugin.modified);  // {\"name\":\"Peter\"}\n```\n\n### plugin.parent\n\nType: `property`\n\nDas Plugin des übergeordneten Scopes.\n\nDer Wert ist `null`, wenn es keinen übergeordneten Scope gibt.\n\nExample: parent lesen\n```js\nconsole.log(PLUGINS['users.detail'].parent.name);  // users\n```\n\n### plugin.caller\n\nType: `property`\n\nDas Plugin, das aktiv war, als dieses Plugin erstellt wurde.\n\nDer Wert ist `null`, wenn kein Plugin aktiv war.\n\nExample: caller lesen\n```js\nconsole.log(plugin.caller);  // null\n```\n\n### plugin.set([path], value, [type])\n\nType: `method`\n\nSchreibt einen Wert in einen Path des Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nMit einem Argument ersetzt der Wert das gesamte Modell.\n\nExample: set() verwenden\n```js\nplugin.set('name', 'Peter');\nconsole.log(GET('users.name'));  // Peter\n```\n\n### plugin.get([path])\n\nType: `method`\n\nLiest einen Path des Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n\nReturns: `Object` Der Wert.\n\nOhne Argument gibt die Methode das gesamte Modell zurück.\n\nExample: get() verwenden\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.get('name'));  // Peter\n```\n\n### plugin.nul(path, [type])\n\nType: `method`\n\nSchreibt `null` in einen Path des Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nExample: nul() verwenden\n```js\nplugin.set('name', 'Peter');\nplugin.nul('name');\nconsole.log(plugin.get('name'));  // null\n```\n\n### plugin.push([path], value, [type])\n\nType: `method`\n\nFügt einem Array einen Eintrag hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `value` | `Object` | yes |  | Das Element. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nMit einem Argument wird der Eintrag dem Modell selbst hinzugefügt.\n\nExample: push() verwenden\n```js\nplugin.push('items', 'A');\nplugin.push('items', 'B');\nconsole.log(plugin.get('items'));  // [\"A\",\"B\"]\n```\n\n### plugin.extend([path], value, [type])\n\nType: `method`\n\nFührt ein Objekt mit einem Path zusammen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `value` | `Object` | yes |  | Die Felder. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nMit einem Argument wird das Objekt mit dem Modell selbst zusammengeführt.\n\nExample: extend() verwenden\n```js\nplugin.extend('user', { name: 'Peter' });\nplugin.extend('user', { age: 30 });\nconsole.log(plugin.get('user'));  // {\"name\":\"Peter\",\"age\":30}\n```\n\n### plugin.inc([path], value, [type])\n\nType: `method`\n\nErhöht eine Zahl.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `value` | `Number` | yes |  | Die Schrittweite. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nMit einem Argument wird das Modell selbst erhöht.\n\nExample: inc() verwenden\n```js\nplugin.inc('count', 2);\nplugin.inc('count', 3);\nconsole.log(plugin.get('count'));  // 5\n```\n\n### plugin.toggle(path, [type])\n\nType: `method`\n\nKehrt einen booleschen Wert um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nExample: toggle() verwenden\n```js\nplugin.toggle('open');\nconsole.log(plugin.get('open'));  // true\n```\n\n### plugin.upd([path], [type])\n\nType: `method`\n\nBenachrichtigt die Listener eines Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n| `type` | `Number` | no |  | Der Typ der Änderung. Ein Wert ab `10` ist eine Verzögerung in Millisekunden. |\n\nReturns: `Plugin` Das Plugin.\n\nExample: upd() verwenden\n```js\nplugin.watch('name', value => console.log(value));  // Peter\nwindow.users.name = 'Peter';\nplugin.upd('name');\n```\n\n### plugin.reset([path])\n\nType: `method`\n\nLöscht den Zustand der an einen Path gebundenen Komponenten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der relative Path. |\n\nReturns: `Plugin` Das Plugin.\n\nDer Zustand „berührt“ und „geändert“ wird gelöscht. Der Wert ändert sich nicht.\n\nExample: reset() verwenden\n```js\nvar com = FIND('field');\ncom.modify('Peter');\nplugin.reset();\nconsole.log(com.config.touched, GET('users.name'));  // false Peter\n```\n\n### plugin.watch(path, callback, [init])\n\nType: `method`\n\nÜberwacht einen Path des Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n| `callback` | `Function` | yes |  | Die Funktion, die die Änderungen erhält. |\n| `init` | `Boolean` | no |  | `true` ruft den Callback sofort auf. |\n\nReturns: `Plugin` Das Plugin.\n\nDer Callback erhält `value`, `path` und `type`. Mehrere Paths werden durch ein Komma oder ` + ` getrennt.\n\nExample: watch() verwenden\n```js\nplugin.watch('name', (value, path) => console.log(value, path));  // Peter users.name\nplugin.set('name', 'Peter');\n```\n\n### plugin.on(name, callback)\n\nType: `method`\n\nLauscht auf ein globales Event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | yes |  | Der Listener. |\n\nReturns: `Plugin` Das Plugin.\n\nDer Scope des Plugins ist aktiv, wenn der Listener registriert wird.\n\nExample: on() verwenden\n```js\nplugin.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### plugin.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuft eine Methode des Plugins auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Methode. |\n\nReturns: `Plugin` Das Plugin.\n\nEine unbekannte Methode wird ignoriert. Die Methode akzeptiert bis zu fünf Argumente.\n\nExample: exec() verwenden\n```js\nplugin.hello = name => console.log('Hello ' + name);  // Hello Peter\nplugin.exec('hello', 'Peter');\n```\n\n### plugin.makepath([path])\n\nType: `method`\n\nLöst einen Path relativ zum Plugin auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der Path. |\n\nReturns: `String` Der aufgelöste Path.\n\nDie Formen sind:\n\n| Argument | Ergebnis für das Plugin `users` |\n| --- | --- |\n| weggelassen | `users` |\n| `name` oder `?.name` | `users.name` |\n| `*name` | `common.name` |\n| `@flag` | `users @flag` |\n| `^name` | `^users.name` |\n| `+name` | `+users.name` |\n| `\\|name` | `users\\|name` |\n| `%name` | `%name` |\n| `#name` | `#name` |\n\nExample: makepath() verwenden\n```js\nconsole.log(plugin.makepath('name'));  // users.name\n```\n\n### plugin.format([text])\n\nType: `method`\n\nFügt den Namen des Plugins in einen Text ein.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no |  | Der Text. |\n\nReturns: `String` Das Ergebnis.\n\nDer Name ersetzt `{0}`. Ein Text ohne Platzhalter erhält den Namen am Ende.\n\nExample: format() verwenden\n```js\nconsole.log(plugin.format('/api/{0}/'));  // /api/users/\n```\n\n### plugin.scope([path])\n\nType: `method`\n\nMacht das Plugin zum aktiven Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der zu aktivierende Scope. |\n\nReturns: `Plugin` Das Plugin.\n\nAndere Funktionen lösen `?` dann auf dieses Plugin auf. Du kannst einen anderen Path übergeben, und `null` löscht den aktiven Scope. Die Methode steht auch als `plugin()` zur Verfügung.\n\nExample: scope() verwenden\n```js\nplugin.scope();\nconsole.log(M.scope());  // users\n```\n\n### plugin.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 URL. |\n| `data` | `Object` | no |  | Die Daten der Anfrage. |\n| `callback` | `Function|String` | no |  | Eine Funktion oder ein relativer Path. |\n\nReturns: `Plugin|Promise` Das Plugin oder, ohne Callback, ein `Promise`.\n\nDie Methode ruft `AJAX()` auf. Ein Text als Callback ist ein Path relativ zum Plugin, der die Antwort erhält. Ohne `data` und Callback gibt die Methode ein `Promise` zurück.\n\nExample: ajax() verwenden\n```js\nplugin.ajax('GET /api/users/', 'response');\nconsole.log(plugin.get('response.url'));  // GET /api/users/\n```\n\n### plugin.api(url, [data], [callback])\n\nType: `method`\n\nRuft einen API-Endpunkt auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Der Name des Endpunkts. |\n| `data` | `Object` | no |  | Die Daten der Anfrage. |\n| `callback` | `Function|String` | no |  | Eine Funktion oder ein relativer Path. |\n\nReturns: `Plugin|Promise` Das Plugin oder, ohne Callback, ein `Promise`.\n\nDie Methode ruft `API()` auf und akzeptiert dieselben Callback-Formen wie [`ajax()`](#ajax).\n\nExample: api() verwenden\n```js\nplugin.api('users_read', function(response) {\n    console.log(response);  // users_read\n});\n```\n\n### plugin.dapi(name, [data], [callback])\n\nType: `method`\n\nRuft einen DAPI-Endpunkt auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Endpunkts. |\n| `data` | `Object` | no |  | Die Daten der Anfrage. |\n| `callback` | `Function|String` | no |  | Eine Funktion oder ein relativer Path. |\n\nReturns: `Plugin|Promise` Das Plugin oder, ohne Callback, ein `Promise`.\n\nDie Methode ruft `DAPI()` auf und akzeptiert dieselben Callback-Formen wie [`ajax()`](#ajax).\n\nExample: dapi() verwenden\n```js\nplugin.dapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.tapi(name, [data], [callback])\n\nType: `method`\n\nRuft einen TAPI-Endpunkt auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Endpunkts. |\n| `data` | `Object` | no |  | Die Daten der Anfrage. |\n| `callback` | `Function|String` | no |  | Eine Funktion oder ein relativer Path. |\n\nReturns: `Plugin|Promise` Das Plugin oder, ohne Callback, ein `Promise`.\n\nDie Methode ruft `TAPI()` auf und akzeptiert dieselben Callback-Formen wie [`ajax()`](#ajax).\n\nExample: tapi() verwenden\n```js\nplugin.tapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.upload(url, data, [callback])\n\nType: `method`\n\nLädt Daten hoch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL. |\n| `data` | `FormData|Object` | yes |  | Die Daten. |\n| `callback` | `Function|String` | no |  | Eine Funktion oder ein relativer Path. |\n\nReturns: `Plugin|Promise` Das Plugin oder, ohne Callback, ein `Promise`.\n\nDie Methode ruft `UPLOAD()` auf und akzeptiert dieselben Callback-Formen wie [`ajax()`](#ajax).\n\nExample: upload() verwenden\n```js\nplugin.upload('/upload/', new FormData(), function(response) {\n    console.log(response);  // /upload/\n});\n```\n\n### plugin.remove()\n\nType: `method`\n\nEntfernt das Plugin.\n\nReturns: `Boolean` Immer `true`.\n\nDer Delegate `destroy` läuft, und die während der Deklaration registrierten Events und Watcher werden entfernt. Das Element bleibt auf der Seite.\n\nExample: remove() verwenden\n```js\nconsole.log(plugin.remove(), PLUGINS.users === undefined);  // true true\n```\n","entries":[{"type":"delegate","name":"destroy","signature":"exports.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"plugin.name","since":"","deprecated":false},{"type":"property","name":"id","signature":"plugin.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"plugin.element","since":"","deprecated":false},{"type":"property","name":"model","signature":"plugin.model","since":"","deprecated":false},{"type":"property","name":"data","signature":"plugin.data","since":"","deprecated":false},{"type":"property","name":"form","signature":"plugin.form","since":"","deprecated":false},{"type":"property","name":"modified","signature":"plugin.modified","since":"","deprecated":false},{"type":"property","name":"parent","signature":"plugin.parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"plugin.caller","since":"","deprecated":false},{"type":"method","name":"set()","signature":"plugin.set([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"plugin.get([path])","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"plugin.nul(path, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"plugin.push([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"plugin.extend([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"plugin.inc([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"plugin.toggle(path, [type])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"plugin.upd([path], [type])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"plugin.reset([path])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"plugin.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"plugin.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"plugin.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"plugin.makepath([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"plugin.format([text])","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"plugin.scope([path])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"plugin.ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"api()","signature":"plugin.api(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"dapi()","signature":"plugin.dapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"plugin.tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"upload()","signature":"plugin.upload(url, data, [callback])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"plugin.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammh68Qj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Plugin","summary":"Las propiedades, los delegates y los métodos de una instancia de plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Plugin\n\n> Las propiedades, los delegates y los métodos de una instancia de plugin.\n\nUna instancia de plugin es el objeto que se pasa a la declaración de `PLUGIN()`. Contiene la lógica de una parte de la página y trabaja con los datos de su propio path. En [Plugins](../../guides/plugins/) se explica el concepto, y en [ui-plugin](../ui-plugin/) se describe el elemento. En los ejemplos, `plugin` es la instancia del plugin `users`.\n\n## API\n\n### exports.destroy = function()\n\nType: `delegate`\n\nSe ejecuta cuando se elimina el plugin.\n\nExample: Liberar recursos\n```html\n<ui-plugin path=\"users\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => PLUGINS.users.remove(), 500);\n</script>\n```\n\n### plugin.name\n\nType: `property`\n\nEl path del plugin.\n\nExample: Leer name\n```js\nconsole.log(plugin.name);  // users\n```\n\n### plugin.id\n\nType: `property`\n\nEl identificador del plugin.\n\nEs el nombre con el prefijo `plug`.\n\nExample: Leer id\n```js\nconsole.log(plugin.id);  // plugusers\n```\n\n### plugin.element\n\nType: `property`\n\nEl elemento del plugin como objeto jQuery.\n\nEs el elemento del scope. Un plugin sin scope usa `body`.\n\nExample: Leer element\n```js\nconsole.log(plugin.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### plugin.model\n\nType: `property`\n\nLee o sustituye el modelo completo del plugin.\n\nLeer un modelo que no existe devuelve un objeto vacío.\n\nExample: Leer model\n```js\nplugin.model = { name: 'Peter' };\nconsole.log(plugin.model.name);  // Peter\n```\n\n### plugin.data\n\nType: `property`\n\nLee o sustituye el modelo completo del plugin.\n\nEs lo mismo que `model`.\n\nExample: Leer data\n```js\nplugin.data = { name: 'Anna' };\nconsole.log(plugin.data.name);  // Anna\n```\n\n### plugin.form\n\nType: `property`\n\nDevuelve el modelo y restablece el estado de sus componentes.\n\nAl leer la propiedad se limpia el estado tocado y modificado de los componentes enlazados al modelo.\n\nExample: Leer form\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.form);  // {\"name\":\"Peter\"}\n```\n\n### plugin.modified\n\nType: `property`\n\nDevuelve los campos cambiados por los componentes.\n\nAl leer la propiedad se limpia el estado tocado y modificado de los componentes enlazados al modelo.\n\nExample: Leer modified\n```js\nFIND('field').modify('Peter');\nconsole.log(plugin.modified);  // {\"name\":\"Peter\"}\n```\n\n### plugin.parent\n\nType: `property`\n\nEl plugin del scope padre.\n\nEl valor es `null` cuando no hay scope padre.\n\nExample: Leer parent\n```js\nconsole.log(PLUGINS['users.detail'].parent.name);  // users\n```\n\n### plugin.caller\n\nType: `property`\n\nEl plugin que estaba activo cuando se creó este plugin.\n\nEl valor es `null` cuando no había ningún plugin activo.\n\nExample: Leer caller\n```js\nconsole.log(plugin.caller);  // null\n```\n\n### plugin.set([path], value, [type])\n\nType: `method`\n\nEscribe un valor en un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `value` | `Object` | yes |  | El valor. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nCon un argumento, el valor sustituye el modelo completo.\n\nExample: Usar set()\n```js\nplugin.set('name', 'Peter');\nconsole.log(GET('users.name'));  // Peter\n```\n\n### plugin.get([path])\n\nType: `method`\n\nLee un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n\nReturns: `Object` El valor.\n\nSin argumento, el método devuelve el modelo completo.\n\nExample: Usar get()\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.get('name'));  // Peter\n```\n\n### plugin.nul(path, [type])\n\nType: `method`\n\nEscribe `null` en un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nExample: Usar nul()\n```js\nplugin.set('name', 'Peter');\nplugin.nul('name');\nconsole.log(plugin.get('name'));  // null\n```\n\n### plugin.push([path], value, [type])\n\nType: `method`\n\nAñade un ítem a un array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `value` | `Object` | yes |  | El elemento. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nCon un argumento, el ítem se añade al propio modelo.\n\nExample: Usar push()\n```js\nplugin.push('items', 'A');\nplugin.push('items', 'B');\nconsole.log(plugin.get('items'));  // [\"A\",\"B\"]\n```\n\n### plugin.extend([path], value, [type])\n\nType: `method`\n\nCombina un objeto en un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `value` | `Object` | yes |  | Los campos. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nCon un argumento, el objeto se combina en el propio modelo.\n\nExample: Usar extend()\n```js\nplugin.extend('user', { name: 'Peter' });\nplugin.extend('user', { age: 30 });\nconsole.log(plugin.get('user'));  // {\"name\":\"Peter\",\"age\":30}\n```\n\n### plugin.inc([path], value, [type])\n\nType: `method`\n\nIncrementa un número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `value` | `Number` | yes |  | El incremento. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nCon un argumento, se incrementa el propio modelo.\n\nExample: Usar inc()\n```js\nplugin.inc('count', 2);\nplugin.inc('count', 3);\nconsole.log(plugin.get('count'));  // 5\n```\n\n### plugin.toggle(path, [type])\n\nType: `method`\n\nInvierte un valor booleano.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nExample: Usar toggle()\n```js\nplugin.toggle('open');\nconsole.log(plugin.get('open'));  // true\n```\n\n### plugin.upd([path], [type])\n\nType: `method`\n\nNotifica a los listeners de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n| `type` | `Number` | no |  | El tipo del cambio. Un valor de `10` o más es un retardo en milisegundos. |\n\nReturns: `Plugin` El plugin.\n\nExample: Usar upd()\n```js\nplugin.watch('name', value => console.log(value));  // Peter\nwindow.users.name = 'Peter';\nplugin.upd('name');\n```\n\n### plugin.reset([path])\n\nType: `method`\n\nLimpia el estado de los componentes enlazados a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path relativo. |\n\nReturns: `Plugin` El plugin.\n\nSe limpia el estado tocado y modificado. El valor no cambia.\n\nExample: Usar reset()\n```js\nvar com = FIND('field');\ncom.modify('Peter');\nplugin.reset();\nconsole.log(com.config.touched, GET('users.name'));  // false Peter\n```\n\n### plugin.watch(path, callback, [init])\n\nType: `method`\n\nObserva un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n| `callback` | `Function` | yes |  | La función que recibe los cambios. |\n| `init` | `Boolean` | no |  | `true` llama al callback de inmediato. |\n\nReturns: `Plugin` El plugin.\n\nEl callback recibe `value`, `path` y `type`. Varios paths se separan con una coma o con ` + `.\n\nExample: Usar watch()\n```js\nplugin.watch('name', (value, path) => console.log(value, path));  // Peter users.name\nplugin.set('name', 'Peter');\n```\n\n### plugin.on(name, callback)\n\nType: `method`\n\nEscucha un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | yes |  | El listener. |\n\nReturns: `Plugin` El plugin.\n\nEl scope del plugin está activo cuando se registra el listener.\n\nExample: Usar on()\n```js\nplugin.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### plugin.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nLlama a un método del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del método. |\n\nReturns: `Plugin` El plugin.\n\nUn método desconocido se ignora. El método admite hasta cinco argumentos.\n\nExample: Usar exec()\n```js\nplugin.hello = name => console.log('Hello ' + name);  // Hello Peter\nplugin.exec('hello', 'Peter');\n```\n\n### plugin.makepath([path])\n\nType: `method`\n\nResuelve un path relativo al plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El path. |\n\nReturns: `String` El path resuelto.\n\nLas formas son:\n\n| Argumento | Resultado para el plugin `users` |\n| --- | --- |\n| omitido | `users` |\n| `name` o `?.name` | `users.name` |\n| `*name` | `common.name` |\n| `@flag` | `users @flag` |\n| `^name` | `^users.name` |\n| `+name` | `+users.name` |\n| `\\|name` | `users\\|name` |\n| `%name` | `%name` |\n| `#name` | `#name` |\n\nExample: Usar makepath()\n```js\nconsole.log(plugin.makepath('name'));  // users.name\n```\n\n### plugin.format([text])\n\nType: `method`\n\nInserta el nombre del plugin en un texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no |  | El texto. |\n\nReturns: `String` El resultado.\n\nEl nombre sustituye a `{0}`. Un texto sin marcador recibe el nombre al final.\n\nExample: Usar format()\n```js\nconsole.log(plugin.format('/api/{0}/'));  // /api/users/\n```\n\n### plugin.scope([path])\n\nType: `method`\n\nConvierte el plugin en el scope activo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El scope que se va a activar. |\n\nReturns: `Plugin` El plugin.\n\nLas demás funciones resuelven entonces `?` a este plugin. Se puede pasar otro path, y `null` limpia el scope activo. El método también está disponible como `plugin()`.\n\nExample: Usar scope()\n```js\nplugin.scope();\nconsole.log(M.scope());  // users\n```\n\n### plugin.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 URL. |\n| `data` | `Object` | no |  | Los datos de la petición. |\n| `callback` | `Function|String` | no |  | Una función o un path relativo. |\n\nReturns: `Plugin|Promise` El plugin, o una `Promise` si no hay callback.\n\nEl método llama a `AJAX()`. Un callback de texto es un path relativo al plugin, que recibe la respuesta. Sin `data` ni callback, el método devuelve una `Promise`.\n\nExample: Usar ajax()\n```js\nplugin.ajax('GET /api/users/', 'response');\nconsole.log(plugin.get('response.url'));  // GET /api/users/\n```\n\n### plugin.api(url, [data], [callback])\n\nType: `method`\n\nLlama a un endpoint de API.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El nombre del endpoint. |\n| `data` | `Object` | no |  | Los datos de la petición. |\n| `callback` | `Function|String` | no |  | Una función o un path relativo. |\n\nReturns: `Plugin|Promise` El plugin, o una `Promise` si no hay callback.\n\nEl método llama a `API()` y admite las mismas formas de callback que [`ajax()`](#ajax).\n\nExample: Usar api()\n```js\nplugin.api('users_read', function(response) {\n    console.log(response);  // users_read\n});\n```\n\n### plugin.dapi(name, [data], [callback])\n\nType: `method`\n\nLlama a un endpoint de DAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del endpoint. |\n| `data` | `Object` | no |  | Los datos de la petición. |\n| `callback` | `Function|String` | no |  | Una función o un path relativo. |\n\nReturns: `Plugin|Promise` El plugin, o una `Promise` si no hay callback.\n\nEl método llama a `DAPI()` y admite las mismas formas de callback que [`ajax()`](#ajax).\n\nExample: Usar dapi()\n```js\nplugin.dapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.tapi(name, [data], [callback])\n\nType: `method`\n\nLlama a un endpoint de TAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del endpoint. |\n| `data` | `Object` | no |  | Los datos de la petición. |\n| `callback` | `Function|String` | no |  | Una función o un path relativo. |\n\nReturns: `Plugin|Promise` El plugin, o una `Promise` si no hay callback.\n\nEl método llama a `TAPI()` y admite las mismas formas de callback que [`ajax()`](#ajax).\n\nExample: Usar tapi()\n```js\nplugin.tapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.upload(url, data, [callback])\n\nType: `method`\n\nSube datos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL. |\n| `data` | `FormData|Object` | yes |  | Los datos. |\n| `callback` | `Function|String` | no |  | Una función o un path relativo. |\n\nReturns: `Plugin|Promise` El plugin, o una `Promise` si no hay callback.\n\nEl método llama a `UPLOAD()` y admite las mismas formas de callback que [`ajax()`](#ajax).\n\nExample: Usar upload()\n```js\nplugin.upload('/upload/', new FormData(), function(response) {\n    console.log(response);  // /upload/\n});\n```\n\n### plugin.remove()\n\nType: `method`\n\nElimina el plugin.\n\nReturns: `Boolean` Siempre `true`.\n\nSe ejecuta el delegate `destroy` y se eliminan los eventos y observadores registrados durante la declaración. El elemento permanece en la página.\n\nExample: Usar remove()\n```js\nconsole.log(plugin.remove(), PLUGINS.users === undefined);  // true true\n```\n","entries":[{"type":"delegate","name":"destroy","signature":"exports.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"plugin.name","since":"","deprecated":false},{"type":"property","name":"id","signature":"plugin.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"plugin.element","since":"","deprecated":false},{"type":"property","name":"model","signature":"plugin.model","since":"","deprecated":false},{"type":"property","name":"data","signature":"plugin.data","since":"","deprecated":false},{"type":"property","name":"form","signature":"plugin.form","since":"","deprecated":false},{"type":"property","name":"modified","signature":"plugin.modified","since":"","deprecated":false},{"type":"property","name":"parent","signature":"plugin.parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"plugin.caller","since":"","deprecated":false},{"type":"method","name":"set()","signature":"plugin.set([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"plugin.get([path])","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"plugin.nul(path, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"plugin.push([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"plugin.extend([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"plugin.inc([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"plugin.toggle(path, [type])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"plugin.upd([path], [type])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"plugin.reset([path])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"plugin.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"plugin.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"plugin.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"plugin.makepath([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"plugin.format([text])","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"plugin.scope([path])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"plugin.ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"api()","signature":"plugin.api(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"dapi()","signature":"plugin.dapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"plugin.tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"upload()","signature":"plugin.upload(url, data, [callback])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"plugin.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammh68Qj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Plugin","summary":"Les propriétés, les delegates et les méthodes d'une instance de plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Plugin\n\n> Les propriétés, les delegates et les méthodes d'une instance de plugin.\n\nUne instance de plugin est l'objet passé à la déclaration de `PLUGIN()`. Elle contient la logique d'une partie de la page et travaille avec les données situées sous son propre path. [Plugins](../../guides/plugins/) explique le concept, et [ui-plugin](../ui-plugin/) décrit l'élément. Dans les exemples, `plugin` est l'instance du plugin `users`.\n\n## API\n\n### exports.destroy = function()\n\nType: `delegate`\n\nS'exécute quand le plugin est supprimé.\n\nExample: Libérer les ressources\n```html\n<ui-plugin path=\"users\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => PLUGINS.users.remove(), 500);\n</script>\n```\n\n### plugin.name\n\nType: `property`\n\nLe path du plugin.\n\nExample: Lire name\n```js\nconsole.log(plugin.name);  // users\n```\n\n### plugin.id\n\nType: `property`\n\nL'identifiant du plugin.\n\nC'est le nom avec le préfixe `plug`.\n\nExample: Lire id\n```js\nconsole.log(plugin.id);  // plugusers\n```\n\n### plugin.element\n\nType: `property`\n\nL'élément du plugin sous forme d'objet jQuery.\n\nC'est l'élément du scope. Un plugin sans scope utilise `body`.\n\nExample: Lire element\n```js\nconsole.log(plugin.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### plugin.model\n\nType: `property`\n\nLit ou remplace le modèle de données entier du plugin.\n\nLa lecture d'un modèle de données absent renvoie un objet vide.\n\nExample: Lire model\n```js\nplugin.model = { name: 'Peter' };\nconsole.log(plugin.model.name);  // Peter\n```\n\n### plugin.data\n\nType: `property`\n\nLit ou remplace le modèle de données entier du plugin.\n\nC'est la même chose que `model`.\n\nExample: Lire data\n```js\nplugin.data = { name: 'Anna' };\nconsole.log(plugin.data.name);  // Anna\n```\n\n### plugin.form\n\nType: `property`\n\nRenvoie le modèle de données et réinitialise l'état de ses composants.\n\nLa lecture de la propriété efface l'état touché et modifié des composants liés au modèle de données.\n\nExample: Lire form\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.form);  // {\"name\":\"Peter\"}\n```\n\n### plugin.modified\n\nType: `property`\n\nRenvoie les champs modifiés par les composants.\n\nLa lecture de la propriété efface l'état touché et modifié des composants liés au modèle de données.\n\nExample: Lire modified\n```js\nFIND('field').modify('Peter');\nconsole.log(plugin.modified);  // {\"name\":\"Peter\"}\n```\n\n### plugin.parent\n\nType: `property`\n\nLe plugin du scope parent.\n\nLa valeur est `null` quand il n'y a pas de scope parent.\n\nExample: Lire parent\n```js\nconsole.log(PLUGINS['users.detail'].parent.name);  // users\n```\n\n### plugin.caller\n\nType: `property`\n\nLe plugin qui était actif à la création de ce plugin.\n\nLa valeur est `null` quand aucun plugin n'était actif.\n\nExample: Lire caller\n```js\nconsole.log(plugin.caller);  // null\n```\n\n### plugin.set([path], value, [type])\n\nType: `method`\n\nÉcrit une valeur dans un path du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `value` | `Object` | yes |  | La valeur. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nAvec un seul argument, la valeur remplace le modèle de données entier.\n\nExample: Utiliser set()\n```js\nplugin.set('name', 'Peter');\nconsole.log(GET('users.name'));  // Peter\n```\n\n### plugin.get([path])\n\nType: `method`\n\nLit un path du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n\nReturns: `Object` La valeur.\n\nSans argument, la méthode renvoie le modèle de données entier.\n\nExample: Utiliser get()\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.get('name'));  // Peter\n```\n\n### plugin.nul(path, [type])\n\nType: `method`\n\nÉcrit `null` dans un path du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nExample: Utiliser nul()\n```js\nplugin.set('name', 'Peter');\nplugin.nul('name');\nconsole.log(plugin.get('name'));  // null\n```\n\n### plugin.push([path], value, [type])\n\nType: `method`\n\nAjoute un élément à un tableau.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `value` | `Object` | yes |  | L'élément. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nAvec un seul argument, l'élément est ajouté au modèle de données lui-même.\n\nExample: Utiliser push()\n```js\nplugin.push('items', 'A');\nplugin.push('items', 'B');\nconsole.log(plugin.get('items'));  // [\"A\",\"B\"]\n```\n\n### plugin.extend([path], value, [type])\n\nType: `method`\n\nFusionne un objet dans un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `value` | `Object` | yes |  | Les champs. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nAvec un seul argument, l'objet est fusionné dans le modèle de données lui-même.\n\nExample: Utiliser extend()\n```js\nplugin.extend('user', { name: 'Peter' });\nplugin.extend('user', { age: 30 });\nconsole.log(plugin.get('user'));  // {\"name\":\"Peter\",\"age\":30}\n```\n\n### plugin.inc([path], value, [type])\n\nType: `method`\n\nAugmente un nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `value` | `Number` | yes |  | L'incrément. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nAvec un seul argument, c'est le modèle de données lui-même qui est augmenté.\n\nExample: Utiliser inc()\n```js\nplugin.inc('count', 2);\nplugin.inc('count', 3);\nconsole.log(plugin.get('count'));  // 5\n```\n\n### plugin.toggle(path, [type])\n\nType: `method`\n\nInverse une valeur booléenne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nExample: Utiliser toggle()\n```js\nplugin.toggle('open');\nconsole.log(plugin.get('open'));  // true\n```\n\n### plugin.upd([path], [type])\n\nType: `method`\n\nNotifie les écouteurs d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n| `type` | `Number` | no |  | Le type de la modification. Une valeur de `10` ou plus est un délai en millisecondes. |\n\nReturns: `Plugin` Le plugin.\n\nExample: Utiliser upd()\n```js\nplugin.watch('name', value => console.log(value));  // Peter\nwindow.users.name = 'Peter';\nplugin.upd('name');\n```\n\n### plugin.reset([path])\n\nType: `method`\n\nEfface l'état des composants liés à un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path relatif. |\n\nReturns: `Plugin` Le plugin.\n\nL'état touché et modifié est effacé. La valeur ne change pas.\n\nExample: Utiliser reset()\n```js\nvar com = FIND('field');\ncom.modify('Peter');\nplugin.reset();\nconsole.log(com.config.touched, GET('users.name'));  // false Peter\n```\n\n### plugin.watch(path, callback, [init])\n\nType: `method`\n\nObserve un path du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n| `callback` | `Function` | yes |  | La fonction qui reçoit les modifications. |\n| `init` | `Boolean` | no |  | `true` appelle le callback immédiatement. |\n\nReturns: `Plugin` Le plugin.\n\nLe callback reçoit `value`, `path` et `type`. Plusieurs paths sont séparés par une virgule ou par ` + `.\n\nExample: Utiliser watch()\n```js\nplugin.watch('name', (value, path) => console.log(value, path));  // Peter users.name\nplugin.set('name', 'Peter');\n```\n\n### plugin.on(name, callback)\n\nType: `method`\n\nÉcoute 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 |  | L'écouteur. |\n\nReturns: `Plugin` Le plugin.\n\nLe scope du plugin est actif lors de l'enregistrement de l'écouteur.\n\nExample: Utiliser on()\n```js\nplugin.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### plugin.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nAppelle une méthode du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la méthode. |\n\nReturns: `Plugin` Le plugin.\n\nUne méthode inconnue est ignorée. La méthode accepte jusqu'à cinq arguments.\n\nExample: Utiliser exec()\n```js\nplugin.hello = name => console.log('Hello ' + name);  // Hello Peter\nplugin.exec('hello', 'Peter');\n```\n\n### plugin.makepath([path])\n\nType: `method`\n\nRésout un path relatif au plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le path. |\n\nReturns: `String` Le path résolu.\n\nLes formes sont :\n\n| Argument | Résultat pour le plugin `users` |\n| --- | --- |\n| omis | `users` |\n| `name` ou `?.name` | `users.name` |\n| `*name` | `common.name` |\n| `@flag` | `users @flag` |\n| `^name` | `^users.name` |\n| `+name` | `+users.name` |\n| `\\|name` | `users\\|name` |\n| `%name` | `%name` |\n| `#name` | `#name` |\n\nExample: Utiliser makepath()\n```js\nconsole.log(plugin.makepath('name'));  // users.name\n```\n\n### plugin.format([text])\n\nType: `method`\n\nInsère le nom du plugin dans un texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no |  | Le texte. |\n\nReturns: `String` Le résultat.\n\nLe nom remplace `{0}`. Dans un texte sans espace réservé, le nom est ajouté à la fin.\n\nExample: Utiliser format()\n```js\nconsole.log(plugin.format('/api/{0}/'));  // /api/users/\n```\n\n### plugin.scope([path])\n\nType: `method`\n\nFait du plugin le scope actif.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le scope à activer. |\n\nReturns: `Plugin` Le plugin.\n\nLes autres fonctions résolvent alors `?` vers ce plugin. Tu peux passer un autre path, et `null` efface le scope actif. La méthode est aussi disponible sous le nom `plugin()`.\n\nExample: Utiliser scope()\n```js\nplugin.scope();\nconsole.log(M.scope());  // users\n```\n\n### plugin.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'URL. |\n| `data` | `Object` | no |  | Les données de la requête. |\n| `callback` | `Function|String` | no |  | Une fonction ou un path relatif. |\n\nReturns: `Plugin|Promise` Le plugin, ou une `Promise` sans callback.\n\nLa méthode appelle `AJAX()`. Un callback textuel est un path relatif au plugin, qui reçoit la réponse. Sans `data` ni callback, la méthode renvoie une `Promise`.\n\nExample: Utiliser ajax()\n```js\nplugin.ajax('GET /api/users/', 'response');\nconsole.log(plugin.get('response.url'));  // GET /api/users/\n```\n\n### plugin.api(url, [data], [callback])\n\nType: `method`\n\nAppelle un endpoint d'API.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Le nom de l'endpoint. |\n| `data` | `Object` | no |  | Les données de la requête. |\n| `callback` | `Function|String` | no |  | Une fonction ou un path relatif. |\n\nReturns: `Plugin|Promise` Le plugin, ou une `Promise` sans callback.\n\nLa méthode appelle `API()` et accepte les mêmes formes de callback que [`ajax()`](#ajax).\n\nExample: Utiliser api()\n```js\nplugin.api('users_read', function(response) {\n    console.log(response);  // users_read\n});\n```\n\n### plugin.dapi(name, [data], [callback])\n\nType: `method`\n\nAppelle un endpoint DAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'endpoint. |\n| `data` | `Object` | no |  | Les données de la requête. |\n| `callback` | `Function|String` | no |  | Une fonction ou un path relatif. |\n\nReturns: `Plugin|Promise` Le plugin, ou une `Promise` sans callback.\n\nLa méthode appelle `DAPI()` et accepte les mêmes formes de callback que [`ajax()`](#ajax).\n\nExample: Utiliser dapi()\n```js\nplugin.dapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.tapi(name, [data], [callback])\n\nType: `method`\n\nAppelle un endpoint TAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'endpoint. |\n| `data` | `Object` | no |  | Les données de la requête. |\n| `callback` | `Function|String` | no |  | Une fonction ou un path relatif. |\n\nReturns: `Plugin|Promise` Le plugin, ou une `Promise` sans callback.\n\nLa méthode appelle `TAPI()` et accepte les mêmes formes de callback que [`ajax()`](#ajax).\n\nExample: Utiliser tapi()\n```js\nplugin.tapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.upload(url, data, [callback])\n\nType: `method`\n\nEnvoie des données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `data` | `FormData|Object` | yes |  | Les données. |\n| `callback` | `Function|String` | no |  | Une fonction ou un path relatif. |\n\nReturns: `Plugin|Promise` Le plugin, ou une `Promise` sans callback.\n\nLa méthode appelle `UPLOAD()` et accepte les mêmes formes de callback que [`ajax()`](#ajax).\n\nExample: Utiliser upload()\n```js\nplugin.upload('/upload/', new FormData(), function(response) {\n    console.log(response);  // /upload/\n});\n```\n\n### plugin.remove()\n\nType: `method`\n\nSupprime le plugin.\n\nReturns: `Boolean` Toujours `true`.\n\nLe delegate `destroy` s'exécute, et les événements et observateurs enregistrés pendant la déclaration sont supprimés. L'élément reste dans la page.\n\nExample: Utiliser remove()\n```js\nconsole.log(plugin.remove(), PLUGINS.users === undefined);  // true true\n```\n","entries":[{"type":"delegate","name":"destroy","signature":"exports.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"plugin.name","since":"","deprecated":false},{"type":"property","name":"id","signature":"plugin.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"plugin.element","since":"","deprecated":false},{"type":"property","name":"model","signature":"plugin.model","since":"","deprecated":false},{"type":"property","name":"data","signature":"plugin.data","since":"","deprecated":false},{"type":"property","name":"form","signature":"plugin.form","since":"","deprecated":false},{"type":"property","name":"modified","signature":"plugin.modified","since":"","deprecated":false},{"type":"property","name":"parent","signature":"plugin.parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"plugin.caller","since":"","deprecated":false},{"type":"method","name":"set()","signature":"plugin.set([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"plugin.get([path])","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"plugin.nul(path, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"plugin.push([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"plugin.extend([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"plugin.inc([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"plugin.toggle(path, [type])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"plugin.upd([path], [type])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"plugin.reset([path])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"plugin.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"plugin.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"plugin.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"plugin.makepath([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"plugin.format([text])","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"plugin.scope([path])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"plugin.ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"api()","signature":"plugin.api(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"dapi()","signature":"plugin.dapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"plugin.tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"upload()","signature":"plugin.upload(url, data, [callback])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"plugin.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammh68Qj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Plugin","summary":"Le proprietà, i delegate e i metodi di un'istanza di plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Plugin\n\n> Le proprietà, i delegate e i metodi di un'istanza di plugin.\n\nUn'istanza di plugin è l'oggetto passato alla dichiarazione di `PLUGIN()`. Contiene la logica di una parte della pagina e lavora con i dati sotto il proprio path. [Plugin](../../guides/plugins/) spiega il concetto e [ui-plugin](../ui-plugin/) descrive l'elemento. Negli esempi, `plugin` è l'istanza del plugin `users`.\n\n## API\n\n### exports.destroy = function()\n\nType: `delegate`\n\nViene eseguito quando il plugin viene rimosso.\n\nExample: Rilasciare le risorse\n```html\n<ui-plugin path=\"users\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => PLUGINS.users.remove(), 500);\n</script>\n```\n\n### plugin.name\n\nType: `property`\n\nIl path del plugin.\n\nExample: Lettura di name\n```js\nconsole.log(plugin.name);  // users\n```\n\n### plugin.id\n\nType: `property`\n\nL'identificatore del plugin.\n\nÈ il nome con il prefisso `plug`.\n\nExample: Lettura di id\n```js\nconsole.log(plugin.id);  // plugusers\n```\n\n### plugin.element\n\nType: `property`\n\nL'elemento del plugin come oggetto jQuery.\n\nÈ l'elemento dello scope. Un plugin senza scope usa `body`.\n\nExample: Lettura di element\n```js\nconsole.log(plugin.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### plugin.model\n\nType: `property`\n\nLegge o sostituisce l'intero modello del plugin.\n\nLa lettura di un modello mancante restituisce un oggetto vuoto.\n\nExample: Lettura di model\n```js\nplugin.model = { name: 'Peter' };\nconsole.log(plugin.model.name);  // Peter\n```\n\n### plugin.data\n\nType: `property`\n\nLegge o sostituisce l'intero modello del plugin.\n\nÈ uguale a `model`.\n\nExample: Lettura di data\n```js\nplugin.data = { name: 'Anna' };\nconsole.log(plugin.data.name);  // Anna\n```\n\n### plugin.form\n\nType: `property`\n\nRestituisce il modello e reimposta lo stato dei suoi componenti.\n\nLa lettura della proprietà azzera lo stato di toccato e modificato dei componenti associati al modello.\n\nExample: Lettura di form\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.form);  // {\"name\":\"Peter\"}\n```\n\n### plugin.modified\n\nType: `property`\n\nRestituisce i campi modificati dai componenti.\n\nLa lettura della proprietà azzera lo stato di toccato e modificato dei componenti associati al modello.\n\nExample: Lettura di modified\n```js\nFIND('field').modify('Peter');\nconsole.log(plugin.modified);  // {\"name\":\"Peter\"}\n```\n\n### plugin.parent\n\nType: `property`\n\nIl plugin dello scope padre.\n\nIl valore è `null` quando non esiste uno scope padre.\n\nExample: Lettura di parent\n```js\nconsole.log(PLUGINS['users.detail'].parent.name);  // users\n```\n\n### plugin.caller\n\nType: `property`\n\nIl plugin che era attivo quando è stato creato questo plugin.\n\nIl valore è `null` quando nessun plugin era attivo.\n\nExample: Lettura di caller\n```js\nconsole.log(plugin.caller);  // null\n```\n\n### plugin.set([path], value, [type])\n\nType: `method`\n\nScrive un valore in un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `value` | `Object` | yes |  | Il valore. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nCon un solo argomento, il valore sostituisce l'intero modello.\n\nExample: Uso di set()\n```js\nplugin.set('name', 'Peter');\nconsole.log(GET('users.name'));  // Peter\n```\n\n### plugin.get([path])\n\nType: `method`\n\nLegge un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n\nReturns: `Object` Il valore.\n\nSenza argomenti, il metodo restituisce l'intero modello.\n\nExample: Uso di get()\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.get('name'));  // Peter\n```\n\n### plugin.nul(path, [type])\n\nType: `method`\n\nScrive `null` in un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nExample: Uso di nul()\n```js\nplugin.set('name', 'Peter');\nplugin.nul('name');\nconsole.log(plugin.get('name'));  // null\n```\n\n### plugin.push([path], value, [type])\n\nType: `method`\n\nAggiunge un elemento a un array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `value` | `Object` | yes |  | L'elemento. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nCon un solo argomento, l'elemento viene aggiunto al modello stesso.\n\nExample: Uso di push()\n```js\nplugin.push('items', 'A');\nplugin.push('items', 'B');\nconsole.log(plugin.get('items'));  // [\"A\",\"B\"]\n```\n\n### plugin.extend([path], value, [type])\n\nType: `method`\n\nUnisce un oggetto in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `value` | `Object` | yes |  | I campi. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nCon un solo argomento, l'oggetto viene unito al modello stesso.\n\nExample: Uso di extend()\n```js\nplugin.extend('user', { name: 'Peter' });\nplugin.extend('user', { age: 30 });\nconsole.log(plugin.get('user'));  // {\"name\":\"Peter\",\"age\":30}\n```\n\n### plugin.inc([path], value, [type])\n\nType: `method`\n\nIncrementa un numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `value` | `Number` | yes |  | L'incremento. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nCon un solo argomento, viene incrementato il modello stesso.\n\nExample: Uso di inc()\n```js\nplugin.inc('count', 2);\nplugin.inc('count', 3);\nconsole.log(plugin.get('count'));  // 5\n```\n\n### plugin.toggle(path, [type])\n\nType: `method`\n\nInverte un valore booleano.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nExample: Uso di toggle()\n```js\nplugin.toggle('open');\nconsole.log(plugin.get('open'));  // true\n```\n\n### plugin.upd([path], [type])\n\nType: `method`\n\nNotifica i listener di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path relativo. |\n| `type` | `Number` | no |  | Il tipo della modifica. Un valore pari o superiore a `10` è un ritardo in millisecondi. |\n\nReturns: `Plugin` Il plugin.\n\nExample: Uso di upd()\n```js\nplugin.watch('name', value => console.log(value));  // Peter\nwindow.users.name = 'Peter';\nplugin.upd('name');\n```\n\n### plugin.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` | no |  | Il path relativo. |\n\nReturns: `Plugin` Il plugin.\n\nLo stato di toccato e modificato viene azzerato. Il valore non cambia.\n\nExample: Uso di reset()\n```js\nvar com = FIND('field');\ncom.modify('Peter');\nplugin.reset();\nconsole.log(com.config.touched, GET('users.name'));  // false Peter\n```\n\n### plugin.watch(path, callback, [init])\n\nType: `method`\n\nOsserva un path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n| `callback` | `Function` | yes |  | La funzione che riceve le modifiche. |\n| `init` | `Boolean` | no |  | `true` chiama subito il callback. |\n\nReturns: `Plugin` Il plugin.\n\nIl callback riceve `value`, `path` e `type`. Più path sono separati da una virgola o da ` + `.\n\nExample: Uso di watch()\n```js\nplugin.watch('name', (value, path) => console.log(value, path));  // Peter users.name\nplugin.set('name', 'Peter');\n```\n\n### plugin.on(name, callback)\n\nType: `method`\n\nResta in ascolto 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 listener. |\n\nReturns: `Plugin` Il plugin.\n\nLo scope del plugin è attivo quando il listener viene registrato.\n\nExample: Uso di on()\n```js\nplugin.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### plugin.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nChiama un metodo del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del metodo. |\n\nReturns: `Plugin` Il plugin.\n\nUn metodo sconosciuto viene ignorato. Il metodo accetta fino a cinque argomenti.\n\nExample: Uso di exec()\n```js\nplugin.hello = name => console.log('Hello ' + name);  // Hello Peter\nplugin.exec('hello', 'Peter');\n```\n\n### plugin.makepath([path])\n\nType: `method`\n\nRisolve un path relativo al plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il path. |\n\nReturns: `String` Il path risolto.\n\nLe forme sono:\n\n| Argomento | Risultato per il plugin `users` |\n| --- | --- |\n| omesso | `users` |\n| `name` o `?.name` | `users.name` |\n| `*name` | `common.name` |\n| `@flag` | `users @flag` |\n| `^name` | `^users.name` |\n| `+name` | `+users.name` |\n| `\\|name` | `users\\|name` |\n| `%name` | `%name` |\n| `#name` | `#name` |\n\nExample: Uso di makepath()\n```js\nconsole.log(plugin.makepath('name'));  // users.name\n```\n\n### plugin.format([text])\n\nType: `method`\n\nInserisce il nome del plugin in un testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no |  | Il testo. |\n\nReturns: `String` Il risultato.\n\nIl nome sostituisce `{0}`. Un testo senza segnaposto riceve il nome alla fine.\n\nExample: Uso di format()\n```js\nconsole.log(plugin.format('/api/{0}/'));  // /api/users/\n```\n\n### plugin.scope([path])\n\nType: `method`\n\nRende il plugin lo scope attivo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Lo scope da attivare. |\n\nReturns: `Plugin` Il plugin.\n\nLe altre funzioni risolvono allora `?` verso questo plugin. Puoi passare un altro path, e `null` azzera lo scope attivo. Il metodo è disponibile anche come `plugin()`.\n\nExample: Uso di scope()\n```js\nplugin.scope();\nconsole.log(M.scope());  // users\n```\n\n### plugin.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'URL. |\n| `data` | `Object` | no |  | I dati della richiesta. |\n| `callback` | `Function|String` | no |  | Una funzione o un path relativo. |\n\nReturns: `Plugin|Promise` Il plugin, oppure una `Promise` senza callback.\n\nIl metodo chiama `AJAX()`. Un callback testuale è un path relativo al plugin, che riceve la risposta. Senza `data` e senza callback, il metodo restituisce una `Promise`.\n\nExample: Uso di ajax()\n```js\nplugin.ajax('GET /api/users/', 'response');\nconsole.log(plugin.get('response.url'));  // GET /api/users/\n```\n\n### plugin.api(url, [data], [callback])\n\nType: `method`\n\nChiama un endpoint API.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il nome dell'endpoint. |\n| `data` | `Object` | no |  | I dati della richiesta. |\n| `callback` | `Function|String` | no |  | Una funzione o un path relativo. |\n\nReturns: `Plugin|Promise` Il plugin, oppure una `Promise` senza callback.\n\nIl metodo chiama `API()` e accetta le stesse forme di callback di [`ajax()`](#ajax).\n\nExample: Uso di api()\n```js\nplugin.api('users_read', function(response) {\n    console.log(response);  // users_read\n});\n```\n\n### plugin.dapi(name, [data], [callback])\n\nType: `method`\n\nChiama un endpoint DAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'endpoint. |\n| `data` | `Object` | no |  | I dati della richiesta. |\n| `callback` | `Function|String` | no |  | Una funzione o un path relativo. |\n\nReturns: `Plugin|Promise` Il plugin, oppure una `Promise` senza callback.\n\nIl metodo chiama `DAPI()` e accetta le stesse forme di callback di [`ajax()`](#ajax).\n\nExample: Uso di dapi()\n```js\nplugin.dapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.tapi(name, [data], [callback])\n\nType: `method`\n\nChiama un endpoint TAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'endpoint. |\n| `data` | `Object` | no |  | I dati della richiesta. |\n| `callback` | `Function|String` | no |  | Una funzione o un path relativo. |\n\nReturns: `Plugin|Promise` Il plugin, oppure una `Promise` senza callback.\n\nIl metodo chiama `TAPI()` e accetta le stesse forme di callback di [`ajax()`](#ajax).\n\nExample: Uso di tapi()\n```js\nplugin.tapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.upload(url, data, [callback])\n\nType: `method`\n\nCarica dati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `data` | `FormData|Object` | yes |  | I dati. |\n| `callback` | `Function|String` | no |  | Una funzione o un path relativo. |\n\nReturns: `Plugin|Promise` Il plugin, oppure una `Promise` senza callback.\n\nIl metodo chiama `UPLOAD()` e accetta le stesse forme di callback di [`ajax()`](#ajax).\n\nExample: Uso di upload()\n```js\nplugin.upload('/upload/', new FormData(), function(response) {\n    console.log(response);  // /upload/\n});\n```\n\n### plugin.remove()\n\nType: `method`\n\nRimuove il plugin.\n\nReturns: `Boolean` Sempre `true`.\n\nViene eseguito il delegate `destroy` e vengono rimossi gli eventi e gli osservatori registrati durante la dichiarazione. L'elemento resta nella pagina.\n\nExample: Uso di remove()\n```js\nconsole.log(plugin.remove(), PLUGINS.users === undefined);  // true true\n```\n","entries":[{"type":"delegate","name":"destroy","signature":"exports.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"plugin.name","since":"","deprecated":false},{"type":"property","name":"id","signature":"plugin.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"plugin.element","since":"","deprecated":false},{"type":"property","name":"model","signature":"plugin.model","since":"","deprecated":false},{"type":"property","name":"data","signature":"plugin.data","since":"","deprecated":false},{"type":"property","name":"form","signature":"plugin.form","since":"","deprecated":false},{"type":"property","name":"modified","signature":"plugin.modified","since":"","deprecated":false},{"type":"property","name":"parent","signature":"plugin.parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"plugin.caller","since":"","deprecated":false},{"type":"method","name":"set()","signature":"plugin.set([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"plugin.get([path])","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"plugin.nul(path, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"plugin.push([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"plugin.extend([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"plugin.inc([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"plugin.toggle(path, [type])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"plugin.upd([path], [type])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"plugin.reset([path])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"plugin.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"plugin.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"plugin.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"plugin.makepath([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"plugin.format([text])","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"plugin.scope([path])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"plugin.ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"api()","signature":"plugin.api(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"dapi()","signature":"plugin.dapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"plugin.tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"upload()","signature":"plugin.upload(url, data, [callback])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"plugin.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammh68Qj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/plugin/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Plugin","summary":"Vlastnosti, delegate a metódy inštancie pluginu.","markdown":"---\ntitle: Plugin\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/plugin/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Plugin\n\n> Vlastnosti, delegate a metódy inštancie pluginu.\n\nInštancia pluginu je objekt odovzdaný deklarácii `PLUGIN()`. Obsahuje logiku časti stránky a pracuje s údajmi pod vlastnou path. Koncept vysvetľuje časť [Pluginy](../../guides/plugins/) a element popisuje časť [ui-plugin](../ui-plugin/). V príkladoch je `plugin` inštancia pluginu `users`.\n\n## API\n\n### exports.destroy = function()\n\nType: `delegate`\n\nSpustí sa pri odstránení pluginu.\n\nExample: Uvoľnenie zdrojov\n```html\n<ui-plugin path=\"users\"><span></span></ui-plugin>\n\n<script>\n    PLUGIN('users', function(exports) {\n        exports.destroy = () => console.log('destroyed');  // destroyed\n    });\n    setTimeout(() => PLUGINS.users.remove(), 500);\n</script>\n```\n\n### plugin.name\n\nType: `property`\n\nPath pluginu.\n\nExample: Čítanie name\n```js\nconsole.log(plugin.name);  // users\n```\n\n### plugin.id\n\nType: `property`\n\nIdentifikátor pluginu.\n\nJe to názov s predponou `plug`.\n\nExample: Čítanie id\n```js\nconsole.log(plugin.id);  // plugusers\n```\n\n### plugin.element\n\nType: `property`\n\nElement pluginu ako objekt jQuery.\n\nJe to element scopu. Plugin bez scopu používa `body`.\n\nExample: Čítanie element\n```js\nconsole.log(plugin.element.prop('tagName'));  // UI-PLUGIN\n```\n\n### plugin.model\n\nType: `property`\n\nPrečíta alebo nahradí celý model pluginu.\n\nČítanie chýbajúceho modelu vráti prázdny objekt.\n\nExample: Čítanie model\n```js\nplugin.model = { name: 'Peter' };\nconsole.log(plugin.model.name);  // Peter\n```\n\n### plugin.data\n\nType: `property`\n\nPrečíta alebo nahradí celý model pluginu.\n\nJe to to isté ako `model`.\n\nExample: Čítanie data\n```js\nplugin.data = { name: 'Anna' };\nconsole.log(plugin.data.name);  // Anna\n```\n\n### plugin.form\n\nType: `property`\n\nVráti model a resetuje stav jeho komponentov.\n\nČítanie tejto vlastnosti vymaže stav dotknutia a úpravy komponentov naviazaných na model.\n\nExample: Čítanie form\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.form);  // {\"name\":\"Peter\"}\n```\n\n### plugin.modified\n\nType: `property`\n\nVráti polia zmenené komponentmi.\n\nČítanie tejto vlastnosti vymaže stav dotknutia a úpravy komponentov naviazaných na model.\n\nExample: Čítanie modified\n```js\nFIND('field').modify('Peter');\nconsole.log(plugin.modified);  // {\"name\":\"Peter\"}\n```\n\n### plugin.parent\n\nType: `property`\n\nPlugin nadradeného scopu.\n\nAk nadradený scope neexistuje, hodnota je `null`.\n\nExample: Čítanie parent\n```js\nconsole.log(PLUGINS['users.detail'].parent.name);  // users\n```\n\n### plugin.caller\n\nType: `property`\n\nPlugin, ktorý bol aktívny pri vytvorení tohto pluginu.\n\nAk nebol aktívny žiadny plugin, hodnota je `null`.\n\nExample: Čítanie caller\n```js\nconsole.log(plugin.caller);  // null\n```\n\n### plugin.set([path], value, [type])\n\nType: `method`\n\nZapíše hodnotu na path pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nPri jednom argumente hodnota nahradí celý model.\n\nExample: Použitie set()\n```js\nplugin.set('name', 'Peter');\nconsole.log(GET('users.name'));  // Peter\n```\n\n### plugin.get([path])\n\nType: `method`\n\nPrečíta path pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n\nReturns: `Object` Hodnota.\n\nBez argumentu metóda vráti celý model.\n\nExample: Použitie get()\n```js\nplugin.set('name', 'Peter');\nconsole.log(plugin.get('name'));  // Peter\n```\n\n### plugin.nul(path, [type])\n\nType: `method`\n\nZapíše `null` na path pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nExample: Použitie nul()\n```js\nplugin.set('name', 'Peter');\nplugin.nul('name');\nconsole.log(plugin.get('name'));  // null\n```\n\n### plugin.push([path], value, [type])\n\nType: `method`\n\nPridá položku do poľa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `value` | `Object` | yes |  | Položka. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nPri jednom argumente sa položka pridá priamo do modelu.\n\nExample: Použitie push()\n```js\nplugin.push('items', 'A');\nplugin.push('items', 'B');\nconsole.log(plugin.get('items'));  // [\"A\",\"B\"]\n```\n\n### plugin.extend([path], value, [type])\n\nType: `method`\n\nZlúči objekt do path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `value` | `Object` | yes |  | Polia. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nPri jednom argumente sa objekt zlúči priamo do modelu.\n\nExample: Použitie extend()\n```js\nplugin.extend('user', { name: 'Peter' });\nplugin.extend('user', { age: 30 });\nconsole.log(plugin.get('user'));  // {\"name\":\"Peter\",\"age\":30}\n```\n\n### plugin.inc([path], value, [type])\n\nType: `method`\n\nZvýši číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `value` | `Number` | yes |  | Prírastok. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nPri jednom argumente sa zvýši priamo model.\n\nExample: Použitie inc()\n```js\nplugin.inc('count', 2);\nplugin.inc('count', 3);\nconsole.log(plugin.get('count'));  // 5\n```\n\n### plugin.toggle(path, [type])\n\nType: `method`\n\nInvertuje logickú hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nExample: Použitie toggle()\n```js\nplugin.toggle('open');\nconsole.log(plugin.get('open'));  // true\n```\n\n### plugin.upd([path], [type])\n\nType: `method`\n\nUpozorní poslucháčov path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n| `type` | `Number` | no |  | Typ zmeny. Hodnota `10` alebo vyššia je oneskorenie v milisekundách. |\n\nReturns: `Plugin` Plugin.\n\nExample: Použitie upd()\n```js\nplugin.watch('name', value => console.log(value));  // Peter\nwindow.users.name = 'Peter';\nplugin.upd('name');\n```\n\n### plugin.reset([path])\n\nType: `method`\n\nVymaže stav komponentov naviazaných na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Relatívny path. |\n\nReturns: `Plugin` Plugin.\n\nVymaže sa stav dotknutia a úpravy. Hodnota sa nezmení.\n\nExample: Použitie reset()\n```js\nvar com = FIND('field');\ncom.modify('Peter');\nplugin.reset();\nconsole.log(com.config.touched, GET('users.name'));  // false Peter\n```\n\n### plugin.watch(path, callback, [init])\n\nType: `method`\n\nSleduje path pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostáva zmeny. |\n| `init` | `Boolean` | no |  | `true` zavolá callback okamžite. |\n\nReturns: `Plugin` Plugin.\n\nCallback dostane `value`, `path` a `type`. Viacero path oddeľ čiarkou alebo ` + `.\n\nExample: Použitie watch()\n```js\nplugin.watch('name', (value, path) => console.log(value, path));  // Peter users.name\nplugin.set('name', 'Peter');\n```\n\n### plugin.on(name, callback)\n\nType: `method`\n\nPočúva globálnu udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | yes |  | Poslucháč. |\n\nReturns: `Plugin` Plugin.\n\nPri registrácii poslucháča je aktívny scope pluginu.\n\nExample: Použitie on()\n```js\nplugin.on('saved', value => console.log(value));  // 5\nEMIT('saved', 5);\n```\n\n### plugin.exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nZavolá metódu pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov metódy. |\n\nReturns: `Plugin` Plugin.\n\nNeznáma metóda sa ignoruje. Metóda prijíma najviac päť argumentov.\n\nExample: Použitie exec()\n```js\nplugin.hello = name => console.log('Hello ' + name);  // Hello Peter\nplugin.exec('hello', 'Peter');\n```\n\n### plugin.makepath([path])\n\nType: `method`\n\nPreloží path relatívnu k pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Path. |\n\nReturns: `String` Preložená path.\n\nTvary sú:\n\n| Argument | Výsledok pre plugin `users` |\n| --- | --- |\n| vynechaný | `users` |\n| `name` alebo `?.name` | `users.name` |\n| `*name` | `common.name` |\n| `@flag` | `users @flag` |\n| `^name` | `^users.name` |\n| `+name` | `+users.name` |\n| `\\|name` | `users\\|name` |\n| `%name` | `%name` |\n| `#name` | `#name` |\n\nExample: Použitie makepath()\n```js\nconsole.log(plugin.makepath('name'));  // users.name\n```\n\n### plugin.format([text])\n\nType: `method`\n\nVloží názov pluginu do textu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no |  | Text. |\n\nReturns: `String` Výsledok.\n\nNázov nahradí `{0}`. Do textu bez zástupného symbolu sa názov pridá na koniec.\n\nExample: Použitie format()\n```js\nconsole.log(plugin.format('/api/{0}/'));  // /api/users/\n```\n\n### plugin.scope([path])\n\nType: `method`\n\nNastaví plugin ako aktívny scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Scope, ktorý sa má aktivovať. |\n\nReturns: `Plugin` Plugin.\n\nOstatné funkcie potom prekladajú `?` na tento plugin. Môžeš odovzdať aj inú path a `null` aktívny scope vymaže. Metóda je dostupná aj ako `plugin()`.\n\nExample: Použitie scope()\n```js\nplugin.scope();\nconsole.log(M.scope());  // users\n```\n\n### plugin.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 URL. |\n| `data` | `Object` | no |  | Údaje požiadavky. |\n| `callback` | `Function|String` | no |  | Funkcia alebo relatívna path. |\n\nReturns: `Plugin|Promise` Plugin, alebo `Promise`, keď nie je zadaný callback.\n\nMetóda volá `AJAX()`. Textový callback je path relatívna k pluginu, ktorá dostane odpoveď. Bez `data` a callbacku metóda vráti `Promise`.\n\nExample: Použitie ajax()\n```js\nplugin.ajax('GET /api/users/', 'response');\nconsole.log(plugin.get('response.url'));  // GET /api/users/\n```\n\n### plugin.api(url, [data], [callback])\n\nType: `method`\n\nZavolá koncový bod API.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Názov koncového bodu. |\n| `data` | `Object` | no |  | Údaje požiadavky. |\n| `callback` | `Function|String` | no |  | Funkcia alebo relatívna path. |\n\nReturns: `Plugin|Promise` Plugin, alebo `Promise`, keď nie je zadaný callback.\n\nMetóda volá `API()` a prijíma rovnaké tvary callbacku ako [`ajax()`](#ajax).\n\nExample: Použitie api()\n```js\nplugin.api('users_read', function(response) {\n    console.log(response);  // users_read\n});\n```\n\n### plugin.dapi(name, [data], [callback])\n\nType: `method`\n\nZavolá koncový bod DAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov koncového bodu. |\n| `data` | `Object` | no |  | Údaje požiadavky. |\n| `callback` | `Function|String` | no |  | Funkcia alebo relatívna path. |\n\nReturns: `Plugin|Promise` Plugin, alebo `Promise`, keď nie je zadaný callback.\n\nMetóda volá `DAPI()` a prijíma rovnaké tvary callbacku ako [`ajax()`](#ajax).\n\nExample: Použitie dapi()\n```js\nplugin.dapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.tapi(name, [data], [callback])\n\nType: `method`\n\nZavolá koncový bod TAPI.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov koncového bodu. |\n| `data` | `Object` | no |  | Údaje požiadavky. |\n| `callback` | `Function|String` | no |  | Funkcia alebo relatívna path. |\n\nReturns: `Plugin|Promise` Plugin, alebo `Promise`, keď nie je zadaný callback.\n\nMetóda volá `TAPI()` a prijíma rovnaké tvary callbacku ako [`ajax()`](#ajax).\n\nExample: Použitie tapi()\n```js\nplugin.tapi('users', function(response) {\n    console.log(response);  // users\n});\n```\n\n### plugin.upload(url, data, [callback])\n\nType: `method`\n\nNahrá údaje.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL. |\n| `data` | `FormData|Object` | yes |  | Dáta. |\n| `callback` | `Function|String` | no |  | Funkcia alebo relatívna path. |\n\nReturns: `Plugin|Promise` Plugin, alebo `Promise`, keď nie je zadaný callback.\n\nMetóda volá `UPLOAD()` a prijíma rovnaké tvary callbacku ako [`ajax()`](#ajax).\n\nExample: Použitie upload()\n```js\nplugin.upload('/upload/', new FormData(), function(response) {\n    console.log(response);  // /upload/\n});\n```\n\n### plugin.remove()\n\nType: `method`\n\nOdstráni plugin.\n\nReturns: `Boolean` Vždy `true`.\n\nSpustí sa delegate `destroy` a odstránia sa udalosti a sledovače zaregistrované počas deklarácie. Element na stránke zostane.\n\nExample: Použitie remove()\n```js\nconsole.log(plugin.remove(), PLUGINS.users === undefined);  // true true\n```\n","entries":[{"type":"delegate","name":"destroy","signature":"exports.destroy = function()","since":"","deprecated":false},{"type":"property","name":"name","signature":"plugin.name","since":"","deprecated":false},{"type":"property","name":"id","signature":"plugin.id","since":"","deprecated":false},{"type":"property","name":"element","signature":"plugin.element","since":"","deprecated":false},{"type":"property","name":"model","signature":"plugin.model","since":"","deprecated":false},{"type":"property","name":"data","signature":"plugin.data","since":"","deprecated":false},{"type":"property","name":"form","signature":"plugin.form","since":"","deprecated":false},{"type":"property","name":"modified","signature":"plugin.modified","since":"","deprecated":false},{"type":"property","name":"parent","signature":"plugin.parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"plugin.caller","since":"","deprecated":false},{"type":"method","name":"set()","signature":"plugin.set([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"get()","signature":"plugin.get([path])","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"plugin.nul(path, [type])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"plugin.push([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"extend()","signature":"plugin.extend([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"plugin.inc([path], value, [type])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"plugin.toggle(path, [type])","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"plugin.upd([path], [type])","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"plugin.reset([path])","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"plugin.watch(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"plugin.on(name, callback)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"plugin.exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"plugin.makepath([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"plugin.format([text])","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"plugin.scope([path])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"plugin.ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"api()","signature":"plugin.api(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"dapi()","signature":"plugin.dapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"plugin.tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"upload()","signature":"plugin.upload(url, data, [callback])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"plugin.remove()","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammmj3Sr61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-import/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"ui-import","summary":"The attributes and configuration keys of the ui-import element.","markdown":"---\ntitle: ui-import\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-import/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-import\n\n> The attributes and configuration keys of the ui-import element.\n\nThe `<ui-import>` element downloads HTML and inserts it into the page. The content can declare plugins and components, which are compiled after the insertion. [Importing content](../../guides/importing/) explains the concept.\n\n## API\n\n### path=\"url\"\n\nType: `property`\n\nSets the URL of the content.\n\nThe [`url`](#url) key has priority over this attribute. A URL with the prefix `once ` or `!` is imported only once in the page.\n\nExample: Importing a page\n```html\n<ui-import path=\"/users.html\"></ui-import>\n```\n\nExample: Importing only once\n```html\n<ui-import id=\"a\" path=\"once /users.html\"></ui-import>\n<ui-import id=\"b\" path=\"once /users.html\"></ui-import>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigures the import.\n\nThe value is a list of `key:value` pairs. The keys are listed on this page.\n\nExample: URL in the configuration\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCreates a scope directly on the element.\n\nThe value is the path of the scope.\n\nExample: A scope on the element\n```html\n<ui-import plugin=\"users\" path=\"/users.html\"></ui-import>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('b').scope().path), 500);  // users\n</script>\n```\n\n### url:url\n\nType: `config`\n\nSets the URL of the content.\n\nThe prefixes `once ` and `!` work as in the [`path`](#path) attribute.\n\nExample: Setting the URL\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### path:path\n\nType: `config`\n\nReplaces `~PATH~` and `CLASS` in the content.\n\nThe value also adds the path to `<ui-plugin>` elements without a path and to an anonymous `PLUGIN(function(...))` declaration, so one file can be imported several times.\n\nExample: Adapting the content\n```html\n<ui-import config=\"url:/part.html;path:users\"></ui-import>\n```\n\n### id:identifier\n\nType: `config`\n\nReplaces `~ID~` in the content.\n\nExample: Adapting the content\n```html\n<ui-import config=\"url:/part.html;id:box1\"></ui-import>\n```\n\n### cache:expiration\n\nType: `config`\n\nSets how long the response is cached.\n\nThe value is an expiration such as `5 minutes`, or `session`. The default value is `DEF.importcache`, which is `session`.\n\nExample: Caching for five minutes\n```html\n<ui-import config=\"url:/users.html;cache:5 minutes\"></ui-import>\n```\n\n### make:path\n\nType: `config`\n\nTransforms the content before the insertion.\n\nThe value is a path to a function or `plugin/method`. A `?` in the value is replaced with the `path` key. The function receives the response, the element and the `path` key, and returns the content to insert. When it returns nothing, nothing is inserted.\n\nExample: Changing the response\n```html\n<ui-import config=\"url:/users.html;make:common.prepare\"></ui-import>\n\n<script>\n    window.common = { prepare: response => response + '<u>Added</u>' };\n</script>\n```\n\n### init:path\n\nType: `config`\n\nCalls a function after the insertion.\n\nThe value is a path to a function or `plugin/method`. A `?` in the value is replaced with the `path` key. The function receives the element.\n\nExample: Running code after the insertion\n```html\n<ui-import config=\"url:/users.html;init:common.ready\"></ui-import>\n\n<script>\n    window.common = { ready: element => console.log(element.html()) };  // <b>Users</b>\n</script>\n```\n\n### target:selector\n\nType: `config`\n\nAppends the content to another element.\n\nThe value is a jQuery selector.\n\nExample: Inserting elsewhere\n```html\n<ui-import config=\"url:/users.html;target:#box\"></ui-import>\n<div id=\"box\"></div>\n```\n\n### replace:true\n\nType: `config`\n\nReplaces the element with the content.\n\nExample: Replacing the element\n```html\n<ui-import config=\"url:/users.html;replace:true\"></ui-import>\n```\n\n### reevaluate:true\n\nType: `config`\n\nRuns the scripts of the content on each import of the URL.\n\nWithout this key, the scripts run only the first time the URL is imported.\n\nExample: Running scripts repeatedly\n```html\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n\n<script>\n    setTimeout(() => console.log(window.counter), 700);  // 2\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"url\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:url","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:path","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:identifier","since":"","deprecated":false},{"type":"config","name":"cache","signature":"cache:expiration","since":"","deprecated":false},{"type":"config","name":"make","signature":"make:path","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"replace","signature":"replace:true","since":"","deprecated":false},{"type":"config","name":"reevaluate","signature":"reevaluate:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammmj3Sr61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-import/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"ui-import","summary":"Die Attribute und Konfigurationsschlüssel des Elements ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/ui-import/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-import\n\n> Die Attribute und Konfigurationsschlüssel des Elements ui-import.\n\nDas Element `<ui-import>` lädt HTML herunter und fügt es in die Seite ein. Der Inhalt kann Plugins und Komponenten deklarieren, die nach dem Einfügen kompiliert werden. [Inhalte importieren](../../guides/importing/) erklärt das Konzept.\n\n## API\n\n### path=\"url\"\n\nType: `property`\n\nLegt die URL des Inhalts fest.\n\nDer Schlüssel [`url`](#url) hat Vorrang vor diesem Attribut. Eine URL mit dem Präfix `once ` oder `!` wird nur einmal auf der Seite importiert.\n\nExample: Eine Seite importieren\n```html\n<ui-import path=\"/users.html\"></ui-import>\n```\n\nExample: Nur einmal importieren\n```html\n<ui-import id=\"a\" path=\"once /users.html\"></ui-import>\n<ui-import id=\"b\" path=\"once /users.html\"></ui-import>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nKonfiguriert den Import.\n\nDer Wert ist eine Liste von `key:value`-Paaren. Die Schlüssel sind auf dieser Seite aufgeführt.\n\nExample: URL in der Konfiguration\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nErstellt einen Scope direkt auf dem Element.\n\nDer Wert ist der Path des Scopes.\n\nExample: Ein Scope auf dem Element\n```html\n<ui-import plugin=\"users\" path=\"/users.html\"></ui-import>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('b').scope().path), 500);  // users\n</script>\n```\n\n### url:url\n\nType: `config`\n\nLegt die URL des Inhalts fest.\n\nDie Präfixe `once ` und `!` funktionieren wie beim Attribut [`path`](#path).\n\nExample: Die URL festlegen\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### path:path\n\nType: `config`\n\nErsetzt `~PATH~` und `CLASS` im Inhalt.\n\nDer Wert fügt den Path außerdem zu `<ui-plugin>`-Elementen ohne Path und zu einer anonymen Deklaration `PLUGIN(function(...))` hinzu, sodass sich eine Datei mehrfach importieren lässt.\n\nExample: Den Inhalt anpassen\n```html\n<ui-import config=\"url:/part.html;path:users\"></ui-import>\n```\n\n### id:identifier\n\nType: `config`\n\nErsetzt `~ID~` im Inhalt.\n\nExample: Den Inhalt anpassen\n```html\n<ui-import config=\"url:/part.html;id:box1\"></ui-import>\n```\n\n### cache:expiration\n\nType: `config`\n\nLegt fest, wie lange die Antwort zwischengespeichert wird.\n\nDer Wert ist eine Ablaufzeit wie `5 minutes` oder `session`. Der Standardwert ist `DEF.importcache`, also `session`.\n\nExample: Fünf Minuten zwischenspeichern\n```html\n<ui-import config=\"url:/users.html;cache:5 minutes\"></ui-import>\n```\n\n### make:path\n\nType: `config`\n\nWandelt den Inhalt vor dem Einfügen um.\n\nDer Wert ist ein Path zu einer Funktion oder `plugin/method`. Ein `?` im Wert wird durch den Schlüssel `path` ersetzt. Die Funktion erhält die Antwort, das Element und den Schlüssel `path` und gibt den einzufügenden Inhalt zurück. Gibt sie nichts zurück, wird nichts eingefügt.\n\nExample: Die Antwort ändern\n```html\n<ui-import config=\"url:/users.html;make:common.prepare\"></ui-import>\n\n<script>\n    window.common = { prepare: response => response + '<u>Added</u>' };\n</script>\n```\n\n### init:path\n\nType: `config`\n\nRuft nach dem Einfügen eine Funktion auf.\n\nDer Wert ist ein Path zu einer Funktion oder `plugin/method`. Ein `?` im Wert wird durch den Schlüssel `path` ersetzt. Die Funktion erhält das Element.\n\nExample: Code nach dem Einfügen ausführen\n```html\n<ui-import config=\"url:/users.html;init:common.ready\"></ui-import>\n\n<script>\n    window.common = { ready: element => console.log(element.html()) };  // <b>Users</b>\n</script>\n```\n\n### target:selector\n\nType: `config`\n\nHängt den Inhalt an ein anderes Element an.\n\nDer Wert ist ein jQuery-Selektor.\n\nExample: An anderer Stelle einfügen\n```html\n<ui-import config=\"url:/users.html;target:#box\"></ui-import>\n<div id=\"box\"></div>\n```\n\n### replace:true\n\nType: `config`\n\nErsetzt das Element durch den Inhalt.\n\nExample: Das Element ersetzen\n```html\n<ui-import config=\"url:/users.html;replace:true\"></ui-import>\n```\n\n### reevaluate:true\n\nType: `config`\n\nFührt die Skripte des Inhalts bei jedem Import der URL aus.\n\nOhne diesen Schlüssel laufen die Skripte nur beim ersten Import der URL.\n\nExample: Skripte wiederholt ausführen\n```html\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n\n<script>\n    setTimeout(() => console.log(window.counter), 700);  // 2\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"url\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:url","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:path","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:identifier","since":"","deprecated":false},{"type":"config","name":"cache","signature":"cache:expiration","since":"","deprecated":false},{"type":"config","name":"make","signature":"make:path","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"replace","signature":"replace:true","since":"","deprecated":false},{"type":"config","name":"reevaluate","signature":"reevaluate:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammmj3Sr61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-import/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/ui-import/\nupdated: 2026-11-18T13:58:29.465Z\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 HTML y lo inserta en la página. El contenido puede declarar plugins y componentes, que se compilan después de la inserción. En [Importar contenido](../../guides/importing/) se explica el concepto.\n\n## API\n\n### path=\"url\"\n\nType: `property`\n\nDefine la URL del contenido.\n\nLa clave [`url`](#url) tiene prioridad sobre este atributo. Una URL con el prefijo `once ` o `!` se importa una sola vez en la página.\n\nExample: Importar una página\n```html\n<ui-import path=\"/users.html\"></ui-import>\n```\n\nExample: Importar una sola vez\n```html\n<ui-import id=\"a\" path=\"once /users.html\"></ui-import>\n<ui-import id=\"b\" path=\"once /users.html\"></ui-import>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigura la importación.\n\nEl valor es una lista de pares `key:value`. Las claves aparecen en esta página.\n\nExample: URL en la configuración\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un scope directamente en el elemento.\n\nEl valor es el path del scope.\n\nExample: Un scope en el elemento\n```html\n<ui-import plugin=\"users\" path=\"/users.html\"></ui-import>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('b').scope().path), 500);  // users\n</script>\n```\n\n### url:url\n\nType: `config`\n\nDefine la URL del contenido.\n\nLos prefijos `once ` y `!` funcionan como en el atributo [`path`](#path).\n\nExample: Definir la URL\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### path:path\n\nType: `config`\n\nSustituye `~PATH~` y `CLASS` en el contenido.\n\nEl valor también añade el path a los elementos `<ui-plugin>` sin path y a una declaración anónima `PLUGIN(function(...))`, de modo que un mismo archivo se puede importar varias veces.\n\nExample: Adaptar el contenido\n```html\n<ui-import config=\"url:/part.html;path:users\"></ui-import>\n```\n\n### id:identifier\n\nType: `config`\n\nSustituye `~ID~` en el contenido.\n\nExample: Adaptar el contenido\n```html\n<ui-import config=\"url:/part.html;id:box1\"></ui-import>\n```\n\n### cache:expiration\n\nType: `config`\n\nDefine cuánto tiempo se guarda la respuesta en caché.\n\nEl valor es una caducidad como `5 minutes`, o `session`. El valor predeterminado es `DEF.importcache`, que es `session`.\n\nExample: Caché de cinco minutos\n```html\n<ui-import config=\"url:/users.html;cache:5 minutes\"></ui-import>\n```\n\n### make:path\n\nType: `config`\n\nTransforma el contenido antes de insertarlo.\n\nEl valor es un path a una función o `plugin/method`. Un `?` en el valor se sustituye por la clave `path`. La función recibe la respuesta, el elemento y la clave `path`, y devuelve el contenido que se va a insertar. Si no devuelve nada, no se inserta nada.\n\nExample: Cambiar la respuesta\n```html\n<ui-import config=\"url:/users.html;make:common.prepare\"></ui-import>\n\n<script>\n    window.common = { prepare: response => response + '<u>Added</u>' };\n</script>\n```\n\n### init:path\n\nType: `config`\n\nLlama a una función después de la inserción.\n\nEl valor es un path a una función o `plugin/method`. Un `?` en el valor se sustituye por la clave `path`. La función recibe el elemento.\n\nExample: Ejecutar código después de la inserción\n```html\n<ui-import config=\"url:/users.html;init:common.ready\"></ui-import>\n\n<script>\n    window.common = { ready: element => console.log(element.html()) };  // <b>Users</b>\n</script>\n```\n\n### target:selector\n\nType: `config`\n\nAñade el contenido al final de otro elemento.\n\nEl valor es un selector de jQuery.\n\nExample: Insertar en otro lugar\n```html\n<ui-import config=\"url:/users.html;target:#box\"></ui-import>\n<div id=\"box\"></div>\n```\n\n### replace:true\n\nType: `config`\n\nSustituye el elemento por el contenido.\n\nExample: Sustituir el elemento\n```html\n<ui-import config=\"url:/users.html;replace:true\"></ui-import>\n```\n\n### reevaluate:true\n\nType: `config`\n\nEjecuta los scripts del contenido cada vez que se importa la URL.\n\nSin esta clave, los scripts se ejecutan solo la primera vez que se importa la URL.\n\nExample: Ejecutar los scripts repetidamente\n```html\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n\n<script>\n    setTimeout(() => console.log(window.counter), 700);  // 2\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"url\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:url","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:path","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:identifier","since":"","deprecated":false},{"type":"config","name":"cache","signature":"cache:expiration","since":"","deprecated":false},{"type":"config","name":"make","signature":"make:path","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"replace","signature":"replace:true","since":"","deprecated":false},{"type":"config","name":"reevaluate","signature":"reevaluate:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammmj3Sr61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-import/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/ui-import/\nupdated: 2026-11-18T13:58:29.465Z\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 HTML et l'insère dans la page. Le contenu peut déclarer des plugins et des composants, qui sont compilés après l'insertion. [Importer du contenu](../../guides/importing/) explique le concept.\n\n## API\n\n### path=\"url\"\n\nType: `property`\n\nDéfinit l'URL du contenu.\n\nLa clé [`url`](#url) a la priorité sur cet attribut. Une URL avec le préfixe `once ` ou `!` n'est importée qu'une seule fois dans la page.\n\nExample: Importer une page\n```html\n<ui-import path=\"/users.html\"></ui-import>\n```\n\nExample: Importer une seule fois\n```html\n<ui-import id=\"a\" path=\"once /users.html\"></ui-import>\n<ui-import id=\"b\" path=\"once /users.html\"></ui-import>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigure l'importation.\n\nLa valeur est une liste de paires `key:value`. Les clés sont listées sur cette page.\n\nExample: L'URL dans la configuration\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrée un scope directement sur l'élément.\n\nLa valeur est le path du scope.\n\nExample: Un scope sur l'élément\n```html\n<ui-import plugin=\"users\" path=\"/users.html\"></ui-import>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('b').scope().path), 500);  // users\n</script>\n```\n\n### url:url\n\nType: `config`\n\nDéfinit l'URL du contenu.\n\nLes préfixes `once ` et `!` fonctionnent comme dans l'attribut [`path`](#path).\n\nExample: Définir l'URL\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### path:path\n\nType: `config`\n\nRemplace `~PATH~` et `CLASS` dans le contenu.\n\nLa valeur ajoute aussi le path aux éléments `<ui-plugin>` sans path et à une déclaration anonyme `PLUGIN(function(...))`, ce qui permet d'importer plusieurs fois un même fichier.\n\nExample: Adapter le contenu\n```html\n<ui-import config=\"url:/part.html;path:users\"></ui-import>\n```\n\n### id:identifier\n\nType: `config`\n\nRemplace `~ID~` dans le contenu.\n\nExample: Adapter le contenu\n```html\n<ui-import config=\"url:/part.html;id:box1\"></ui-import>\n```\n\n### cache:expiration\n\nType: `config`\n\nDéfinit la durée de mise en cache de la réponse.\n\nLa valeur est une expiration comme `5 minutes`, ou `session`. La valeur par défaut est `DEF.importcache`, qui vaut `session`.\n\nExample: Mettre en cache pendant cinq minutes\n```html\n<ui-import config=\"url:/users.html;cache:5 minutes\"></ui-import>\n```\n\n### make:path\n\nType: `config`\n\nTransforme le contenu avant l'insertion.\n\nLa valeur est un path vers une fonction ou `plugin/method`. Un `?` dans la valeur est remplacé par la clé `path`. La fonction reçoit la réponse, l'élément et la clé `path`, et renvoie le contenu à insérer. Si elle ne renvoie rien, rien n'est inséré.\n\nExample: Modifier la réponse\n```html\n<ui-import config=\"url:/users.html;make:common.prepare\"></ui-import>\n\n<script>\n    window.common = { prepare: response => response + '<u>Added</u>' };\n</script>\n```\n\n### init:path\n\nType: `config`\n\nAppelle une fonction après l'insertion.\n\nLa valeur est un path vers une fonction ou `plugin/method`. Un `?` dans la valeur est remplacé par la clé `path`. La fonction reçoit l'élément.\n\nExample: Exécuter du code après l'insertion\n```html\n<ui-import config=\"url:/users.html;init:common.ready\"></ui-import>\n\n<script>\n    window.common = { ready: element => console.log(element.html()) };  // <b>Users</b>\n</script>\n```\n\n### target:selector\n\nType: `config`\n\nAjoute le contenu à la fin d'un autre élément.\n\nLa valeur est un sélecteur jQuery.\n\nExample: Insérer ailleurs\n```html\n<ui-import config=\"url:/users.html;target:#box\"></ui-import>\n<div id=\"box\"></div>\n```\n\n### replace:true\n\nType: `config`\n\nRemplace l'élément par le contenu.\n\nExample: Remplacer l'élément\n```html\n<ui-import config=\"url:/users.html;replace:true\"></ui-import>\n```\n\n### reevaluate:true\n\nType: `config`\n\nExécute les scripts du contenu à chaque importation de l'URL.\n\nSans cette clé, les scripts ne s'exécutent que la première fois que l'URL est importée.\n\nExample: Exécuter les scripts à chaque fois\n```html\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n\n<script>\n    setTimeout(() => console.log(window.counter), 700);  // 2\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"url\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:url","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:path","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:identifier","since":"","deprecated":false},{"type":"config","name":"cache","signature":"cache:expiration","since":"","deprecated":false},{"type":"config","name":"make","signature":"make:path","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"replace","signature":"replace:true","since":"","deprecated":false},{"type":"config","name":"reevaluate","signature":"reevaluate:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammmj3Sr61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-import/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/ui-import/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-import\n\n> Gli attributi e le chiavi di configurazione dell'elemento ui-import.\n\nL'elemento `<ui-import>` scarica HTML e lo inserisce nella pagina. Il contenuto può dichiarare plugin e componenti, che vengono compilati dopo l'inserimento. [Importazione dei contenuti](../../guides/importing/) spiega il concetto.\n\n## API\n\n### path=\"url\"\n\nType: `property`\n\nImposta l'URL del contenuto.\n\nLa chiave [`url`](#url) ha la priorità su questo attributo. Un URL con il prefisso `once ` o `!` viene importato una sola volta nella pagina.\n\nExample: Importare una pagina\n```html\n<ui-import path=\"/users.html\"></ui-import>\n```\n\nExample: Importare una sola volta\n```html\n<ui-import id=\"a\" path=\"once /users.html\"></ui-import>\n<ui-import id=\"b\" path=\"once /users.html\"></ui-import>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nConfigura l'importazione.\n\nIl valore è un elenco di coppie `key:value`. Le chiavi sono elencate in questa pagina.\n\nExample: URL nella configurazione\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea uno scope direttamente sull'elemento.\n\nIl valore è il path dello scope.\n\nExample: Uno scope sull'elemento\n```html\n<ui-import plugin=\"users\" path=\"/users.html\"></ui-import>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('b').scope().path), 500);  // users\n</script>\n```\n\n### url:url\n\nType: `config`\n\nImposta l'URL del contenuto.\n\nI prefissi `once ` e `!` funzionano come nell'attributo [`path`](#path).\n\nExample: Impostare l'URL\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### path:path\n\nType: `config`\n\nSostituisce `~PATH~` e `CLASS` nel contenuto.\n\nIl valore aggiunge anche il path agli elementi `<ui-plugin>` senza path e a una dichiarazione anonima `PLUGIN(function(...))`, così puoi importare più volte lo stesso file.\n\nExample: Adattare il contenuto\n```html\n<ui-import config=\"url:/part.html;path:users\"></ui-import>\n```\n\n### id:identifier\n\nType: `config`\n\nSostituisce `~ID~` nel contenuto.\n\nExample: Adattare il contenuto\n```html\n<ui-import config=\"url:/part.html;id:box1\"></ui-import>\n```\n\n### cache:expiration\n\nType: `config`\n\nImposta per quanto tempo la risposta resta in cache.\n\nIl valore è una scadenza come `5 minutes`, oppure `session`. Il valore predefinito è `DEF.importcache`, cioè `session`.\n\nExample: Cache per cinque minuti\n```html\n<ui-import config=\"url:/users.html;cache:5 minutes\"></ui-import>\n```\n\n### make:path\n\nType: `config`\n\nTrasforma il contenuto prima dell'inserimento.\n\nIl valore è un path verso una funzione oppure `plugin/method`. Un `?` nel valore viene sostituito con la chiave `path`. La funzione riceve la risposta, l'elemento e la chiave `path`, e restituisce il contenuto da inserire. Se non restituisce nulla, non viene inserito nulla.\n\nExample: Modificare la risposta\n```html\n<ui-import config=\"url:/users.html;make:common.prepare\"></ui-import>\n\n<script>\n    window.common = { prepare: response => response + '<u>Added</u>' };\n</script>\n```\n\n### init:path\n\nType: `config`\n\nChiama una funzione dopo l'inserimento.\n\nIl valore è un path verso una funzione oppure `plugin/method`. Un `?` nel valore viene sostituito con la chiave `path`. La funzione riceve l'elemento.\n\nExample: Eseguire codice dopo l'inserimento\n```html\n<ui-import config=\"url:/users.html;init:common.ready\"></ui-import>\n\n<script>\n    window.common = { ready: element => console.log(element.html()) };  // <b>Users</b>\n</script>\n```\n\n### target:selector\n\nType: `config`\n\nAggiunge il contenuto a un altro elemento.\n\nIl valore è un selettore jQuery.\n\nExample: Inserire altrove\n```html\n<ui-import config=\"url:/users.html;target:#box\"></ui-import>\n<div id=\"box\"></div>\n```\n\n### replace:true\n\nType: `config`\n\nSostituisce l'elemento con il contenuto.\n\nExample: Sostituire l'elemento\n```html\n<ui-import config=\"url:/users.html;replace:true\"></ui-import>\n```\n\n### reevaluate:true\n\nType: `config`\n\nEsegue gli script del contenuto a ogni importazione dell'URL.\n\nSenza questa chiave, gli script vengono eseguiti solo la prima volta che l'URL viene importato.\n\nExample: Eseguire gli script più volte\n```html\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n\n<script>\n    setTimeout(() => console.log(window.counter), 700);  // 2\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"url\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:url","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:path","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:identifier","since":"","deprecated":false},{"type":"config","name":"cache","signature":"cache:expiration","since":"","deprecated":false},{"type":"config","name":"make","signature":"make:path","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"replace","signature":"replace:true","since":"","deprecated":false},{"type":"config","name":"reevaluate","signature":"reevaluate:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammmj3Sr61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-import/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"ui-import","summary":"Atribúty a konfiguračné kľúče elementu ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/ui-import/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# ui-import\n\n> Atribúty a konfiguračné kľúče elementu ui-import.\n\nElement `<ui-import>` stiahne HTML a vloží ho do stránky. Obsah môže deklarovať pluginy a komponenty, ktoré sa po vložení skompilujú. Koncept vysvetľuje časť [Import obsahu](../../guides/importing/).\n\n## API\n\n### path=\"url\"\n\nType: `property`\n\nNastaví URL obsahu.\n\nKľúč [`url`](#url) má prednosť pred týmto atribútom. URL s predponou `once ` alebo `!` sa na stránke importuje iba raz.\n\nExample: Import stránky\n```html\n<ui-import path=\"/users.html\"></ui-import>\n```\n\nExample: Import iba raz\n```html\n<ui-import id=\"a\" path=\"once /users.html\"></ui-import>\n<ui-import id=\"b\" path=\"once /users.html\"></ui-import>\n```\n\n### config=\"key:value\"\n\nType: `property`\n\nKonfiguruje import.\n\nHodnota je zoznam dvojíc `key:value`. Kľúče sú uvedené na tejto stránke.\n\nExample: URL v konfigurácii\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nVytvorí scope priamo na elemente.\n\nHodnota je path scopu.\n\nExample: Scope na elemente\n```html\n<ui-import plugin=\"users\" path=\"/users.html\"></ui-import>\n\n<script>\n    PLUGIN('users', function(exports) {});\n    setTimeout(() => console.log($('b').scope().path), 500);  // users\n</script>\n```\n\n### url:url\n\nType: `config`\n\nNastaví URL obsahu.\n\nPredpony `once ` a `!` fungujú rovnako ako v atribúte [`path`](#path).\n\nExample: Nastavenie URL\n```html\n<ui-import config=\"url:/users.html\"></ui-import>\n```\n\n### path:path\n\nType: `config`\n\nNahradí `~PATH~` a `CLASS` v obsahu.\n\nHodnota tiež pridá path k elementom `<ui-plugin>` bez path a k anonymnej deklarácii `PLUGIN(function(...))`, takže jeden súbor môžeš importovať viackrát.\n\nExample: Prispôsobenie obsahu\n```html\n<ui-import config=\"url:/part.html;path:users\"></ui-import>\n```\n\n### id:identifier\n\nType: `config`\n\nNahradí `~ID~` v obsahu.\n\nExample: Prispôsobenie obsahu\n```html\n<ui-import config=\"url:/part.html;id:box1\"></ui-import>\n```\n\n### cache:expiration\n\nType: `config`\n\nNastaví, ako dlho sa odpoveď uchováva vo vyrovnávacej pamäti.\n\nHodnota je čas vypršania, napríklad `5 minutes`, alebo `session`. Predvolená hodnota je `DEF.importcache`, čo je `session`.\n\nExample: Uchovanie vo vyrovnávacej pamäti na päť minút\n```html\n<ui-import config=\"url:/users.html;cache:5 minutes\"></ui-import>\n```\n\n### make:path\n\nType: `config`\n\nTransformuje obsah pred vložením.\n\nHodnota je path k funkcii alebo `plugin/method`. Znak `?` v hodnote sa nahradí kľúčom `path`. Funkcia dostane odpoveď, element a kľúč `path` a vráti obsah na vloženie. Keď nevráti nič, nič sa nevloží.\n\nExample: Zmena odpovede\n```html\n<ui-import config=\"url:/users.html;make:common.prepare\"></ui-import>\n\n<script>\n    window.common = { prepare: response => response + '<u>Added</u>' };\n</script>\n```\n\n### init:path\n\nType: `config`\n\nZavolá funkciu po vložení.\n\nHodnota je path k funkcii alebo `plugin/method`. Znak `?` v hodnote sa nahradí kľúčom `path`. Funkcia dostane element.\n\nExample: Spustenie kódu po vložení\n```html\n<ui-import config=\"url:/users.html;init:common.ready\"></ui-import>\n\n<script>\n    window.common = { ready: element => console.log(element.html()) };  // <b>Users</b>\n</script>\n```\n\n### target:selector\n\nType: `config`\n\nPripojí obsah k inému elementu.\n\nHodnota je selektor jQuery.\n\nExample: Vloženie na iné miesto\n```html\n<ui-import config=\"url:/users.html;target:#box\"></ui-import>\n<div id=\"box\"></div>\n```\n\n### replace:true\n\nType: `config`\n\nNahradí element obsahom.\n\nExample: Nahradenie elementu\n```html\n<ui-import config=\"url:/users.html;replace:true\"></ui-import>\n```\n\n### reevaluate:true\n\nType: `config`\n\nSpustí skripty obsahu pri každom importe URL.\n\nBez tohto kľúča sa skripty spustia iba pri prvom importe URL.\n\nExample: Opakované spúšťanie skriptov\n```html\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n<ui-import config=\"url:/script.html;reevaluate:true\"></ui-import>\n\n<script>\n    setTimeout(() => console.log(window.counter), 700);  // 2\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"url\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:url","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:path","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:identifier","since":"","deprecated":false},{"type":"config","name":"cache","signature":"cache:expiration","since":"","deprecated":false},{"type":"config","name":"make","signature":"make:path","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"replace","signature":"replace:true","since":"","deprecated":false},{"type":"config","name":"reevaluate","signature":"reevaluate:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammjpBgj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/tangular-helpers/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Tangular helpers","summary":"The helpers available in Tangular templates for encoding, formatting and reading code lists.","markdown":"---\ntitle: Tangular helpers\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Tangular helpers\n\n> The helpers available in Tangular templates for encoding, formatting and reading code lists.\n\nA helper transforms a value in a template: `{{ value | helper(arguments) }}`. These helpers live in the global object `Thelpers`, so they can also be called from code with the value as the first argument. A value without a helper is HTML-encoded automatically; a value with a helper is written as the helper returns it. [Templates with Tangular](../../guides/tangular/) explains the syntax and how to add your own helpers.\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nWrites a value of the code list item with the given identifier.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `key` | `String` | no | `'name'` | The field to write. |\n\nReturns: `String` The value of the item.\n\nThe code list is read from `DEF.cl[name]`, and its items are matched by the field `id`. Without `key`, the helper writes the field `name`, or `DEF.empty` when the item does not exist. With `key`, a missing item writes an empty text. The output is not HTML-encoded.\n\nExample: Read a code list\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | cl(\"colors\") }}'.render({ id: 1 }); // \"Red\"\n'{{ id | cl(\"colors\", \"color\") }}'.render({ id: 1 }); // \"#f00\"\n'{{ id | cl(\"colors\") }}'.render({ id: 9 }); // \"---\"\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nWrites a code list item as a colored `<span>`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `key` | `String` | no | `'name'` | The field to write. |\n\nReturns: `String` The HTML of the item.\n\nThe element has the class `ui-clcolor`. The `color` field of the item sets its background and the `icon` field adds an icon. A missing item writes an empty text. The output is not HTML-encoded.\n\nExample: A colored label\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clcolor(\"colors\") }}'.render({ id: 1 }); // \"<span class=\\\"ui-clcolor\\\" style=\\\"background:#f00\\\"><i class=\\\"ti ti-circle mr5\\\"></i>Red</span>\"\n'{{ id | clcolor(\"colors\") }}'.render({ id: 2 }); // \"<span class=\\\"ui-clcolor\\\">Blue</span>\"\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nWrites a code list item with its icon.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `key` | `String` | no | `'name'` | The field to write. |\n\nReturns: `String` The HTML of the item.\n\nThe `icon` field adds an `<i>` element, and the `color` field sets the color of the icon. A missing item writes an empty text. The output is not HTML-encoded.\n\nExample: An item with an icon\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clicon(\"colors\") }}'.render({ id: 1 }); // \"<i class=\\\"ti ti-circle mr5\\\" style=\\\"color:#f00\\\"></i>Red\"\n'{{ id | clicon(\"colors\") }}'.render({ id: 2 }); // \"Blue\"\n```\n\n### {{ value | currency([code]) }}\n\nType: `method`\n\nFormats a number or a numeric text as a currency.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | no |  | The currency code registered in `DEF.currencies`. |\n\nReturns: `String` The formatted amount.\n\nThe helper calls [currency()](../number/#currency). Values that are not numbers or texts write an empty text.\n\nExample: Write an amount\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\n\n'{{ price | currency(\"eur\") }}'.render({ price: 1234.5 }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: '1234,5' }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: null }); // \"\"\n```\n\n### {{ value | def([text]) }}\n\nType: `method`\n\nWrites the value, or a replacement when the value is empty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | The replacement text. |\n\nReturns: `String` The encoded value or the replacement.\n\nEvery falsy value counts as empty, including `0`. The value is HTML-encoded. The replacement defaults to `DEF.empty`, which is `---`. `empty` is another name for this helper.\n\nExample: Replace an empty value\n```js\n'{{ name | def }}'.render({ name: '' }); // \"---\"\n'{{ name | def(\"unknown\") }}'.render({}); // \"unknown\"\n'{{ name | def }}'.render({ name: '<b>' }); // \"&lt;b&gt;\"\n'{{ count | def }}'.render({ count: 0 }); // \"---\"\n```\n\n### {{ value | empty([text]) }}\n\nType: `method`\n\nAnother name for the helper [def](#def).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | The replacement text. |\n\nReturns: `String` The encoded value or the replacement.\n\nExample: Replace an empty value\n```js\n'{{ name | empty }}'.render({}); // \"---\"\n'{{ name | empty(\"n/a\") }}'.render({ name: 'Ann' }); // \"Ann\"\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nEncodes the value for HTML, JSON or a URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String or Function` | no |  | The type of encoding. |\n\nReturns: `String` The encoded value.\n\nWithout `type`, the characters `<`, `>`, `&` and `\"` are written as HTML entities and `null` or `undefined` writes an empty text.\n\n| Type | Output |\n| --- | --- |\n| `'json'` | JSON |\n| `'json2'` | JSON indented with tabs |\n| `'url'`, `'urlencoded'` | A URL-encoded value |\n| `'querify'` | A query string built with `QUERIFY()` |\n| Function | The result of `function(value)` |\n\nExample: Encoding types\n```js\n'{{ value | encode }}'.render({ value: '<b>' }); // \"&lt;b&gt;\"\n'{{ value | encode(\"json\") }}'.render({ value: { id: 1 } }); // \"{\\\"id\\\":1}\"\n'{{ value | encode(\"url\") }}'.render({ value: 'a b&c' }); // \"a%20b%26c\"\n'{{ value | encode(\"querify\") }}'.render({ value: { page: 1, q: 'x y' } }); // \"?page=1&q=x%20y\"\n```\n\n### {{ value | format([format], [a], [b]) }}\n\nType: `method`\n\nFormats a number, a date or a text that holds one of them.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | The number of decimals, or the date format. |\n| `a` | `Object` | no |  | The thousands separator for numbers, or `utc` for dates. |\n| `b` | `String` | no |  | The decimal separator for numbers. |\n\nReturns: `String` The formatted value.\n\nThe arguments depend on the value:\n\n| Value | Arguments | Result |\n| --- | --- | --- |\n| Number | `decimals`, `separator`, `decimalSeparator` | [Number format()](../number/#format). Without `decimals`, no decimals are written. |\n| Date | `format`, `utc` | [Date format()](../date/#format) |\n| Text with a date | `format` | The date, by default as `dd.MM.yyyy` |\n| Numeric text | `decimals`, `separator`, `decimalSeparator` | The number, which keeps its decimals when `decimals` is missing |\n\nA text counts as a date when it contains a colon, a space, the letter `T`, or more than one `-` or `.`. `null` and `undefined` write an empty text.\n\nExample: Numbers\n```js\n'{{ price | format(2) }}'.render({ price: 1234.5 }); // \"1 234.50\"\n'{{ price | format }}'.render({ price: 1234.5 }); // \"1 234\"\n'{{ price | format(2, \",\", \".\") }}'.render({ price: 1234.5 }); // \"1,234.50\"\n```\n\nExample: Dates\n```js\nvar date = new Date(2026, 10, 18);\n\n'{{ date | format(\"dd.MM.yyyy\") }}'.render({ date: date }); // \"18.11.2026\"\n'{{ date | format }}'.render({ date: date }); // \"2026-11-18\"\n```\n\nExample: Text values\n```js\nThelpers.format('2026-11-18'); // \"18.11.2026\"\nThelpers.format('2026-11-18', 'yyyy/MM'); // \"2026/11\"\nThelpers.format('1234.5'); // \"1 234.5\"\nThelpers.format('1234,5', 2); // \"1 234.50\"\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nChooses a text by the size of a number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | The text for 0, or all four forms. |\n| `one` | `String` | yes |  | The text for 1. |\n| `few` | `String` | yes |  | The text for numbers greater than 1 and lower than 5. |\n| `other` | `String` | yes |  | The text for all other numbers. |\n\nReturns: `String` The chosen text.\n\nThe helper calls [pluralize()](../number/#pluralize). A text value is converted to a number first; spaces are removed and a comma is read as a decimal separator.\n\nExample: Choose a form\n```js\nvar template = '{{ count | pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}';\n\ntemplate.render({ count: 0 }); // \"no items\"\ntemplate.render({ count: 1 }); // \"1 item\"\ntemplate.render({ count: 7 }); // \"7 items\"\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nWrites the value without HTML encoding.\n\nReturns: `Object` The unchanged value.\n\nUse this helper only with trusted content.\n\nExample: Write HTML\n```js\n'{{ html | raw }}'.render({ html: '<b>Hello</b>' }); // \"<b>Hello</b>\"\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([code]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [a], [b]) }}","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:29.465Z"}
{"id":"JammjpBgj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/tangular-helpers/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Tangular-Helper","summary":"Die in Tangular-Templates verfügbaren Helper zum Kodieren, Formatieren und Lesen von Codelisten.","markdown":"---\ntitle: Tangular-Helper\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Tangular-Helper\n\n> Die in Tangular-Templates verfügbaren Helper zum Kodieren, Formatieren und Lesen von Codelisten.\n\nEin Helper wandelt einen Wert in einem Template um: `{{ value | helper(arguments) }}`. Diese Helper liegen im globalen Objekt `Thelpers`, sodass du sie auch aus dem Code mit dem Wert als erstem Argument aufrufen kannst. Ein Wert ohne Helper wird automatisch HTML-kodiert; ein Wert mit Helper wird so geschrieben, wie der Helper ihn zurückgibt. [Templates mit Tangular](../../guides/tangular/) erklärt die Syntax und wie du eigene Helper hinzufügst.\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nSchreibt einen Wert des Codelisten-Eintrags mit der angegebenen Kennung.\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 Eintrags.\n\nDie Codeliste wird aus `DEF.cl[name]` gelesen, und ihre Einträge werden über das Feld `id` zugeordnet. Ohne `key` schreibt der Helper das Feld `name` oder, wenn der Eintrag nicht existiert, `DEF.empty`. Mit `key` schreibt ein fehlender Eintrag einen leeren Text. Die Ausgabe wird nicht HTML-kodiert.\n\nExample: Eine Codeliste lesen\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | cl(\"colors\") }}'.render({ id: 1 }); // \"Red\"\n'{{ id | cl(\"colors\", \"color\") }}'.render({ id: 1 }); // \"#f00\"\n'{{ id | cl(\"colors\") }}'.render({ id: 9 }); // \"---\"\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nSchreibt einen Codelisten-Eintrag als farbiges `<span>`.\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 Element hat die Klasse `ui-clcolor`. Das Feld `color` des Eintrags legt seinen Hintergrund fest und das Feld `icon` fügt ein Icon hinzu. Ein fehlender Eintrag schreibt einen leeren Text. Die Ausgabe wird nicht HTML-kodiert.\n\nExample: Ein farbiges Label\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clcolor(\"colors\") }}'.render({ id: 1 }); // \"<span class=\\\"ui-clcolor\\\" style=\\\"background:#f00\\\"><i class=\\\"ti ti-circle mr5\\\"></i>Red</span>\"\n'{{ id | clcolor(\"colors\") }}'.render({ id: 2 }); // \"<span class=\\\"ui-clcolor\\\">Blue</span>\"\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nSchreibt einen Codelisten-Eintrag 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 Feld `icon` fügt ein `<i>`-Element hinzu und das Feld `color` legt die Farbe des Icons fest. Ein fehlender Eintrag schreibt einen leeren Text. Die Ausgabe wird nicht HTML-kodiert.\n\nExample: Ein Eintrag mit Icon\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clicon(\"colors\") }}'.render({ id: 1 }); // \"<i class=\\\"ti ti-circle mr5\\\" style=\\\"color:#f00\\\"></i>Red\"\n'{{ id | clicon(\"colors\") }}'.render({ id: 2 }); // \"Blue\"\n```\n\n### {{ value | currency([code]) }}\n\nType: `method`\n\nFormatiert eine Zahl oder einen numerischen Text als Währung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | no |  | Der in `DEF.currencies` registrierte Währungscode. |\n\nReturns: `String` Der formatierte Betrag.\n\nDer Helper ruft [currency()](../number/#currency) auf. Werte, die weder Zahlen noch Texte sind, schreiben einen leeren Text.\n\nExample: Einen Betrag schreiben\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\n\n'{{ price | currency(\"eur\") }}'.render({ price: 1234.5 }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: '1234,5' }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: null }); // \"\"\n```\n\n### {{ value | def([text]) }}\n\nType: `method`\n\nSchreibt den Wert oder, wenn der Wert leer ist, einen Ersatz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Der Ersatztext. |\n\nReturns: `String` Der kodierte Wert oder der Ersatz.\n\nJeder falsy Wert gilt als leer, auch `0`. Der Wert wird HTML-kodiert. Der Ersatz ist standardmäßig `DEF.empty`, also `---`. `empty` ist ein anderer Name für diesen Helper.\n\nExample: Einen leeren Wert ersetzen\n```js\n'{{ name | def }}'.render({ name: '' }); // \"---\"\n'{{ name | def(\"unknown\") }}'.render({}); // \"unknown\"\n'{{ name | def }}'.render({ name: '<b>' }); // \"&lt;b&gt;\"\n'{{ count | def }}'.render({ count: 0 }); // \"---\"\n```\n\n### {{ value | empty([text]) }}\n\nType: `method`\n\nEin anderer Name für den Helper [def](#def).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Der Ersatztext. |\n\nReturns: `String` Der kodierte Wert oder der Ersatz.\n\nExample: Einen leeren Wert ersetzen\n```js\n'{{ name | empty }}'.render({}); // \"---\"\n'{{ name | empty(\"n/a\") }}'.render({ name: 'Ann' }); // \"Ann\"\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nKodiert den Wert für HTML, JSON oder eine URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String or Function` | no |  | Die Art der Kodierung. |\n\nReturns: `String` Der kodierte Wert.\n\nOhne `type` werden die Zeichen `<`, `>`, `&` und `\"` als HTML-Entitäten geschrieben, und `null` oder `undefined` schreibt einen leeren Text.\n\n| Typ | Ausgabe |\n| --- | --- |\n| `'json'` | JSON |\n| `'json2'` | Mit Tabs eingerücktes JSON |\n| `'url'`, `'urlencoded'` | Ein URL-kodierter Wert |\n| `'querify'` | Ein mit `QUERIFY()` erstellter Query-String |\n| Funktion | Das Ergebnis von `function(value)` |\n\nExample: Kodierungsarten\n```js\n'{{ value | encode }}'.render({ value: '<b>' }); // \"&lt;b&gt;\"\n'{{ value | encode(\"json\") }}'.render({ value: { id: 1 } }); // \"{\\\"id\\\":1}\"\n'{{ value | encode(\"url\") }}'.render({ value: 'a b&c' }); // \"a%20b%26c\"\n'{{ value | encode(\"querify\") }}'.render({ value: { page: 1, q: 'x y' } }); // \"?page=1&q=x%20y\"\n```\n\n### {{ value | format([format], [a], [b]) }}\n\nType: `method`\n\nFormatiert eine Zahl, ein Datum oder einen Text, der eines von beiden enthält.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Die Anzahl der Dezimalstellen oder das Datumsformat. |\n| `a` | `Object` | no |  | Das Tausendertrennzeichen für Zahlen oder `utc` für Datumswerte. |\n| `b` | `String` | no |  | Das Dezimaltrennzeichen für Zahlen. |\n\nReturns: `String` Der formatierte Wert.\n\nDie Argumente hängen vom Wert ab:\n\n| Wert | Argumente | Ergebnis |\n| --- | --- | --- |\n| Zahl | `decimals`, `separator`, `decimalSeparator` | [Number format()](../number/#format). Ohne `decimals` werden keine Dezimalstellen geschrieben. |\n| Datum | `format`, `utc` | [Date format()](../date/#format) |\n| Text mit einem Datum | `format` | Das Datum, standardmäßig als `dd.MM.yyyy` |\n| Numerischer Text | `decimals`, `separator`, `decimalSeparator` | Die Zahl, die ihre Dezimalstellen behält, wenn `decimals` fehlt |\n\nEin Text gilt als Datum, wenn er einen Doppelpunkt, ein Leerzeichen, den Buchstaben `T` oder mehr als ein `-` oder `.` enthält. `null` und `undefined` schreiben einen leeren Text.\n\nExample: Zahlen\n```js\n'{{ price | format(2) }}'.render({ price: 1234.5 }); // \"1 234.50\"\n'{{ price | format }}'.render({ price: 1234.5 }); // \"1 234\"\n'{{ price | format(2, \",\", \".\") }}'.render({ price: 1234.5 }); // \"1,234.50\"\n```\n\nExample: Datumswerte\n```js\nvar date = new Date(2026, 10, 18);\n\n'{{ date | format(\"dd.MM.yyyy\") }}'.render({ date: date }); // \"18.11.2026\"\n'{{ date | format }}'.render({ date: date }); // \"2026-11-18\"\n```\n\nExample: Textwerte\n```js\nThelpers.format('2026-11-18'); // \"18.11.2026\"\nThelpers.format('2026-11-18', 'yyyy/MM'); // \"2026/11\"\nThelpers.format('1234.5'); // \"1 234.5\"\nThelpers.format('1234,5', 2); // \"1 234.50\"\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nWählt einen Text anhand der Größe einer Zahl aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Der Text für 0 oder alle vier Formen. |\n| `one` | `String` | yes |  | Der Text für 1. |\n| `few` | `String` | yes |  | Der Text für Zahlen größer als 1 und kleiner als 5. |\n| `other` | `String` | yes |  | Der Text für alle anderen Zahlen. |\n\nReturns: `String` Der ausgewählte Text.\n\nDer Helper ruft [pluralize()](../number/#pluralize) auf. Ein Textwert wird zuerst in eine Zahl umgewandelt; Leerzeichen werden entfernt und ein Komma wird als Dezimaltrennzeichen gelesen.\n\nExample: Eine Form auswählen\n```js\nvar template = '{{ count | pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}';\n\ntemplate.render({ count: 0 }); // \"no items\"\ntemplate.render({ count: 1 }); // \"1 item\"\ntemplate.render({ count: 7 }); // \"7 items\"\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nSchreibt den Wert ohne HTML-Kodierung.\n\nReturns: `Object` Der unveränderte Wert.\n\nVerwende diesen Helper nur mit vertrauenswürdigen Inhalten.\n\nExample: HTML schreiben\n```js\n'{{ html | raw }}'.render({ html: '<b>Hello</b>' }); // \"<b>Hello</b>\"\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([code]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [a], [b]) }}","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:29.465Z"}
{"id":"JammjpBgj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/tangular-helpers/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Helpers de Tangular","summary":"Los helpers disponibles en las plantillas de Tangular para codificar, dar formato y leer listas de códigos.","markdown":"---\ntitle: Helpers de Tangular\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Helpers de Tangular\n\n> Los helpers disponibles en las plantillas de Tangular para codificar, dar formato y leer listas de códigos.\n\nUn helper transforma un valor en una plantilla: `{{ value | helper(arguments) }}`. Estos helpers están en el objeto global `Thelpers`, así que también puedes llamarlos desde el código pasando el valor como primer argumento. Un valor sin helper se codifica en HTML automáticamente; un valor con helper se escribe tal como lo devuelve el helper. En [Plantillas con Tangular](../../guides/tangular/) se explica la sintaxis y cómo añadir tus propios helpers.\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nEscribe un valor del ítem de la lista de códigos que tiene el identificador indicado.\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 ítem.\n\nLa lista de códigos se lee de `DEF.cl[name]`, y sus ítems se buscan por el campo `id`. Sin `key`, el helper escribe el campo `name`, o `DEF.empty` cuando el ítem no existe. Con `key`, un ítem que no existe escribe un texto vacío. La salida no se codifica en HTML.\n\nExample: Leer una lista de códigos\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | cl(\"colors\") }}'.render({ id: 1 }); // \"Red\"\n'{{ id | cl(\"colors\", \"color\") }}'.render({ id: 1 }); // \"#f00\"\n'{{ id | cl(\"colors\") }}'.render({ id: 9 }); // \"---\"\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nEscribe un ítem de una lista de códigos como un `<span>` 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 del elemento.\n\nEl elemento tiene la clase `ui-clcolor`. El campo `color` del ítem define su fondo y el campo `icon` añade un icono. Un ítem que no existe escribe un texto vacío. La salida no se codifica en HTML.\n\nExample: Una etiqueta de color\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clcolor(\"colors\") }}'.render({ id: 1 }); // \"<span class=\\\"ui-clcolor\\\" style=\\\"background:#f00\\\"><i class=\\\"ti ti-circle mr5\\\"></i>Red</span>\"\n'{{ id | clcolor(\"colors\") }}'.render({ id: 2 }); // \"<span class=\\\"ui-clcolor\\\">Blue</span>\"\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nEscribe un ítem 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 campo `icon` añade un elemento `<i>` y el campo `color` define el color del icono. Un ítem que no existe escribe un texto vacío. La salida no se codifica en HTML.\n\nExample: Un elemento con icono\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clicon(\"colors\") }}'.render({ id: 1 }); // \"<i class=\\\"ti ti-circle mr5\\\" style=\\\"color:#f00\\\"></i>Red\"\n'{{ id | clicon(\"colors\") }}'.render({ id: 2 }); // \"Blue\"\n```\n\n### {{ value | currency([code]) }}\n\nType: `method`\n\nDa formato de moneda a un número o a un texto numérico.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | no |  | El código de moneda registrado en `DEF.currencies`. |\n\nReturns: `String` El importe formateado.\n\nEl helper llama a [currency()](../number/#currency). Los valores que no son números ni textos escriben un texto vacío.\n\nExample: Escribir un importe\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\n\n'{{ price | currency(\"eur\") }}'.render({ price: 1234.5 }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: '1234,5' }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: null }); // \"\"\n```\n\n### {{ value | def([text]) }}\n\nType: `method`\n\nEscribe el valor, o un texto de sustitución cuando el valor está vacío.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | El texto de sustitución. |\n\nReturns: `String` El valor codificado o el texto de sustitución.\n\nTodo valor falsy cuenta como vacío, incluido `0`. El valor se codifica en HTML. El texto de sustitución es, de forma predeterminada, `DEF.empty`, que es `---`. `empty` es otro nombre de este helper.\n\nExample: Sustituir un valor vacío\n```js\n'{{ name | def }}'.render({ name: '' }); // \"---\"\n'{{ name | def(\"unknown\") }}'.render({}); // \"unknown\"\n'{{ name | def }}'.render({ name: '<b>' }); // \"&lt;b&gt;\"\n'{{ count | def }}'.render({ count: 0 }); // \"---\"\n```\n\n### {{ value | empty([text]) }}\n\nType: `method`\n\nOtro nombre del helper [def](#def).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | El texto de sustitución. |\n\nReturns: `String` El valor codificado o el texto de sustitución.\n\nExample: Sustituir un valor vacío\n```js\n'{{ name | empty }}'.render({}); // \"---\"\n'{{ name | empty(\"n/a\") }}'.render({ name: 'Ann' }); // \"Ann\"\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nCodifica el valor para HTML, JSON o una URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String or Function` | no |  | El tipo de codificación. |\n\nReturns: `String` El valor codificado.\n\nSin `type`, los caracteres `<`, `>`, `&` y `\"` se escriben como entidades HTML, y `null` o `undefined` escriben un texto vacío.\n\n| Tipo | Salida |\n| --- | --- |\n| `'json'` | JSON |\n| `'json2'` | JSON sangrado con tabuladores |\n| `'url'`, `'urlencoded'` | Un valor codificado para URL |\n| `'querify'` | Una query string creada con `QUERIFY()` |\n| Función | El resultado de `function(value)` |\n\nExample: Tipos de codificación\n```js\n'{{ value | encode }}'.render({ value: '<b>' }); // \"&lt;b&gt;\"\n'{{ value | encode(\"json\") }}'.render({ value: { id: 1 } }); // \"{\\\"id\\\":1}\"\n'{{ value | encode(\"url\") }}'.render({ value: 'a b&c' }); // \"a%20b%26c\"\n'{{ value | encode(\"querify\") }}'.render({ value: { page: 1, q: 'x y' } }); // \"?page=1&q=x%20y\"\n```\n\n### {{ value | format([format], [a], [b]) }}\n\nType: `method`\n\nDa formato a un número, a una fecha o a un texto que contenga uno de ellos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | El número de decimales o el formato de fecha. |\n| `a` | `Object` | no |  | El separador de miles para números, o `utc` para fechas. |\n| `b` | `String` | no |  | El separador decimal para números. |\n\nReturns: `String` El valor con formato.\n\nLos argumentos dependen del valor:\n\n| Valor | Argumentos | Resultado |\n| --- | --- | --- |\n| Número | `decimals`, `separator`, `decimalSeparator` | [format() de Number](../number/#format). Sin `decimals`, no se escriben decimales. |\n| Fecha | `format`, `utc` | [format() de Date](../date/#format) |\n| Texto con una fecha | `format` | La fecha, de forma predeterminada como `dd.MM.yyyy` |\n| Texto numérico | `decimals`, `separator`, `decimalSeparator` | El número, que conserva sus decimales cuando falta `decimals` |\n\nUn texto cuenta como fecha cuando contiene dos puntos, un espacio, la letra `T`, o más de un `-` o `.`. `null` y `undefined` escriben un texto vacío.\n\nExample: Números\n```js\n'{{ price | format(2) }}'.render({ price: 1234.5 }); // \"1 234.50\"\n'{{ price | format }}'.render({ price: 1234.5 }); // \"1 234\"\n'{{ price | format(2, \",\", \".\") }}'.render({ price: 1234.5 }); // \"1,234.50\"\n```\n\nExample: Fechas\n```js\nvar date = new Date(2026, 10, 18);\n\n'{{ date | format(\"dd.MM.yyyy\") }}'.render({ date: date }); // \"18.11.2026\"\n'{{ date | format }}'.render({ date: date }); // \"2026-11-18\"\n```\n\nExample: Valores de texto\n```js\nThelpers.format('2026-11-18'); // \"18.11.2026\"\nThelpers.format('2026-11-18', 'yyyy/MM'); // \"2026/11\"\nThelpers.format('1234.5'); // \"1 234.5\"\nThelpers.format('1234,5', 2); // \"1 234.50\"\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nElige un texto según la magnitud de un número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | El texto para 0, o las cuatro formas. |\n| `one` | `String` | yes |  | El texto para 1. |\n| `few` | `String` | yes |  | El texto para números mayores que 1 y menores que 5. |\n| `other` | `String` | yes |  | El texto para todos los demás números. |\n\nReturns: `String` El texto elegido.\n\nEl helper llama a [pluralize()](../number/#pluralize). Un valor de texto se convierte antes a número: se eliminan los espacios y la coma se interpreta como separador decimal.\n\nExample: Elegir una forma\n```js\nvar template = '{{ count | pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}';\n\ntemplate.render({ count: 0 }); // \"no items\"\ntemplate.render({ count: 1 }); // \"1 item\"\ntemplate.render({ count: 7 }); // \"7 items\"\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nEscribe el valor sin codificarlo en HTML.\n\nReturns: `Object` El valor sin cambios.\n\nUsa este helper solo con contenido de confianza.\n\nExample: Escribir HTML\n```js\n'{{ html | raw }}'.render({ html: '<b>Hello</b>' }); // \"<b>Hello</b>\"\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([code]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [a], [b]) }}","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:29.465Z"}
{"id":"JammjpBgj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/tangular-helpers/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Helpers Tangular","summary":"Les helpers disponibles dans les modèles Tangular pour encoder, formater et lire des listes de codes.","markdown":"---\ntitle: Helpers Tangular\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Helpers Tangular\n\n> Les helpers disponibles dans les modèles Tangular pour encoder, formater et lire des listes de codes.\n\nUn helper transforme une valeur dans un modèle : `{{ value | helper(arguments) }}`. Ces helpers se trouvent dans l'objet global `Thelpers`, tu peux donc aussi les appeler depuis le code en passant la valeur comme premier argument. Une valeur sans helper est encodée automatiquement en HTML ; une valeur avec un helper est écrite telle que le helper la renvoie. [Modèles avec Tangular](../../guides/tangular/) explique la syntaxe et comment ajouter tes propres helpers.\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nÉcrit une valeur de l'élément de la liste de codes qui a l'identifiant donné.\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 de l'élément.\n\nLa liste de codes est lue depuis `DEF.cl[name]`, et ses éléments sont recherchés par le champ `id`. Sans `key`, le helper écrit le champ `name`, ou `DEF.empty` quand l'élément n'existe pas. Avec `key`, un élément absent écrit un texte vide. La sortie n'est pas encodée en HTML.\n\nExample: Lire une liste de codes\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | cl(\"colors\") }}'.render({ id: 1 }); // \"Red\"\n'{{ id | cl(\"colors\", \"color\") }}'.render({ id: 1 }); // \"#f00\"\n'{{ id | cl(\"colors\") }}'.render({ id: 9 }); // \"---\"\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nÉcrit un élément de liste de codes sous forme de `<span>` 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 de l'élément.\n\nL'élément a la classe `ui-clcolor`. Le champ `color` de l'élément de la liste définit son arrière-plan et le champ `icon` ajoute une icône. Un élément absent écrit un texte vide. La sortie n'est pas encodée en HTML.\n\nExample: Un libellé coloré\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clcolor(\"colors\") }}'.render({ id: 1 }); // \"<span class=\\\"ui-clcolor\\\" style=\\\"background:#f00\\\"><i class=\\\"ti ti-circle mr5\\\"></i>Red</span>\"\n'{{ id | clcolor(\"colors\") }}'.render({ id: 2 }); // \"<span class=\\\"ui-clcolor\\\">Blue</span>\"\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nÉcrit un élément de 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\nLe champ `icon` ajoute un élément `<i>`, et le champ `color` définit la couleur de l'icône. Un élément absent écrit un texte vide. La sortie n'est pas encodée en HTML.\n\nExample: Un élément avec une icône\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clicon(\"colors\") }}'.render({ id: 1 }); // \"<i class=\\\"ti ti-circle mr5\\\" style=\\\"color:#f00\\\"></i>Red\"\n'{{ id | clicon(\"colors\") }}'.render({ id: 2 }); // \"Blue\"\n```\n\n### {{ value | currency([code]) }}\n\nType: `method`\n\nFormate un nombre ou un texte numérique en devise.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | no |  | Le code de devise enregistré dans `DEF.currencies`. |\n\nReturns: `String` Le montant formaté.\n\nLe helper appelle [currency()](../number/#currency). Les valeurs qui ne sont ni des nombres ni des textes écrivent un texte vide.\n\nExample: Écrire un montant\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\n\n'{{ price | currency(\"eur\") }}'.render({ price: 1234.5 }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: '1234,5' }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: null }); // \"\"\n```\n\n### {{ value | def([text]) }}\n\nType: `method`\n\nÉcrit la valeur, ou un texte de remplacement quand la valeur est vide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Le texte de remplacement. |\n\nReturns: `String` La valeur encodée ou le texte de remplacement.\n\nToute valeur fausse compte comme vide, y compris `0`. La valeur est encodée en HTML. Le texte de remplacement est par défaut `DEF.empty`, qui vaut `---`. `empty` est un autre nom de ce helper.\n\nExample: Remplacer une valeur vide\n```js\n'{{ name | def }}'.render({ name: '' }); // \"---\"\n'{{ name | def(\"unknown\") }}'.render({}); // \"unknown\"\n'{{ name | def }}'.render({ name: '<b>' }); // \"&lt;b&gt;\"\n'{{ count | def }}'.render({ count: 0 }); // \"---\"\n```\n\n### {{ value | empty([text]) }}\n\nType: `method`\n\nUn autre nom du helper [def](#def).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Le texte de remplacement. |\n\nReturns: `String` La valeur encodée ou le texte de remplacement.\n\nExample: Remplacer une valeur vide\n```js\n'{{ name | empty }}'.render({}); // \"---\"\n'{{ name | empty(\"n/a\") }}'.render({ name: 'Ann' }); // \"Ann\"\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nEncode la valeur pour HTML, JSON ou une URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String or Function` | no |  | Le type d'encodage. |\n\nReturns: `String` La valeur encodée.\n\nSans `type`, les caractères `<`, `>`, `&` et `\"` sont écrits sous forme d'entités HTML, et `null` ou `undefined` écrit un texte vide.\n\n| Type | Sortie |\n| --- | --- |\n| `'json'` | JSON |\n| `'json2'` | JSON indenté avec des tabulations |\n| `'url'`, `'urlencoded'` | Une valeur encodée pour une URL |\n| `'querify'` | Une chaîne de requête construite avec `QUERIFY()` |\n| Fonction | Le résultat de `function(value)` |\n\nExample: Types d'encodage\n```js\n'{{ value | encode }}'.render({ value: '<b>' }); // \"&lt;b&gt;\"\n'{{ value | encode(\"json\") }}'.render({ value: { id: 1 } }); // \"{\\\"id\\\":1}\"\n'{{ value | encode(\"url\") }}'.render({ value: 'a b&c' }); // \"a%20b%26c\"\n'{{ value | encode(\"querify\") }}'.render({ value: { page: 1, q: 'x y' } }); // \"?page=1&q=x%20y\"\n```\n\n### {{ value | format([format], [a], [b]) }}\n\nType: `method`\n\nFormate un nombre, une date ou un texte qui contient l'un des deux.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Le nombre de décimales, ou le format de date. |\n| `a` | `Object` | no |  | Le séparateur de milliers pour les nombres, ou `utc` pour les dates. |\n| `b` | `String` | no |  | Le séparateur décimal pour les nombres. |\n\nReturns: `String` La valeur formatée.\n\nLes arguments dépendent de la valeur :\n\n| Valeur | Arguments | Résultat |\n| --- | --- | --- |\n| Nombre | `decimals`, `separator`, `decimalSeparator` | [format() de Number](../number/#format). Sans `decimals`, aucune décimale n'est écrite. |\n| Date | `format`, `utc` | [format() de Date](../date/#format) |\n| Texte contenant une date | `format` | La date, par défaut au format `dd.MM.yyyy` |\n| Texte numérique | `decimals`, `separator`, `decimalSeparator` | Le nombre, qui conserve ses décimales quand `decimals` est absent |\n\nUn texte compte comme une date quand il contient un deux-points, un espace, la lettre `T`, ou plus d'un `-` ou `.`. `null` et `undefined` écrivent un texte vide.\n\nExample: Nombres\n```js\n'{{ price | format(2) }}'.render({ price: 1234.5 }); // \"1 234.50\"\n'{{ price | format }}'.render({ price: 1234.5 }); // \"1 234\"\n'{{ price | format(2, \",\", \".\") }}'.render({ price: 1234.5 }); // \"1,234.50\"\n```\n\nExample: Dates\n```js\nvar date = new Date(2026, 10, 18);\n\n'{{ date | format(\"dd.MM.yyyy\") }}'.render({ date: date }); // \"18.11.2026\"\n'{{ date | format }}'.render({ date: date }); // \"2026-11-18\"\n```\n\nExample: Valeurs textuelles\n```js\nThelpers.format('2026-11-18'); // \"18.11.2026\"\nThelpers.format('2026-11-18', 'yyyy/MM'); // \"2026/11\"\nThelpers.format('1234.5'); // \"1 234.5\"\nThelpers.format('1234,5', 2); // \"1 234.50\"\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nChoisit un texte selon la taille d'un nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Le texte pour 0, ou les quatre formes. |\n| `one` | `String` | yes |  | Le texte pour 1. |\n| `few` | `String` | yes |  | Le texte pour les nombres supérieurs à 1 et inférieurs à 5. |\n| `other` | `String` | yes |  | Le texte pour tous les autres nombres. |\n\nReturns: `String` Le texte choisi.\n\nLe helper appelle [pluralize()](../number/#pluralize). Une valeur textuelle est d'abord convertie en nombre ; les espaces sont supprimés et une virgule est lue comme séparateur décimal.\n\nExample: Choisir une forme\n```js\nvar template = '{{ count | pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}';\n\ntemplate.render({ count: 0 }); // \"no items\"\ntemplate.render({ count: 1 }); // \"1 item\"\ntemplate.render({ count: 7 }); // \"7 items\"\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nÉcrit la valeur sans encodage HTML.\n\nReturns: `Object` La valeur inchangée.\n\nUtilise ce helper uniquement avec du contenu de confiance.\n\nExample: Écrire du HTML\n```js\n'{{ html | raw }}'.render({ html: '<b>Hello</b>' }); // \"<b>Hello</b>\"\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([code]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [a], [b]) }}","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:29.465Z"}
{"id":"JammjpBgj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/tangular-helpers/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Helper di Tangular","summary":"Gli helper disponibili nei template Tangular per codificare, formattare e leggere gli elenchi di codici.","markdown":"---\ntitle: Helper di Tangular\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Helper di Tangular\n\n> Gli helper disponibili nei template Tangular per codificare, formattare e leggere gli elenchi di codici.\n\nUn helper trasforma un valore in un template: `{{ value | helper(arguments) }}`. Questi helper si trovano nell'oggetto globale `Thelpers`, quindi puoi chiamarli anche dal codice passando il valore come primo argomento. Un valore senza helper viene codificato automaticamente in HTML; un valore con un helper viene scritto così come l'helper lo restituisce. [Template con Tangular](../../guides/tangular/) spiega la sintassi e come aggiungere i tuoi helper.\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nScrive un valore dell'elemento dell'elenco di codici con l'identificatore indicato.\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 dell'elemento.\n\nL'elenco di codici viene letto da `DEF.cl[name]` e i suoi elementi vengono confrontati tramite il campo `id`. Senza `key`, l'helper scrive il campo `name`, oppure `DEF.empty` quando l'elemento non esiste. Con `key`, un elemento mancante scrive un testo vuoto. L'output non viene codificato in HTML.\n\nExample: Leggi un elenco di codici\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | cl(\"colors\") }}'.render({ id: 1 }); // \"Red\"\n'{{ id | cl(\"colors\", \"color\") }}'.render({ id: 1 }); // \"#f00\"\n'{{ id | cl(\"colors\") }}'.render({ id: 9 }); // \"---\"\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nScrive un elemento dell'elenco di codici come `<span>` colorato.\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'elemento ha la classe `ui-clcolor`. Il campo `color` dell'elemento imposta lo sfondo e il campo `icon` aggiunge un'icona. Un elemento mancante scrive un testo vuoto. L'output non viene codificato in HTML.\n\nExample: Un'etichetta colorata\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clcolor(\"colors\") }}'.render({ id: 1 }); // \"<span class=\\\"ui-clcolor\\\" style=\\\"background:#f00\\\"><i class=\\\"ti ti-circle mr5\\\"></i>Red</span>\"\n'{{ id | clcolor(\"colors\") }}'.render({ id: 2 }); // \"<span class=\\\"ui-clcolor\\\">Blue</span>\"\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nScrive un elemento dell'elenco di codici con la relativa 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\nIl campo `icon` aggiunge un elemento `<i>` e il campo `color` imposta il colore dell'icona. Un elemento mancante scrive un testo vuoto. L'output non viene codificato in HTML.\n\nExample: Un elemento con un'icona\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clicon(\"colors\") }}'.render({ id: 1 }); // \"<i class=\\\"ti ti-circle mr5\\\" style=\\\"color:#f00\\\"></i>Red\"\n'{{ id | clicon(\"colors\") }}'.render({ id: 2 }); // \"Blue\"\n```\n\n### {{ value | currency([code]) }}\n\nType: `method`\n\nFormatta come valuta un numero o un testo numerico.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | no |  | Il codice della valuta registrato in `DEF.currencies`. |\n\nReturns: `String` L'importo formattato.\n\nL'helper chiama [currency()](../number/#currency). I valori che non sono numeri o testi scrivono un testo vuoto.\n\nExample: Scrivi un importo\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\n\n'{{ price | currency(\"eur\") }}'.render({ price: 1234.5 }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: '1234,5' }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: null }); // \"\"\n```\n\n### {{ value | def([text]) }}\n\nType: `method`\n\nScrive il valore, oppure un sostituto quando il valore è vuoto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Il testo sostitutivo. |\n\nReturns: `String` Il valore codificato o il sostituto.\n\nOgni valore falsy è considerato vuoto, compreso `0`. Il valore viene codificato in HTML. Il sostituto predefinito è `DEF.empty`, cioè `---`. `empty` è un altro nome di questo helper.\n\nExample: Sostituisci un valore vuoto\n```js\n'{{ name | def }}'.render({ name: '' }); // \"---\"\n'{{ name | def(\"unknown\") }}'.render({}); // \"unknown\"\n'{{ name | def }}'.render({ name: '<b>' }); // \"&lt;b&gt;\"\n'{{ count | def }}'.render({ count: 0 }); // \"---\"\n```\n\n### {{ value | empty([text]) }}\n\nType: `method`\n\nUn altro nome dell'helper [def](#def).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Il testo sostitutivo. |\n\nReturns: `String` Il valore codificato o il sostituto.\n\nExample: Sostituisci un valore vuoto\n```js\n'{{ name | empty }}'.render({}); // \"---\"\n'{{ name | empty(\"n/a\") }}'.render({ name: 'Ann' }); // \"Ann\"\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nCodifica il valore per HTML, JSON o un URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String or Function` | no |  | Il tipo di codifica. |\n\nReturns: `String` Il valore codificato.\n\nSenza `type`, i caratteri `<`, `>`, `&` e `\"` vengono scritti come entità HTML, e `null` o `undefined` scrivono un testo vuoto.\n\n| Tipo | Output |\n| --- | --- |\n| `'json'` | JSON |\n| `'json2'` | JSON indentato con tabulazioni |\n| `'url'`, `'urlencoded'` | Un valore codificato per URL |\n| `'querify'` | Una stringa di query costruita con `QUERIFY()` |\n| Funzione | Il risultato di `function(value)` |\n\nExample: Tipi di codifica\n```js\n'{{ value | encode }}'.render({ value: '<b>' }); // \"&lt;b&gt;\"\n'{{ value | encode(\"json\") }}'.render({ value: { id: 1 } }); // \"{\\\"id\\\":1}\"\n'{{ value | encode(\"url\") }}'.render({ value: 'a b&c' }); // \"a%20b%26c\"\n'{{ value | encode(\"querify\") }}'.render({ value: { page: 1, q: 'x y' } }); // \"?page=1&q=x%20y\"\n```\n\n### {{ value | format([format], [a], [b]) }}\n\nType: `method`\n\nFormatta un numero, una data o un testo che ne contiene uno.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Il numero di decimali o il formato della data. |\n| `a` | `Object` | no |  | Il separatore delle migliaia per i numeri, oppure `utc` per le date. |\n| `b` | `String` | no |  | Il separatore decimale per i numeri. |\n\nReturns: `String` Il valore formattato.\n\nGli argomenti dipendono dal valore:\n\n| Valore | Argomenti | Risultato |\n| --- | --- | --- |\n| Numero | `decimals`, `separator`, `decimalSeparator` | [format() di Number](../number/#format). Senza `decimals`, non vengono scritti decimali. |\n| Data | `format`, `utc` | [format() di Date](../date/#format) |\n| Testo con una data | `format` | La data, per impostazione predefinita come `dd.MM.yyyy` |\n| Testo numerico | `decimals`, `separator`, `decimalSeparator` | Il numero, che mantiene i decimali quando manca `decimals` |\n\nUn testo è considerato una data quando contiene due punti, uno spazio, la lettera `T`, oppure più di un `-` o `.`. `null` e `undefined` scrivono un testo vuoto.\n\nExample: Numeri\n```js\n'{{ price | format(2) }}'.render({ price: 1234.5 }); // \"1 234.50\"\n'{{ price | format }}'.render({ price: 1234.5 }); // \"1 234\"\n'{{ price | format(2, \",\", \".\") }}'.render({ price: 1234.5 }); // \"1,234.50\"\n```\n\nExample: Date\n```js\nvar date = new Date(2026, 10, 18);\n\n'{{ date | format(\"dd.MM.yyyy\") }}'.render({ date: date }); // \"18.11.2026\"\n'{{ date | format }}'.render({ date: date }); // \"2026-11-18\"\n```\n\nExample: Valori testuali\n```js\nThelpers.format('2026-11-18'); // \"18.11.2026\"\nThelpers.format('2026-11-18', 'yyyy/MM'); // \"2026/11\"\nThelpers.format('1234.5'); // \"1 234.5\"\nThelpers.format('1234,5', 2); // \"1 234.50\"\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nSceglie un testo in base alla grandezza di un numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Il testo per 0, oppure tutte e quattro le forme. |\n| `one` | `String` | yes |  | Il testo per 1. |\n| `few` | `String` | yes |  | Il testo per i numeri maggiori di 1 e minori di 5. |\n| `other` | `String` | yes |  | Il testo per tutti gli altri numeri. |\n\nReturns: `String` Il testo scelto.\n\nL'helper chiama [pluralize()](../number/#pluralize). Un valore testuale viene prima convertito in numero: gli spazi vengono rimossi e una virgola viene letta come separatore decimale.\n\nExample: Scegli una forma\n```js\nvar template = '{{ count | pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}';\n\ntemplate.render({ count: 0 }); // \"no items\"\ntemplate.render({ count: 1 }); // \"1 item\"\ntemplate.render({ count: 7 }); // \"7 items\"\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nScrive il valore senza codifica HTML.\n\nReturns: `Object` Il valore invariato.\n\nUsa questo helper solo con contenuti attendibili.\n\nExample: Scrivi HTML\n```js\n'{{ html | raw }}'.render({ html: '<b>Hello</b>' }); // \"<b>Hello</b>\"\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([code]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [a], [b]) }}","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:29.465Z"}
{"id":"JammjpBgj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/tangular-helpers/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Helpery Tangularu","summary":"Helpery dostupné v šablónach Tangular na kódovanie, formátovanie a čítanie zoznamov kódov.","markdown":"---\ntitle: Helpery Tangularu\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Helpery Tangularu\n\n> Helpery dostupné v šablónach Tangular na kódovanie, formátovanie a čítanie zoznamov kódov.\n\nHelper transformuje hodnotu v šablóne: `{{ value | helper(arguments) }}`. Tieto helpery sa nachádzajú v globálnom objekte `Thelpers`, takže ich môžeš volať aj z kódu s hodnotou ako prvým argumentom. Hodnota bez helpera sa automaticky zakóduje pre HTML; hodnota s helperom sa zapíše tak, ako ju helper vráti. Syntax a pridávanie vlastných helperov vysvetľuje časť [Šablóny s Tangular](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nZapíše hodnotu položky zoznamu kódov so zadaným identifikátorom.\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 položky.\n\nZoznam kódov sa číta z `DEF.cl[name]` a jeho položky sa porovnávajú podľa poľa `id`. Bez `key` helper zapíše pole `name`, alebo `DEF.empty`, keď položka neexistuje. S `key` sa pri chýbajúcej položke zapíše prázdny text. Výstup sa nekóduje pre HTML.\n\nExample: Prečítaj zoznam kódov\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | cl(\"colors\") }}'.render({ id: 1 }); // \"Red\"\n'{{ id | cl(\"colors\", \"color\") }}'.render({ id: 1 }); // \"#f00\"\n'{{ id | cl(\"colors\") }}'.render({ id: 9 }); // \"---\"\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nZapíše položku zoznamu kódov ako farebný `<span>`.\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\nElement má triedu `ui-clcolor`. Pole `color` položky nastaví jeho pozadie a pole `icon` pridá ikonu. Pri chýbajúcej položke sa zapíše prázdny text. Výstup sa nekóduje pre HTML.\n\nExample: Farebný štítok\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clcolor(\"colors\") }}'.render({ id: 1 }); // \"<span class=\\\"ui-clcolor\\\" style=\\\"background:#f00\\\"><i class=\\\"ti ti-circle mr5\\\"></i>Red</span>\"\n'{{ id | clcolor(\"colors\") }}'.render({ id: 2 }); // \"<span class=\\\"ui-clcolor\\\">Blue</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\nPole `icon` pridá element `<i>` a pole `color` nastaví farbu ikony. Pri chýbajúcej položke sa zapíše prázdny text. Výstup sa nekóduje pre HTML.\n\nExample: Položka s ikonou\n```js\nDEF.cl.colors = [\n\t{ id: 1, name: 'Red', icon: 'ti ti-circle', color: '#f00' },\n\t{ id: 2, name: 'Blue' }\n];\n\n'{{ id | clicon(\"colors\") }}'.render({ id: 1 }); // \"<i class=\\\"ti ti-circle mr5\\\" style=\\\"color:#f00\\\"></i>Red\"\n'{{ id | clicon(\"colors\") }}'.render({ id: 2 }); // \"Blue\"\n```\n\n### {{ value | currency([code]) }}\n\nType: `method`\n\nNaformátuje číslo alebo číselný text ako menu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | no |  | Kód meny zaregistrovaný v `DEF.currencies`. |\n\nReturns: `String` Naformátovaná suma.\n\nHelper volá [currency()](../number/#currency). Pri hodnotách, ktoré nie sú číslami ani textami, sa zapíše prázdny text.\n\nExample: Zapíš sumu\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\n\n'{{ price | currency(\"eur\") }}'.render({ price: 1234.5 }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: '1234,5' }); // \"1 234.50 EUR\"\n'{{ price | currency(\"eur\") }}'.render({ price: null }); // \"\"\n```\n\n### {{ value | def([text]) }}\n\nType: `method`\n\nZapíše hodnotu alebo náhradu, keď je hodnota prázdna.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Náhradný text. |\n\nReturns: `String` Zakódovaná hodnota alebo náhrada.\n\nZa prázdnu sa považuje každá nepravdivá hodnota vrátane `0`. Hodnota sa kóduje pre HTML. Predvolená náhrada je `DEF.empty`, čo je `---`. `empty` je iný názov tohto helpera.\n\nExample: Nahraď prázdnu hodnotu\n```js\n'{{ name | def }}'.render({ name: '' }); // \"---\"\n'{{ name | def(\"unknown\") }}'.render({}); // \"unknown\"\n'{{ name | def }}'.render({ name: '<b>' }); // \"&lt;b&gt;\"\n'{{ count | def }}'.render({ count: 0 }); // \"---\"\n```\n\n### {{ value | empty([text]) }}\n\nType: `method`\n\nIný názov helpera [def](#def).\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Náhradný text. |\n\nReturns: `String` Zakódovaná hodnota alebo náhrada.\n\nExample: Nahraď prázdnu hodnotu\n```js\n'{{ name | empty }}'.render({}); // \"---\"\n'{{ name | empty(\"n/a\") }}'.render({ name: 'Ann' }); // \"Ann\"\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nZakóduje hodnotu pre HTML, JSON alebo URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String or Function` | no |  | Typ kódovania. |\n\nReturns: `String` Zakódovaná hodnota.\n\nBez `type` sa znaky `<`, `>`, `&` a `\"` zapíšu ako entity HTML a pri `null` alebo `undefined` sa zapíše prázdny text.\n\n| Typ | Výstup |\n| --- | --- |\n| `'json'` | JSON |\n| `'json2'` | JSON odsadený tabulátormi |\n| `'url'`, `'urlencoded'` | Hodnota zakódovaná pre URL |\n| `'querify'` | Reťazec dotazu zostavený pomocou `QUERIFY()` |\n| Funkcia | Výsledok `function(value)` |\n\nExample: Typy kódovania\n```js\n'{{ value | encode }}'.render({ value: '<b>' }); // \"&lt;b&gt;\"\n'{{ value | encode(\"json\") }}'.render({ value: { id: 1 } }); // \"{\\\"id\\\":1}\"\n'{{ value | encode(\"url\") }}'.render({ value: 'a b&c' }); // \"a%20b%26c\"\n'{{ value | encode(\"querify\") }}'.render({ value: { page: 1, q: 'x y' } }); // \"?page=1&q=x%20y\"\n```\n\n### {{ value | format([format], [a], [b]) }}\n\nType: `method`\n\nNaformátuje číslo, dátum alebo text, ktorý jedno z nich obsahuje.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Počet desatinných miest alebo formát dátumu. |\n| `a` | `Object` | no |  | Oddeľovač tisícok pre čísla alebo `utc` pre dátumy. |\n| `b` | `String` | no |  | Desatinný oddeľovač pre čísla. |\n\nReturns: `String` Naformátovaná hodnota.\n\nArgumenty závisia od hodnoty:\n\n| Hodnota | Argumenty | Výsledok |\n| --- | --- | --- |\n| Číslo | `decimals`, `separator`, `decimalSeparator` | [format() pre Number](../number/#format). Bez `decimals` sa desatinné miesta nezapíšu. |\n| Dátum | `format`, `utc` | [format() pre Date](../date/#format) |\n| Text s dátumom | `format` | Dátum, predvolene vo formáte `dd.MM.yyyy` |\n| Číselný text | `decimals`, `separator`, `decimalSeparator` | Číslo, ktoré si zachová desatinné miesta, keď `decimals` chýba |\n\nText sa považuje za dátum, keď obsahuje dvojbodku, medzeru, písmeno `T` alebo viac ako jeden znak `-` či `.`. Pri `null` a `undefined` sa zapíše prázdny text.\n\nExample: Čísla\n```js\n'{{ price | format(2) }}'.render({ price: 1234.5 }); // \"1 234.50\"\n'{{ price | format }}'.render({ price: 1234.5 }); // \"1 234\"\n'{{ price | format(2, \",\", \".\") }}'.render({ price: 1234.5 }); // \"1,234.50\"\n```\n\nExample: Dátumy\n```js\nvar date = new Date(2026, 10, 18);\n\n'{{ date | format(\"dd.MM.yyyy\") }}'.render({ date: date }); // \"18.11.2026\"\n'{{ date | format }}'.render({ date: date }); // \"2026-11-18\"\n```\n\nExample: Textové hodnoty\n```js\nThelpers.format('2026-11-18'); // \"18.11.2026\"\nThelpers.format('2026-11-18', 'yyyy/MM'); // \"2026/11\"\nThelpers.format('1234.5'); // \"1 234.5\"\nThelpers.format('1234,5', 2); // \"1 234.50\"\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nVyberie text podľa veľkosti čísla.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Text pre 0 alebo všetky štyri tvary. |\n| `one` | `String` | yes |  | Text pre 1. |\n| `few` | `String` | yes |  | Text pre čísla väčšie ako 1 a menšie ako 5. |\n| `other` | `String` | yes |  | Text pre všetky ostatné čísla. |\n\nReturns: `String` Vybraný text.\n\nHelper volá [pluralize()](../number/#pluralize). Textová hodnota sa najprv prevedie na číslo; medzery sa odstránia a čiarka sa číta ako desatinný oddeľovač.\n\nExample: Vyber tvar\n```js\nvar template = '{{ count | pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}';\n\ntemplate.render({ count: 0 }); // \"no items\"\ntemplate.render({ count: 1 }); // \"1 item\"\ntemplate.render({ count: 7 }); // \"7 items\"\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nZapíše hodnotu bez kódovania pre HTML.\n\nReturns: `Object` Nezmenená hodnota.\n\nTento helper používaj iba s dôveryhodným obsahom.\n\nExample: Zapíš HTML\n```js\n'{{ html | raw }}'.render({ html: '<b>Hello</b>' }); // \"<b>Hello</b>\"\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([code]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [a], [b]) }}","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:29.465Z"}
{"id":"JanH8l32G61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/routing/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/routing/\nupdated: 2026-11-18T17:06:23.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. The handler receives `null`, the original URL and the type `redirect`. See [Events](../events/).\n\nExample: React to a flag\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log(value, '|', type);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// /orders/ @audit | redirect\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([expire])\n\nType: `method`\n\nKeeps the navigation inside the application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expire` | `String or Boolean` | no | `'1 month'` | How long the URL is kept, for example `1 day`. `true` means one month, and `false` stores nothing. |\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\nThe current URL is stored in the browser and opened again on the next visit.\n\nExample: Navigate inside the application\n```js\nNAV.custom('1 day');\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([expire])","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:23.115Z"}
{"id":"JanH8l32G61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/routing/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/routing/\nupdated: 2026-11-18T17:06:23.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. Der Handler erhält `null`, die ursprüngliche URL und den Typ `redirect`. Siehe [Ereignisse](../events/).\n\nExample: Auf ein Flag reagieren\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log(value, '|', type);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// /orders/ @audit | redirect\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([expire])\n\nType: `method`\n\nHält die Navigation innerhalb der Anwendung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expire` | `String or Boolean` | no | `'1 month'` | Wie lange die URL aufbewahrt wird, zum Beispiel `1 day`. `true` bedeutet einen Monat, und `false` speichert nichts. |\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\nDie aktuelle URL wird im Browser gespeichert und beim nächsten Besuch wieder geöffnet.\n\nExample: Innerhalb der Anwendung navigieren\n```js\nNAV.custom('1 day');\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([expire])","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:23.115Z"}
{"id":"JanH8l32G61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/routing/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/routing/\nupdated: 2026-11-18T17:06:23.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. El manejador recibe `null`, la URL original y el tipo `redirect`. Consulta [Eventos](../events/).\n\nExample: Reacciona a un flag\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log(value, '|', type);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// /orders/ @audit | redirect\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([expire])\n\nType: `method`\n\nMantiene la navegación dentro de la aplicación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expire` | `String or Boolean` | no | `'1 month'` | Cuánto tiempo se conserva la URL, por ejemplo `1 day`. `true` significa un mes y `false` no guarda nada. |\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\nLa URL actual se guarda en el navegador y se abre de nuevo en la siguiente visita.\n\nExample: Navega dentro de la aplicación\n```js\nNAV.custom('1 day');\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([expire])","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:23.115Z"}
{"id":"JanH8l32G61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/routing/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/routing/\nupdated: 2026-11-18T17:06:23.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. Le gestionnaire reçoit `null`, l'URL d'origine et le type `redirect`. Consulte [Événements](../events/).\n\nExample: Réagir à un flag\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log(value, '|', type);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// /orders/ @audit | redirect\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([expire])\n\nType: `method`\n\nGarde la navigation à l'intérieur de l'application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expire` | `String or Boolean` | no | `'1 month'` | La durée de conservation de l'URL, par exemple `1 day`. `true` signifie un mois, et `false` ne stocke rien. |\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\nL'URL actuelle est stockée dans le navigateur et rouverte à la visite suivante.\n\nExample: Naviguer à l'intérieur de l'application\n```js\nNAV.custom('1 day');\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([expire])","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:23.115Z"}
{"id":"JanH8l32G61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/routing/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/routing/\nupdated: 2026-11-18T17:06:23.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. Il gestore riceve `null`, l'URL originale e il tipo `redirect`. Vedi [Eventi](../events/).\n\nExample: Reagisci a un flag\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log(value, '|', type);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// /orders/ @audit | redirect\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([expire])\n\nType: `method`\n\nMantiene la navigazione all'interno dell'applicazione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expire` | `String or Boolean` | no | `'1 month'` | Per quanto tempo viene conservato l'URL, ad esempio `1 day`. `true` significa un mese e `false` non memorizza nulla. |\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\nL'URL corrente viene memorizzato nel browser e riaperto alla visita successiva.\n\nExample: Naviga all'interno dell'applicazione\n```js\nNAV.custom('1 day');\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([expire])","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:23.115Z"}
{"id":"JanH8l32G61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/routing/","project":"jcomponent-v19","version":"19-194","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 V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/routing/\nupdated: 2026-11-18T17:06:23.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`. Obslužná funkcia dostane `null`, pôvodnú URL a typ `redirect`. Pozri [Udalosti](../events/).\n\nExample: Zareaguj na flag\n```js\nON('@flag audit', function(path, value, type) {\n\tconsole.log(value, '|', type);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// /orders/ @audit | redirect\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([expire])\n\nType: `method`\n\nUdržiava navigáciu vnútri aplikácie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `expire` | `String or Boolean` | no | `'1 month'` | Ako dlho sa URL uchováva, napríklad `1 day`. `true` znamená jeden mesiac a `false` neukladá nič. |\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\nAktuálna URL sa uloží v prehliadači a pri ďalšej návšteve sa znova otvorí.\n\nExample: Naviguj vnútri aplikácie\n```js\nNAV.custom('1 day');\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([expire])","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:23.115Z"}
{"id":"Jammj3Amj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/string/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"String","summary":"Methods that jComponent adds to String.prototype for formatting, parsing, validating and converting text.","markdown":"---\ntitle: String\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/string/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# String\n\n> Methods that jComponent adds to String.prototype for formatting, parsing, validating and converting text.\n\njComponent adds these methods to `String.prototype`, so they are available on every string as soon as the library is loaded. Numbers and dates have their own helpers on the [Number](../number/) and [Date](../date/) pages, and [Templates with Tangular](../../guides/tangular/) explains the template syntax used by `render()`.\n\n## API\n\n### str.arg(obj, [encode], [def])\n\nType: `method`\n\nReplaces `{key}` and `{{ key }}` placeholders with values read from an object.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | The source of the values. |\n| `encode` | `Boolean, String or Function` | no |  | How the values are encoded. |\n| `def` | `String` | no |  | The text used for placeholders without a value. |\n\nReturns: `String` The text with the values applied.\n\nA key can be a nested path such as `{user.name}`. A placeholder without a value stays in the text, unless `def` is set. `args()` is another name for the same method.\n\nThe `encode` argument changes how values are written:\n\n| Value | Result |\n| --- | --- |\n| `true` | The value is URL-encoded. |\n| `'escape'` | The value is HTML-encoded. Every placeholder must have a value. |\n| `'json'` | The value is written as JSON. Every placeholder must have a value. |\n| Function | `function(value, key)` returns the text to write. |\n\nExample: Placeholders\n```js\n'Hello {name}, {age}'.arg({ name: 'Ann', age: 30 }); // \"Hello Ann, 30\"\n'Hello {{ user.name }}'.arg({ user: { name: 'Ann' } }); // \"Hello Ann\"\n'Hello {name}'.arg({}); // \"Hello {name}\"\n'Hello {name}'.arg({}, undefined, 'guest'); // \"Hello guest\"\n```\n\nExample: Encoding\n```js\n'/search?q={q}'.arg({ q: 'a b&c' }, true); // \"/search?q=a%20b%26c\"\n'<b>{name}</b>'.arg({ name: '<i>' }, 'escape'); // \"<b>&lt;i&gt;</b>\"\n'data={value}'.arg({ value: { id: 1 } }, 'json'); // \"data={\\\"id\\\":1}\"\n'{price}'.arg({ price: 2 }, (value, key) => key + '=' + (value * 2)); // \"price=4\"\n```\n\n### str.COMPILABLE()\n\nType: `method`\n\nChecks whether an HTML string contains a binding attribute or a component declaration.\n\nReturns: `Boolean` `true` when the text contains one of them.\n\nThe method looks for the attributes `data--`, `data---`, `data-import`, `-bind` and `bind`, and for a `COMPONENT(` call.\n\nExample: Check a template\n```js\n'<div data-bind=\"user.name\"></div>'.COMPILABLE(); // true\n'<div>Hello</div>'.COMPILABLE(); // false\n```\n\n### str.encode()\n\nType: `method`\n\nEncodes the characters `<`, `>`, `&` and `\"` as HTML entities.\n\nReturns: `String` The encoded text.\n\nExample: Encode text\n```js\n'<a href=\"#\">Tom & Ann</a>'.encode(); // \"&lt;a href=&quot;#&quot;&gt;Tom &amp; Ann&lt;/a&gt;\"\n```\n\n### str.env()\n\nType: `method`\n\nReplaces `[key]` with a value from `ENV()` and `[.path]` with a value from the model.\n\nReturns: `String` The text with the values applied.\n\nA key without a value stays in the text.\n\nExample: Read environment values\n```js\nENV('site', 'Docs');\nSET('common.title', 'Hello');\n'[site] page'.env(); // \"Docs page\"\n'[.common.title] page'.env(); // \"Hello page\"\n'[missing] page'.env(); // \"[missing] page\"\n```\n\n### str.flags([path], [value], [type])\n\nType: `method`\n\nRemoves `@flag` words from the text and emits an event for each of them.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The first argument of the event. |\n| `value` | `Object` | no |  | The second argument of the event. |\n| `type` | `Number or String` | no |  | The third argument of the event. |\n\nReturns: `String` The text without the flags.\n\nEach flag emits the event `@flag name` with the arguments `path`, `value` and `type`. The [Flags and path modifiers](../../guides/flags/) guide explains how flags are used.\n\nExample: Remove flags\n```js\nON('@flag hidden', function(path, value, type) {\n\tconsole.log('flag', path, value, type);\n});\n\nvar path = 'user.name @hidden'.flags('user.name', 'Ann', 1);\nconsole.log(path);\n```\n\n### str.format(a, [b], [c], ...)\n\nType: `method`\n\nReplaces the positional placeholders `{0}`, `{1}` and so on with the arguments.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `a` | `Object` | yes |  | The value for `{0}`. Each further argument fills the next position. |\n\nReturns: `String` The formatted text.\n\nA missing or `null` argument writes an empty text. An array is joined without a separator.\n\nExample: Positional values\n```js\n'{0} and {1}'.format('Ann', 'Bob'); // \"Ann and Bob\"\n'{0}-{1}-{2}'.format('a', null, ['x', 'y']); // \"a--xy\"\n```\n\n### str.isEmail()\n\nType: `method`\n\nChecks whether the text is an email address.\n\nReturns: `Boolean` `true` for a valid address.\n\nExample: Validate an address\n```js\n'ann@example.com'.isEmail(); // true\n'ann@example'.isEmail(); // false\n```\n\n### str.isJSONDate()\n\nType: `method`\n\nChecks whether the text has the shape of a date serialized to JSON.\n\nReturns: `Boolean` `true` when the text has the shape `yyyy-MM-ddTHH:mm:ss.sssZ`.\n\nThe method checks the length and the positions of the separators, and the final `Z`. It does not validate the values.\n\nExample: Detect a JSON date\n```js\n'2026-11-18T10:20:30.000Z'.isJSONDate(); // true\n'2026-11-18'.isJSONDate(); // false\n```\n\n### str.isPhone()\n\nType: `method`\n\nChecks whether the text is a phone number.\n\nReturns: `Boolean` `true` for a valid number.\n\nThe number has an optional `+`, a group of three digits that can be in parentheses, a group of three digits and a group of four to eight digits. The groups can be separated by a single space, `-` or `.`.\n\nExample: Validate a number\n```js\n'+421903123456'.isPhone(); // true\n'123-456-7890'.isPhone(); // true\n'12345'.isPhone(); // false\n```\n\n### str.isURL()\n\nType: `method`\n\nChecks whether the text is an `http` or `https` address.\n\nReturns: `Boolean` `true` for a valid address.\n\nExample: Validate an address\n```js\n'https://www.totaljs.com'.isURL(); // true\n'ftp://example.com/file'.isURL(); // false\n'totaljs.com'.isURL(); // false\n```\n\n### str.padLeft(length, [char])\n\nType: `method`\n\nAdds a character to the left side until the text reaches a length.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `' '` | The character to add. |\n\nReturns: `String` The padded text.\n\nText that is already long enough is returned unchanged.\n\nExample: Pad on the left\n```js\n'5'.padLeft(3, '0'); // \"005\"\n'5'.padLeft(3); // \"  5\"\n'hello'.padLeft(3, '0'); // \"hello\"\n```\n\n### str.padRight(length, [char])\n\nType: `method`\n\nAdds a character to the right side until the text reaches a length.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `' '` | The character to add. |\n\nReturns: `String` The padded text.\n\nText that is already long enough is returned unchanged.\n\nExample: Pad on the right\n```js\n'5'.padRight(3, '-'); // \"5--\"\n```\n\n### str.parseConfig([def], [callback])\n\nType: `method`\n\nParses a `key:value;key:value` text into an object.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String, Object or Function` | no |  | Default values as a configuration text or an object. A function is used as `callback`. |\n| `callback` | `Function` | no |  | `function(key, value)` is called for each parsed pair. |\n\nReturns: `Object` The parsed configuration.\n\nThe values `true` and `false` become booleans and numeric values become numbers. Use `\\:` and `\\;` to write these characters in a value; the colon of an `http://`, `https://`, `ws://` or `wss://` address needs no escaping. Keys and values go through [env()](#env). A pair with more than one unescaped colon is skipped.\n\nWhen `def` is an object, the values are written to that object and the same object is returned.\n\nExample: Parse a configuration\n```js\n'title:Hello;limit:10;visible:true'.parseConfig(); // {\"title\":\"Hello\",\"limit\":10,\"visible\":true}\n'url:https://www.totaljs.com;size:2'.parseConfig(); // {\"url\":\"https://www.totaljs.com\",\"size\":2}\n```\n\nExample: Default values and a callback\n```js\n'limit:10'.parseConfig('limit:5;page:1'); // {\"limit\":10,\"page\":1}\n\nvar keys = [];\n'a:1;b:2'.parseConfig((key, value) => keys.push(key + '=' + value));\nkeys; // [\"a=1\",\"b=2\"]\n```\n\n### str.parseDate([format])\n\nType: `method`\n\nConverts the text to a `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | The layout of the text. |\n\nReturns: `Date` The parsed date, or `null` for an empty text.\n\nWithout `format`, the method reads `yyyy-MM-dd` and `dd.MM.yyyy`, optionally followed by a time in the form `HH:mm` or `HH:mm:ss`, separated by a space or `T`. A text ending with `Z` is read as a UTC date. Any other text goes to the `Date` constructor. A time alone uses the current date.\n\nWith `format`, the digits of the text are read by position, so each value must have the width of its token. The supported tokens are `yyyy`, `yy`, `MM`, `dd`, `HH`, `mm` and `ss`. A two-digit year is added to 2000. The format must contain the day.\n\nExample: Automatic detection\n```js\n'2026-11-18 14:05:09'.parseDate().format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\n'18.11.2026'.parseDate().format('yyyy-MM-dd'); // \"2026-11-18\"\n'2026-11-18T13:05:09.000Z'.parseDate().getTime() === Date.UTC(2026, 10, 18, 13, 5, 9); // true\n''.parseDate(); // null\n```\n\nExample: A custom layout\n```js\n'18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd'); // \"2026-11-18\"\n'20261118'.parseDate('yyyyMMdd').format('yyyy-MM-dd'); // \"2026-11-18\"\n'18.11.26 14:05'.parseDate('dd.MM.yy HH:mm').format('yyyy-MM-dd HH:mm'); // \"2026-11-18 14:05\"\n```\n\n### str.parseEncoded()\n\nType: `method`\n\nParses a URL query string into an object.\n\nReturns: `Object` The parsed values.\n\nEverything up to the `?` and everything after the `#` is ignored. Keys and values are decoded with `decodeURIComponent()`, and all values stay strings.\n\nExample: Read a query string\n```js\n'name=Ann&city=New%20York'.parseEncoded(); // {\"name\":\"Ann\",\"city\":\"New York\"}\n'/products/?page=2&sort=asc#top'.parseEncoded(); // {\"page\":\"2\",\"sort\":\"asc\"}\n```\n\n### str.parseExpire()\n\nType: `method`\n\nConverts a duration such as `5 minutes` to milliseconds.\n\nReturns: `Number` The duration in milliseconds.\n\nThe text has a number, a space and a unit. An unknown unit returns `0`, and so does a text that does not start with a number.\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\nExample: Durations\n```js\n'30 seconds'.parseExpire(); // 30000\n'5 minutes'.parseExpire(); // 300000\n'1 day'.parseExpire(); // 86400000\n'1 month'.parseExpire(); // 2419200000\n'none'.parseExpire(); // 0\n```\n\n### str.parseFloat([def])\n\nType: `method`\n\nReads the first decimal number from the text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | The value returned when the text has no valid number. |\n\nReturns: `Number` The parsed number.\n\nThe decimal separator can be a dot or a comma. A number that contains both of them, such as `1,234.5`, is not valid and returns the default value.\n\nExample: Read a decimal number\n```js\n'12.5'.parseFloat(); // 12.5\n'12,5'.parseFloat(); // 12.5\n'-3.25 kg'.parseFloat(); // -3.25\n'abc'.parseFloat(1.5); // 1.5\n```\n\n### str.parseInt([def])\n\nType: `method`\n\nReads the first whole number from the text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | The value returned when the text has no number. |\n\nReturns: `Number` The parsed number.\n\nExample: Read a whole number\n```js\n'123abc'.parseInt(); // 123\n' -42 '.parseInt(); // -42\n'a12b3'.parseInt(); // 12\n'abc'.parseInt(7); // 7\n```\n\n### str.parseSource([type])\n\nType: `method`\n\nParses an `id|name|icon` list into an array of objects.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number or String` | no |  | Use `Number` or `'number'` to convert identifiers to numbers. |\n\nReturns: `Array` Objects with the fields `id`, `name` and `icon`.\n\nItems are separated by commas. The name defaults to the identifier and the icon to an empty text.\n\nExample: Parse a list\n```js\n'1|One|ti ti-star,2|Two'.parseSource(); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti ti-star\"},{\"id\":\"2\",\"name\":\"Two\",\"icon\":\"\"}]\n'1|One,2'.parseSource(Number); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"},{\"id\":2,\"name\":\"2\",\"icon\":\"\"}]\n```\n\n### str.removeTags()\n\nType: `method`\n\nRemoves HTML tags from the text.\n\nReturns: `String` The text without tags.\n\nEverything from a `<` to the next `>` is treated as a tag.\n\nExample: Strip HTML\n```js\n'<p>Hello <b>world</b></p>'.removeTags(); // \"Hello world\"\n```\n\n### str.render(model, [repository])\n\nType: `method`\n\nCompiles the text as a Tangular template and renders it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `Object` | yes |  | The data of the template. |\n| `repository` | `Object` | no |  | Additional data, available in the template as `$`. |\n\nReturns: `String` The rendered output.\n\nThe [Templates with Tangular](../../guides/tangular/) guide describes the syntax.\n\nExample: Render a template\n```js\n'Hello {{ name }}'.render({ name: '<Ann>' }); // \"Hello &lt;Ann&gt;\"\n'{{ $.title }}: {{ name }}'.render({ name: 'Ann' }, { title: 'User' }); // \"User: Ann\"\n```\n\n### str.ROOT([nobase])\n\nType: `method`\n\nPrepends `DEF.root` or `DEF.baseurl` to a relative URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `nobase` | `Boolean` | no |  | Use `true` to ignore `DEF.baseurl`. |\n\nReturns: `String` The final URL.\n\n`DEF.root` is used when it is set; otherwise `DEF.baseurl` is used. Both can be a string or a function that receives the URL and returns the new one. A string prefix is not added to an absolute URL. Repeated slashes in the result are reduced to one. See [DEF](../def/).\n\nExample: Prefix a URL\n```js\nDEF.root = '/app';\n'/users/'.ROOT(); // \"/app/users/\"\n'https://www.totaljs.com/'.ROOT(); // \"https://www.totaljs.com/\"\nDEF.root = '';\n\nDEF.baseurl = '/base';\n'/users/'.ROOT(); // \"/base/users/\"\n'/users/'.ROOT(true); // \"/users/\"\nDEF.baseurl = '';\n```\n\n### str.SCOPE(element)\n\nType: `method`\n\nReplaces `?` in a path with the path of the scope of an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element, jQuery, Component, Plugin or Scope` | yes |  | The object that gives the scope. |\n\nReturns: `String` The final path.\n\nA path without `?` is returned as it is. See [Scopes](../../guides/scopes/).\n\nExample: Resolve a scoped path\n```html\n<ui-plugin path=\"orders\"><div id=\"field\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tvar path = '?.name'.SCOPE($('#field'));\n\tconsole.log(path);\n}, 500);\n</script>\n```\n\n### str.slug([max])\n\nType: `method`\n\nConverts the text to a lowercase, URL-friendly identifier.\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()](#toascii). Spaces and punctuation become a single `-`, and characters without an ASCII form are removed.\n\nExample: Create a slug\n```js\n'Hello World!'.slug(); // \"hello-world\"\n'  Žluťoučký kůň  '.slug(); // \"zlutoucky-kun\"\n'one two three'.slug(7); // \"one-two\"\n```\n\n### str.toASCII()\n\nType: `method`\n\nReplaces diacritical characters with their ASCII letters.\n\nReturns: `String` The converted text.\n\nThe conversion covers the characters `á ä č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž ć` in both cases. Other characters stay unchanged.\n\nExample: Remove diacritics\n```js\n'Žluťoučký kůň'.toASCII(); // \"Zlutoucky kun\"\n'Señor'.toASCII(); // \"Señor\"\n```\n\n### str.toSearch()\n\nType: `method`\n\nNormalizes the text for fuzzy searching.\n\nReturns: `String` The normalized text.\n\nThe method removes punctuation except the colon, converts the text to lowercase ASCII, replaces `y` with `i` and collapses repeated characters.\n\nExample: Normalize a search term\n```js\n'Žluťoučký Kůň!'.toSearch(); // \"zlutoucki kun\"\n'Yellow Sunny'.toSearch(); // \"ielow suni\"\n```\n\n### str.VARIABLES([args])\n\nType: `method`\n\nReads `--name=value--` definitions from the text and replaces `--name--` placeholders.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Predefined values. Definitions found in the text are added to this object. |\n\nReturns: `String` The processed text.\n\nDefinitions are removed from the text and stored in `args`. A placeholder without a value stays in the text.\n\nExample: Variables in a text\n```js\n'--color=red--Color: --color--'.VARIABLES(); // \"Color: red\"\n'Size: --size--'.VARIABLES({ size: '10px' }); // \"Size: 10px\"\n'Size: --size--'.VARIABLES(); // \"Size: --size--\"\n```\n","entries":[{"type":"method","name":"arg()","signature":"str.arg(obj, [encode], [def])","since":"","deprecated":false},{"type":"method","name":"COMPILABLE()","signature":"str.COMPILABLE()","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"str.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"str.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"str.flags([path], [value], [type])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"str.format(a, [b], [c], ...)","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"str.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"str.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"str.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"str.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"str.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"str.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"str.parseConfig([def], [callback])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"str.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseEncoded()","signature":"str.parseEncoded()","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"str.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"str.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"str.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"str.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"removeTags()","signature":"str.removeTags()","since":"","deprecated":false},{"type":"method","name":"render()","signature":"str.render(model, [repository])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"str.ROOT([nobase])","since":"","deprecated":false},{"type":"method","name":"SCOPE()","signature":"str.SCOPE(element)","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"str.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"str.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"str.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"str.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammj3Amj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/string/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"String","summary":"Methoden, die jComponent zu String.prototype hinzufügt, um Text zu formatieren, zu parsen, zu validieren und umzuwandeln.","markdown":"---\ntitle: String\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/string/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# String\n\n> Methoden, die jComponent zu String.prototype hinzufügt, um Text zu formatieren, zu parsen, zu validieren und umzuwandeln.\n\njComponent fügt diese Methoden zu `String.prototype` hinzu, sodass sie auf jedem String verfügbar sind, sobald die Bibliothek geladen ist. Zahlen und Datumswerte haben eigene Helper auf den Seiten [Number](../number/) und [Date](../date/), und [Templates mit Tangular](../../guides/tangular/) erklärt die von `render()` verwendete Template-Syntax.\n\n## API\n\n### str.arg(obj, [encode], [def])\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 Quelle der Werte. |\n| `encode` | `Boolean, String or Function` | no |  | Wie die Werte kodiert werden. |\n| `def` | `String` | no |  | Der Text für Platzhalter ohne Wert. |\n\nReturns: `String` Der Text mit den eingesetzten Werten.\n\nEin Schlüssel kann ein verschachtelter Path wie `{user.name}` sein. Ein Platzhalter ohne Wert bleibt im Text stehen, sofern `def` nicht gesetzt ist. `args()` ist ein anderer Name für dieselbe Methode.\n\nDas Argument `encode` ändert, wie Werte geschrieben werden:\n\n| Wert | Ergebnis |\n| --- | --- |\n| `true` | Der Wert wird URL-kodiert. |\n| `'escape'` | Der Wert wird HTML-kodiert. Jeder Platzhalter muss einen Wert haben. |\n| `'json'` | Der Wert wird als JSON geschrieben. Jeder Platzhalter muss einen Wert haben. |\n| Funktion | `function(value, key)` gibt den zu schreibenden Text zurück. |\n\nExample: Platzhalter\n```js\n'Hello {name}, {age}'.arg({ name: 'Ann', age: 30 }); // \"Hello Ann, 30\"\n'Hello {{ user.name }}'.arg({ user: { name: 'Ann' } }); // \"Hello Ann\"\n'Hello {name}'.arg({}); // \"Hello {name}\"\n'Hello {name}'.arg({}, undefined, 'guest'); // \"Hello guest\"\n```\n\nExample: Kodierung\n```js\n'/search?q={q}'.arg({ q: 'a b&c' }, true); // \"/search?q=a%20b%26c\"\n'<b>{name}</b>'.arg({ name: '<i>' }, 'escape'); // \"<b>&lt;i&gt;</b>\"\n'data={value}'.arg({ value: { id: 1 } }, 'json'); // \"data={\\\"id\\\":1}\"\n'{price}'.arg({ price: 2 }, (value, key) => key + '=' + (value * 2)); // \"price=4\"\n```\n\n### str.COMPILABLE()\n\nType: `method`\n\nPrüft, ob ein HTML-String ein Bindungsattribut oder eine Komponentendeklaration enthält.\n\nReturns: `Boolean` `true`, wenn der Text eines davon enthält.\n\nDie Methode sucht nach den Attributen `data--`, `data---`, `data-import`, `-bind` und `bind` sowie nach einem Aufruf von `COMPONENT(`.\n\nExample: Ein Template prüfen\n```js\n'<div data-bind=\"user.name\"></div>'.COMPILABLE(); // true\n'<div>Hello</div>'.COMPILABLE(); // false\n```\n\n### str.encode()\n\nType: `method`\n\nKodiert die Zeichen `<`, `>`, `&` und `\"` als HTML-Entitäten.\n\nReturns: `String` Der kodierte Text.\n\nExample: Text kodieren\n```js\n'<a href=\"#\">Tom & Ann</a>'.encode(); // \"&lt;a href=&quot;#&quot;&gt;Tom &amp; Ann&lt;/a&gt;\"\n```\n\n### str.env()\n\nType: `method`\n\nErsetzt `[key]` durch einen Wert aus `ENV()` und `[.path]` durch einen Wert aus dem Modell.\n\nReturns: `String` Der Text mit den eingesetzten Werten.\n\nEin Schlüssel ohne Wert bleibt im Text stehen.\n\nExample: Umgebungswerte lesen\n```js\nENV('site', 'Docs');\nSET('common.title', 'Hello');\n'[site] page'.env(); // \"Docs page\"\n'[.common.title] page'.env(); // \"Hello page\"\n'[missing] page'.env(); // \"[missing] page\"\n```\n\n### str.flags([path], [value], [type])\n\nType: `method`\n\nEntfernt `@flag`-Wörter aus dem Text und löst für jedes ein Event aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Das erste Argument des Events. |\n| `value` | `Object` | no |  | Das zweite Argument des Events. |\n| `type` | `Number or String` | no |  | Das dritte Argument des Events. |\n\nReturns: `String` Der Text ohne die Flags.\n\nJedes Flag löst das Event `@flag name` mit den Argumenten `path`, `value` und `type` aus. Der Guide [Flags und Path-Modifikatoren](../../guides/flags/) erklärt, wie Flags verwendet werden.\n\nExample: Flags entfernen\n```js\nON('@flag hidden', function(path, value, type) {\n\tconsole.log('flag', path, value, type);\n});\n\nvar path = 'user.name @hidden'.flags('user.name', 'Ann', 1);\nconsole.log(path);\n```\n\n### str.format(a, [b], [c], ...)\n\nType: `method`\n\nErsetzt die Positionsplatzhalter `{0}`, `{1}` und so weiter durch die Argumente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `a` | `Object` | yes |  | Der Wert für `{0}`. Jedes weitere Argument füllt die nächste Position. |\n\nReturns: `String` Der formatierte Text.\n\nEin fehlendes Argument oder `null` schreibt einen leeren Text. Ein Array wird ohne Trennzeichen zusammengefügt.\n\nExample: Positionswerte\n```js\n'{0} and {1}'.format('Ann', 'Bob'); // \"Ann and Bob\"\n'{0}-{1}-{2}'.format('a', null, ['x', 'y']); // \"a--xy\"\n```\n\n### str.isEmail()\n\nType: `method`\n\nPrüft, ob der Text eine E-Mail-Adresse ist.\n\nReturns: `Boolean` `true` bei einer gültigen Adresse.\n\nExample: Eine Adresse validieren\n```js\n'ann@example.com'.isEmail(); // true\n'ann@example'.isEmail(); // false\n```\n\n### str.isJSONDate()\n\nType: `method`\n\nPrüft, ob der Text die Form eines nach JSON serialisierten Datums hat.\n\nReturns: `Boolean` `true`, wenn der Text die Form `yyyy-MM-ddTHH:mm:ss.sssZ` hat.\n\nDie Methode prüft die Länge, die Positionen der Trennzeichen und das abschließende `Z`. Die Werte selbst validiert sie nicht.\n\nExample: Ein JSON-Datum erkennen\n```js\n'2026-11-18T10:20:30.000Z'.isJSONDate(); // true\n'2026-11-18'.isJSONDate(); // false\n```\n\n### str.isPhone()\n\nType: `method`\n\nPrüft, ob der Text eine Telefonnummer ist.\n\nReturns: `Boolean` `true` bei einer gültigen Nummer.\n\nDie Nummer besteht aus einem optionalen `+`, einer Gruppe aus drei Ziffern, die in Klammern stehen kann, einer Gruppe aus drei Ziffern und einer Gruppe aus vier bis acht Ziffern. Die Gruppen können durch ein einzelnes Leerzeichen, `-` oder `.` getrennt sein.\n\nExample: Eine Nummer validieren\n```js\n'+421903123456'.isPhone(); // true\n'123-456-7890'.isPhone(); // true\n'12345'.isPhone(); // false\n```\n\n### str.isURL()\n\nType: `method`\n\nPrüft, ob der Text eine `http`- oder `https`-Adresse ist.\n\nReturns: `Boolean` `true` bei einer gültigen Adresse.\n\nExample: Eine Adresse validieren\n```js\n'https://www.totaljs.com'.isURL(); // true\n'ftp://example.com/file'.isURL(); // false\n'totaljs.com'.isURL(); // false\n```\n\n### str.padLeft(length, [char])\n\nType: `method`\n\nFügt links ein Zeichen hinzu, bis der Text eine bestimmte Länge erreicht.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `' '` | Das hinzuzufügende Zeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nEin Text, der bereits lang genug ist, wird unverändert zurückgegeben.\n\nExample: Links auffüllen\n```js\n'5'.padLeft(3, '0'); // \"005\"\n'5'.padLeft(3); // \"  5\"\n'hello'.padLeft(3, '0'); // \"hello\"\n```\n\n### str.padRight(length, [char])\n\nType: `method`\n\nFügt rechts ein Zeichen hinzu, bis der Text eine bestimmte Länge erreicht.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `' '` | Das hinzuzufügende Zeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nEin Text, der bereits lang genug ist, wird unverändert zurückgegeben.\n\nExample: Rechts auffüllen\n```js\n'5'.padRight(3, '-'); // \"5--\"\n```\n\n### str.parseConfig([def], [callback])\n\nType: `method`\n\nParst einen Text im Format `key:value;key:value` in ein Objekt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String, Object or Function` | no |  | Standardwerte als Konfigurationstext oder Objekt. Eine Funktion wird als `callback` verwendet. |\n| `callback` | `Function` | no |  | `function(key, value)` wird für jedes geparste Paar aufgerufen. |\n\nReturns: `Object` Die geparste Konfiguration.\n\nDie Werte `true` und `false` werden zu booleschen Werten und numerische Werte zu Zahlen. Mit `\\:` und `\\;` schreibst du diese Zeichen in einen Wert; der Doppelpunkt einer `http://`-, `https://`-, `ws://`- oder `wss://`-Adresse muss nicht escapt werden. Schlüssel und Werte durchlaufen [env()](#env). Ein Paar mit mehr als einem nicht escapten Doppelpunkt wird übersprungen.\n\nIst `def` ein Objekt, werden die Werte in dieses Objekt geschrieben und dasselbe Objekt wird zurückgegeben.\n\nExample: Eine Konfiguration parsen\n```js\n'title:Hello;limit:10;visible:true'.parseConfig(); // {\"title\":\"Hello\",\"limit\":10,\"visible\":true}\n'url:https://www.totaljs.com;size:2'.parseConfig(); // {\"url\":\"https://www.totaljs.com\",\"size\":2}\n```\n\nExample: Standardwerte und ein Callback\n```js\n'limit:10'.parseConfig('limit:5;page:1'); // {\"limit\":10,\"page\":1}\n\nvar keys = [];\n'a:1;b:2'.parseConfig((key, value) => keys.push(key + '=' + value));\nkeys; // [\"a=1\",\"b=2\"]\n```\n\n### str.parseDate([format])\n\nType: `method`\n\nWandelt den Text in ein `Date` um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | Das Layout des Textes. |\n\nReturns: `Date` Das geparste Datum oder, bei einem leeren Text, `null`.\n\nOhne `format` liest die Methode `yyyy-MM-dd` und `dd.MM.yyyy`, optional gefolgt von einer Uhrzeit in der Form `HH:mm` oder `HH:mm:ss`, getrennt durch ein Leerzeichen oder `T`. Ein Text, der auf `Z` endet, wird als UTC-Datum gelesen. Jeder andere Text geht an den `Date`-Konstruktor. Eine Uhrzeit allein verwendet das aktuelle Datum.\n\nMit `format` werden die Ziffern des Texts nach ihrer Position gelesen, daher muss jeder Wert die Breite seines Tokens haben. Unterstützt werden die Tokens `yyyy`, `yy`, `MM`, `dd`, `HH`, `mm` und `ss`. Zu einer zweistelligen Jahreszahl wird 2000 addiert. Das Format muss den Tag enthalten.\n\nExample: Automatische Erkennung\n```js\n'2026-11-18 14:05:09'.parseDate().format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\n'18.11.2026'.parseDate().format('yyyy-MM-dd'); // \"2026-11-18\"\n'2026-11-18T13:05:09.000Z'.parseDate().getTime() === Date.UTC(2026, 10, 18, 13, 5, 9); // true\n''.parseDate(); // null\n```\n\nExample: Ein eigenes Layout\n```js\n'18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd'); // \"2026-11-18\"\n'20261118'.parseDate('yyyyMMdd').format('yyyy-MM-dd'); // \"2026-11-18\"\n'18.11.26 14:05'.parseDate('dd.MM.yy HH:mm').format('yyyy-MM-dd HH:mm'); // \"2026-11-18 14:05\"\n```\n\n### str.parseEncoded()\n\nType: `method`\n\nParst einen URL-Query-String in ein Objekt.\n\nReturns: `Object` Die geparsten Werte.\n\nAlles bis zum `?` und alles nach dem `#` wird ignoriert. Schlüssel und Werte werden mit `decodeURIComponent()` dekodiert, und alle Werte bleiben Strings.\n\nExample: Einen Query-String lesen\n```js\n'name=Ann&city=New%20York'.parseEncoded(); // {\"name\":\"Ann\",\"city\":\"New York\"}\n'/products/?page=2&sort=asc#top'.parseEncoded(); // {\"page\":\"2\",\"sort\":\"asc\"}\n```\n\n### str.parseExpire()\n\nType: `method`\n\nWandelt eine Dauer wie `5 minutes` in Millisekunden um.\n\nReturns: `Number` Die Dauer in Millisekunden.\n\nDer Text besteht aus einer Zahl, einem Leerzeichen und einer Einheit. Eine unbekannte Einheit gibt `0` zurück, ebenso ein Text, der nicht mit einer Zahl beginnt.\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\nExample: Zeitdauern\n```js\n'30 seconds'.parseExpire(); // 30000\n'5 minutes'.parseExpire(); // 300000\n'1 day'.parseExpire(); // 86400000\n'1 month'.parseExpire(); // 2419200000\n'none'.parseExpire(); // 0\n```\n\n### str.parseFloat([def])\n\nType: `method`\n\nLiest die erste Dezimalzahl aus dem Text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Der Wert, der zurückgegeben wird, wenn der Text keine gültige Zahl enthält. |\n\nReturns: `Number` Die geparste Zahl.\n\nDas Dezimaltrennzeichen kann ein Punkt oder ein Komma sein. Eine Zahl, die beide enthält, etwa `1,234.5`, ist ungültig und gibt den Standardwert zurück.\n\nExample: Eine Dezimalzahl lesen\n```js\n'12.5'.parseFloat(); // 12.5\n'12,5'.parseFloat(); // 12.5\n'-3.25 kg'.parseFloat(); // -3.25\n'abc'.parseFloat(1.5); // 1.5\n```\n\n### str.parseInt([def])\n\nType: `method`\n\nLiest die erste ganze Zahl aus dem Text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Der Wert, der zurückgegeben wird, wenn der Text keine Zahl enthält. |\n\nReturns: `Number` Die geparste Zahl.\n\nExample: Eine ganze Zahl lesen\n```js\n'123abc'.parseInt(); // 123\n' -42 '.parseInt(); // -42\n'a12b3'.parseInt(); // 12\n'abc'.parseInt(7); // 7\n```\n\n### str.parseSource([type])\n\nType: `method`\n\nParst eine Liste im Format `id|name|icon` in ein Array von Objekten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number or String` | no |  | Verwende `Number` oder `'number'`, um Kennungen in Zahlen umzuwandeln. |\n\nReturns: `Array` Objekte mit den Feldern `id`, `name` und `icon`.\n\nEinträge werden durch Kommas getrennt. Der Name ist standardmäßig die Kennung und das Icon ein leerer Text.\n\nExample: Liste parsen\n```js\n'1|One|ti ti-star,2|Two'.parseSource(); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti ti-star\"},{\"id\":\"2\",\"name\":\"Two\",\"icon\":\"\"}]\n'1|One,2'.parseSource(Number); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"},{\"id\":2,\"name\":\"2\",\"icon\":\"\"}]\n```\n\n### str.removeTags()\n\nType: `method`\n\nEntfernt HTML-Tags aus dem Text.\n\nReturns: `String` Der Text ohne Tags.\n\nAlles von einem `<` bis zum nächsten `>` wird als Tag behandelt.\n\nExample: HTML entfernen\n```js\n'<p>Hello <b>world</b></p>'.removeTags(); // \"Hello world\"\n```\n\n### str.render(model, [repository])\n\nType: `method`\n\nKompiliert den Text als Tangular-Template und rendert ihn.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `Object` | yes |  | Die Daten des Templates. |\n| `repository` | `Object` | no |  | Zusätzliche Daten, die im Template als `$` verfügbar sind. |\n\nReturns: `String` Die gerenderte Ausgabe.\n\nDer Guide [Templates mit Tangular](../../guides/tangular/) beschreibt die Syntax.\n\nExample: Ein Template rendern\n```js\n'Hello {{ name }}'.render({ name: '<Ann>' }); // \"Hello &lt;Ann&gt;\"\n'{{ $.title }}: {{ name }}'.render({ name: 'Ann' }, { title: 'User' }); // \"User: Ann\"\n```\n\n### str.ROOT([nobase])\n\nType: `method`\n\nStellt einer relativen URL `DEF.root` oder `DEF.baseurl` voran.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `nobase` | `Boolean` | no |  | Verwende `true`, um `DEF.baseurl` zu ignorieren. |\n\nReturns: `String` Die endgültige URL.\n\n`DEF.root` wird verwendet, wenn es gesetzt ist; andernfalls `DEF.baseurl`. Beide können ein String oder eine Funktion sein, die die URL erhält und die neue zurückgibt. Ein String-Präfix wird einer absoluten URL nicht hinzugefügt. Mehrfache Schrägstriche im Ergebnis werden auf einen reduziert. Siehe [DEF](../def/).\n\nExample: Einer URL ein Präfix voranstellen\n```js\nDEF.root = '/app';\n'/users/'.ROOT(); // \"/app/users/\"\n'https://www.totaljs.com/'.ROOT(); // \"https://www.totaljs.com/\"\nDEF.root = '';\n\nDEF.baseurl = '/base';\n'/users/'.ROOT(); // \"/base/users/\"\n'/users/'.ROOT(true); // \"/users/\"\nDEF.baseurl = '';\n```\n\n### str.SCOPE(element)\n\nType: `method`\n\nErsetzt `?` in einem Path durch den Path des Scopes eines Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element, jQuery, Component, Plugin or Scope` | yes |  | Das Objekt, das den Scope liefert. |\n\nReturns: `String` Der endgültige Path.\n\nEin Path ohne `?` wird unverändert zurückgegeben. Siehe [Scopes](../../guides/scopes/).\n\nExample: Einen Path im Scope auflösen\n```html\n<ui-plugin path=\"orders\"><div id=\"field\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tvar path = '?.name'.SCOPE($('#field'));\n\tconsole.log(path);\n}, 500);\n</script>\n```\n\n### str.slug([max])\n\nType: `method`\n\nWandelt den Text in eine kleingeschriebene, URL-freundliche Kennung 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()](#toascii) umgewandelt. Leerzeichen und Satzzeichen werden zu einem einzelnen `-`, und Zeichen ohne ASCII-Form werden entfernt.\n\nExample: Einen Slug erstellen\n```js\n'Hello World!'.slug(); // \"hello-world\"\n'  Žluťoučký kůň  '.slug(); // \"zlutoucky-kun\"\n'one two three'.slug(7); // \"one-two\"\n```\n\n### str.toASCII()\n\nType: `method`\n\nErsetzt diakritische Zeichen durch ihre ASCII-Buchstaben.\n\nReturns: `String` Der umgewandelte Text.\n\nDie Umwandlung umfasst die Zeichen `á ä č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž ć` in Groß- und Kleinschreibung. Andere Zeichen bleiben unverändert.\n\nExample: Diakritische Zeichen entfernen\n```js\n'Žluťoučký kůň'.toASCII(); // \"Zlutoucky kun\"\n'Señor'.toASCII(); // \"Señor\"\n```\n\n### str.toSearch()\n\nType: `method`\n\nNormalisiert den Text für die unscharfe Suche.\n\nReturns: `String` Der normalisierte Text.\n\nDie Methode entfernt Satzzeichen außer dem Doppelpunkt, wandelt den Text in kleingeschriebenes ASCII um, ersetzt `y` durch `i` und fasst wiederholte Zeichen zusammen.\n\nExample: Einen Suchbegriff normalisieren\n```js\n'Žluťoučký Kůň!'.toSearch(); // \"zlutoucki kun\"\n'Yellow Sunny'.toSearch(); // \"ielow suni\"\n```\n\n### str.VARIABLES([args])\n\nType: `method`\n\nLiest `--name=value--`-Definitionen aus dem Text und ersetzt `--name--`-Platzhalter.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Vordefinierte Werte. Im Text gefundene Definitionen werden diesem Objekt hinzugefügt. |\n\nReturns: `String` Der verarbeitete Text.\n\nDefinitionen werden aus dem Text entfernt und in `args` gespeichert. Ein Platzhalter ohne Wert bleibt im Text stehen.\n\nExample: Variablen in einem Text\n```js\n'--color=red--Color: --color--'.VARIABLES(); // \"Color: red\"\n'Size: --size--'.VARIABLES({ size: '10px' }); // \"Size: 10px\"\n'Size: --size--'.VARIABLES(); // \"Size: --size--\"\n```\n","entries":[{"type":"method","name":"arg()","signature":"str.arg(obj, [encode], [def])","since":"","deprecated":false},{"type":"method","name":"COMPILABLE()","signature":"str.COMPILABLE()","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"str.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"str.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"str.flags([path], [value], [type])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"str.format(a, [b], [c], ...)","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"str.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"str.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"str.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"str.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"str.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"str.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"str.parseConfig([def], [callback])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"str.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseEncoded()","signature":"str.parseEncoded()","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"str.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"str.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"str.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"str.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"removeTags()","signature":"str.removeTags()","since":"","deprecated":false},{"type":"method","name":"render()","signature":"str.render(model, [repository])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"str.ROOT([nobase])","since":"","deprecated":false},{"type":"method","name":"SCOPE()","signature":"str.SCOPE(element)","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"str.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"str.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"str.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"str.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammj3Amj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/string/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"String","summary":"Métodos que jComponent añade a String.prototype para dar formato, analizar, validar y convertir texto.","markdown":"---\ntitle: String\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/string/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# String\n\n> Métodos que jComponent añade a String.prototype para dar formato, analizar, validar y convertir texto.\n\njComponent añade estos métodos a `String.prototype`, así que están disponibles en cualquier cadena en cuanto se carga la biblioteca. Los números y las fechas tienen sus propios helpers en las páginas [Number](../number/) y [Date](../date/), y en [Plantillas con Tangular](../../guides/tangular/) se explica la sintaxis de plantillas que usa `render()`.\n\n## API\n\n### str.arg(obj, [encode], [def])\n\nType: `method`\n\nSustituye los marcadores `{key}` y `{{ key }}` por valores leídos de un objeto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | El origen de los valores. |\n| `encode` | `Boolean, String or Function` | no |  | Cómo se codifican los valores. |\n| `def` | `String` | no |  | El texto que se usa para los marcadores sin valor. |\n\nReturns: `String` El texto con los valores aplicados.\n\nUna clave puede ser un path anidado como `{user.name}`. Un marcador sin valor se queda en el texto, salvo que definas `def`. `args()` es otro nombre del mismo método.\n\nEl argumento `encode` cambia cómo se escriben los valores:\n\n| Valor | Resultado |\n| --- | --- |\n| `true` | El valor se codifica para URL. |\n| `'escape'` | El valor se codifica en HTML. Todos los marcadores deben tener un valor. |\n| `'json'` | El valor se escribe como JSON. Todos los marcadores deben tener un valor. |\n| Función | `function(value, key)` devuelve el texto que se escribe. |\n\nExample: Marcadores\n```js\n'Hello {name}, {age}'.arg({ name: 'Ann', age: 30 }); // \"Hello Ann, 30\"\n'Hello {{ user.name }}'.arg({ user: { name: 'Ann' } }); // \"Hello Ann\"\n'Hello {name}'.arg({}); // \"Hello {name}\"\n'Hello {name}'.arg({}, undefined, 'guest'); // \"Hello guest\"\n```\n\nExample: Codificación\n```js\n'/search?q={q}'.arg({ q: 'a b&c' }, true); // \"/search?q=a%20b%26c\"\n'<b>{name}</b>'.arg({ name: '<i>' }, 'escape'); // \"<b>&lt;i&gt;</b>\"\n'data={value}'.arg({ value: { id: 1 } }, 'json'); // \"data={\\\"id\\\":1}\"\n'{price}'.arg({ price: 2 }, (value, key) => key + '=' + (value * 2)); // \"price=4\"\n```\n\n### str.COMPILABLE()\n\nType: `method`\n\nComprueba si una cadena HTML contiene un atributo de binding o una declaración de componente.\n\nReturns: `Boolean` `true` cuando el texto contiene alguno de ellos.\n\nEl método busca los atributos `data--`, `data---`, `data-import`, `-bind` y `bind`, y una llamada a `COMPONENT(`.\n\nExample: Comprobar una plantilla\n```js\n'<div data-bind=\"user.name\"></div>'.COMPILABLE(); // true\n'<div>Hello</div>'.COMPILABLE(); // false\n```\n\n### str.encode()\n\nType: `method`\n\nCodifica los caracteres `<`, `>`, `&` y `\"` como entidades HTML.\n\nReturns: `String` El texto codificado.\n\nExample: Codificar texto\n```js\n'<a href=\"#\">Tom & Ann</a>'.encode(); // \"&lt;a href=&quot;#&quot;&gt;Tom &amp; Ann&lt;/a&gt;\"\n```\n\n### str.env()\n\nType: `method`\n\nSustituye `[key]` por un valor de `ENV()` y `[.path]` por un valor del modelo.\n\nReturns: `String` El texto con los valores aplicados.\n\nUna clave sin valor se queda en el texto.\n\nExample: Leer valores del entorno\n```js\nENV('site', 'Docs');\nSET('common.title', 'Hello');\n'[site] page'.env(); // \"Docs page\"\n'[.common.title] page'.env(); // \"Hello page\"\n'[missing] page'.env(); // \"[missing] page\"\n```\n\n### str.flags([path], [value], [type])\n\nType: `method`\n\nElimina las palabras `@flag` del texto y emite un evento por cada una.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El primer argumento del evento. |\n| `value` | `Object` | no |  | El segundo argumento del evento. |\n| `type` | `Number or String` | no |  | El tercer argumento del evento. |\n\nReturns: `String` El texto sin los flags.\n\nCada flag emite el evento `@flag name` con los argumentos `path`, `value` y `type`. En la guía [Flags y modificadores de path](../../guides/flags/) se explica cómo se usan los flags.\n\nExample: Eliminar flags\n```js\nON('@flag hidden', function(path, value, type) {\n\tconsole.log('flag', path, value, type);\n});\n\nvar path = 'user.name @hidden'.flags('user.name', 'Ann', 1);\nconsole.log(path);\n```\n\n### str.format(a, [b], [c], ...)\n\nType: `method`\n\nSustituye los marcadores posicionales `{0}`, `{1}`, etc., por los argumentos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `a` | `Object` | yes |  | El valor para `{0}`. Cada argumento adicional ocupa la siguiente posición. |\n\nReturns: `String` El texto con formato.\n\nUn argumento ausente o `null` escribe un texto vacío. Un array se une sin separador.\n\nExample: Valores posicionales\n```js\n'{0} and {1}'.format('Ann', 'Bob'); // \"Ann and Bob\"\n'{0}-{1}-{2}'.format('a', null, ['x', 'y']); // \"a--xy\"\n```\n\n### str.isEmail()\n\nType: `method`\n\nComprueba si el texto es una dirección de correo electrónico.\n\nReturns: `Boolean` `true` para una dirección válida.\n\nExample: Validar una dirección\n```js\n'ann@example.com'.isEmail(); // true\n'ann@example'.isEmail(); // false\n```\n\n### str.isJSONDate()\n\nType: `method`\n\nComprueba si el texto tiene la forma de una fecha serializada a JSON.\n\nReturns: `Boolean` `true` cuando el texto tiene la forma `yyyy-MM-ddTHH:mm:ss.sssZ`.\n\nEl método comprueba la longitud, la posición de los separadores y la `Z` final. No valida los valores.\n\nExample: Detectar una fecha JSON\n```js\n'2026-11-18T10:20:30.000Z'.isJSONDate(); // true\n'2026-11-18'.isJSONDate(); // false\n```\n\n### str.isPhone()\n\nType: `method`\n\nComprueba si el texto es un número de teléfono.\n\nReturns: `Boolean` `true` para un número válido.\n\nEl número tiene un `+` opcional, un grupo de tres dígitos que puede ir entre paréntesis, un grupo de tres dígitos y un grupo de cuatro a ocho dígitos. Los grupos se pueden separar con un solo espacio, `-` o `.`.\n\nExample: Validar un número\n```js\n'+421903123456'.isPhone(); // true\n'123-456-7890'.isPhone(); // true\n'12345'.isPhone(); // false\n```\n\n### str.isURL()\n\nType: `method`\n\nComprueba si el texto es una dirección `http` o `https`.\n\nReturns: `Boolean` `true` para una dirección válida.\n\nExample: Validar una dirección\n```js\n'https://www.totaljs.com'.isURL(); // true\n'ftp://example.com/file'.isURL(); // false\n'totaljs.com'.isURL(); // false\n```\n\n### str.padLeft(length, [char])\n\nType: `method`\n\nAñade un carácter por la izquierda hasta que el texto alcanza una longitud.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `' '` | El carácter que se añade. |\n\nReturns: `String` El texto rellenado.\n\nUn texto que ya es lo bastante largo se devuelve sin cambios.\n\nExample: Rellenar por la izquierda\n```js\n'5'.padLeft(3, '0'); // \"005\"\n'5'.padLeft(3); // \"  5\"\n'hello'.padLeft(3, '0'); // \"hello\"\n```\n\n### str.padRight(length, [char])\n\nType: `method`\n\nAñade un carácter por la derecha hasta que el texto alcanza una longitud.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `' '` | El carácter que se añade. |\n\nReturns: `String` El texto rellenado.\n\nUn texto que ya es lo bastante largo se devuelve sin cambios.\n\nExample: Rellenar por la derecha\n```js\n'5'.padRight(3, '-'); // \"5--\"\n```\n\n### str.parseConfig([def], [callback])\n\nType: `method`\n\nConvierte un texto `key:value;key:value` en un objeto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String, Object or Function` | no |  | Valores predeterminados como texto de configuración o como objeto. Una función se usa como `callback`. |\n| `callback` | `Function` | no |  | Se llama a `function(key, value)` por cada par analizado. |\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. Usa `\\:` y `\\;` para escribir estos caracteres en un valor; los dos puntos de una dirección `http://`, `https://`, `ws://` o `wss://` no hace falta escaparlos. Las claves y los valores pasan por [env()](#env). Se omite cualquier par que tenga más de un carácter de dos puntos sin escapar.\n\nCuando `def` es un objeto, los valores se escriben en ese objeto y se devuelve ese mismo objeto.\n\nExample: Analizar una configuración\n```js\n'title:Hello;limit:10;visible:true'.parseConfig(); // {\"title\":\"Hello\",\"limit\":10,\"visible\":true}\n'url:https://www.totaljs.com;size:2'.parseConfig(); // {\"url\":\"https://www.totaljs.com\",\"size\":2}\n```\n\nExample: Valores predeterminados y un callback\n```js\n'limit:10'.parseConfig('limit:5;page:1'); // {\"limit\":10,\"page\":1}\n\nvar keys = [];\n'a:1;b:2'.parseConfig((key, value) => keys.push(key + '=' + value));\nkeys; // [\"a=1\",\"b=2\"]\n```\n\n### str.parseDate([format])\n\nType: `method`\n\nConvierte el texto en un `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | El patrón del texto. |\n\nReturns: `Date` La fecha analizada, o `null` si el texto está vacío.\n\nSin `format`, el método lee `yyyy-MM-dd` y `dd.MM.yyyy`, seguidos opcionalmente de una hora con la forma `HH:mm` o `HH:mm:ss`, separada por un espacio o una `T`. Un texto que termina en `Z` se lee como fecha UTC. Cualquier otro texto pasa al constructor `Date`. Una hora sola usa la fecha actual.\n\nCon `format`, los dígitos del texto se leen por posición, así que cada valor debe tener el ancho de su token. Los tokens admitidos son `yyyy`, `yy`, `MM`, `dd`, `HH`, `mm` y `ss`. A un año de dos dígitos se le suma 2000. El formato debe contener el día.\n\nExample: Detección automática\n```js\n'2026-11-18 14:05:09'.parseDate().format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\n'18.11.2026'.parseDate().format('yyyy-MM-dd'); // \"2026-11-18\"\n'2026-11-18T13:05:09.000Z'.parseDate().getTime() === Date.UTC(2026, 10, 18, 13, 5, 9); // true\n''.parseDate(); // null\n```\n\nExample: Un formato personalizado\n```js\n'18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd'); // \"2026-11-18\"\n'20261118'.parseDate('yyyyMMdd').format('yyyy-MM-dd'); // \"2026-11-18\"\n'18.11.26 14:05'.parseDate('dd.MM.yy HH:mm').format('yyyy-MM-dd HH:mm'); // \"2026-11-18 14:05\"\n```\n\n### str.parseEncoded()\n\nType: `method`\n\nConvierte una query string de URL en un objeto.\n\nReturns: `Object` Los valores analizados.\n\nSe ignora todo lo que hay hasta el `?` y todo lo que hay después del `#`. Las claves y los valores se decodifican con `decodeURIComponent()`, y todos los valores siguen siendo cadenas.\n\nExample: Leer una query string\n```js\n'name=Ann&city=New%20York'.parseEncoded(); // {\"name\":\"Ann\",\"city\":\"New York\"}\n'/products/?page=2&sort=asc#top'.parseEncoded(); // {\"page\":\"2\",\"sort\":\"asc\"}\n```\n\n### str.parseExpire()\n\nType: `method`\n\nConvierte una duración como `5 minutes` en milisegundos.\n\nReturns: `Number` La duración en milisegundos.\n\nEl texto tiene un número, un espacio y una unidad. Una unidad desconocida devuelve `0`, igual que un texto que no empieza por un número.\n\n| Unidad | Nombres admitidos |\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\nExample: Duraciones\n```js\n'30 seconds'.parseExpire(); // 30000\n'5 minutes'.parseExpire(); // 300000\n'1 day'.parseExpire(); // 86400000\n'1 month'.parseExpire(); // 2419200000\n'none'.parseExpire(); // 0\n```\n\n### str.parseFloat([def])\n\nType: `method`\n\nLee el primer número decimal del texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | El valor que se devuelve cuando el texto no tiene ningún número válido. |\n\nReturns: `Number` El número analizado.\n\nEl separador decimal puede ser un punto o una coma. Un número que contiene ambos, como `1,234.5`, no es válido y devuelve el valor predeterminado.\n\nExample: Leer un número decimal\n```js\n'12.5'.parseFloat(); // 12.5\n'12,5'.parseFloat(); // 12.5\n'-3.25 kg'.parseFloat(); // -3.25\n'abc'.parseFloat(1.5); // 1.5\n```\n\n### str.parseInt([def])\n\nType: `method`\n\nLee el primer número entero del texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | El valor que se devuelve cuando el texto no tiene ningún número. |\n\nReturns: `Number` El número analizado.\n\nExample: Leer un número entero\n```js\n'123abc'.parseInt(); // 123\n' -42 '.parseInt(); // -42\n'a12b3'.parseInt(); // 12\n'abc'.parseInt(7); // 7\n```\n\n### str.parseSource([type])\n\nType: `method`\n\nConvierte una lista `id|name|icon` en un array de objetos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number or String` | no |  | Usa `Number` o `'number'` para convertir los identificadores a números. |\n\nReturns: `Array` Objetos con los campos `id`, `name` e `icon`.\n\nLos ítems se separan con comas. El nombre es, de forma predeterminada, el identificador, y el icono, un texto vacío.\n\nExample: Analizar una lista\n```js\n'1|One|ti ti-star,2|Two'.parseSource(); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti ti-star\"},{\"id\":\"2\",\"name\":\"Two\",\"icon\":\"\"}]\n'1|One,2'.parseSource(Number); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"},{\"id\":2,\"name\":\"2\",\"icon\":\"\"}]\n```\n\n### str.removeTags()\n\nType: `method`\n\nElimina las etiquetas HTML del texto.\n\nReturns: `String` El texto sin etiquetas.\n\nTodo lo que va desde un `<` hasta el siguiente `>` se trata como una etiqueta.\n\nExample: Quitar el HTML\n```js\n'<p>Hello <b>world</b></p>'.removeTags(); // \"Hello world\"\n```\n\n### str.render(model, [repository])\n\nType: `method`\n\nCompila el texto como plantilla de Tangular y lo renderiza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `Object` | yes |  | Los datos de la plantilla. |\n| `repository` | `Object` | no |  | Datos adicionales, disponibles en la plantilla como `$`. |\n\nReturns: `String` La salida renderizada.\n\nEn la guía [Plantillas con Tangular](../../guides/tangular/) se describe la sintaxis.\n\nExample: Renderizar una plantilla\n```js\n'Hello {{ name }}'.render({ name: '<Ann>' }); // \"Hello &lt;Ann&gt;\"\n'{{ $.title }}: {{ name }}'.render({ name: 'Ann' }, { title: 'User' }); // \"User: Ann\"\n```\n\n### str.ROOT([nobase])\n\nType: `method`\n\nAntepone `DEF.root` o `DEF.baseurl` a una URL relativa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `nobase` | `Boolean` | no |  | Usa `true` para ignorar `DEF.baseurl`. |\n\nReturns: `String` La URL final.\n\nSe usa `DEF.root` cuando está definido; en caso contrario, se usa `DEF.baseurl`. Ambos pueden ser una cadena o una función que recibe la URL y devuelve la nueva. Un prefijo de cadena no se añade a una URL absoluta. Las barras repetidas del resultado se reducen a una. Consulta [DEF](../def/).\n\nExample: Añadir un prefijo a una URL\n```js\nDEF.root = '/app';\n'/users/'.ROOT(); // \"/app/users/\"\n'https://www.totaljs.com/'.ROOT(); // \"https://www.totaljs.com/\"\nDEF.root = '';\n\nDEF.baseurl = '/base';\n'/users/'.ROOT(); // \"/base/users/\"\n'/users/'.ROOT(true); // \"/users/\"\nDEF.baseurl = '';\n```\n\n### str.SCOPE(element)\n\nType: `method`\n\nSustituye `?` en un path por el path del scope de un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element, jQuery, Component, Plugin or Scope` | yes |  | El objeto que proporciona el scope. |\n\nReturns: `String` El path final.\n\nUn path sin `?` se devuelve tal cual. Consulta [Scopes](../../guides/scopes/).\n\nExample: Resolver un path con scope\n```html\n<ui-plugin path=\"orders\"><div id=\"field\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tvar path = '?.name'.SCOPE($('#field'));\n\tconsole.log(path);\n}, 500);\n</script>\n```\n\n### str.slug([max])\n\nType: `method`\n\nConvierte el texto en un identificador en minúsculas y apto para URL.\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()](#toascii). Los espacios y los signos de puntuación se convierten en un único `-`, y los caracteres sin forma ASCII se eliminan.\n\nExample: Crear un slug\n```js\n'Hello World!'.slug(); // \"hello-world\"\n'  Žluťoučký kůň  '.slug(); // \"zlutoucky-kun\"\n'one two three'.slug(7); // \"one-two\"\n```\n\n### str.toASCII()\n\nType: `method`\n\nSustituye los caracteres con diacríticos por sus letras ASCII.\n\nReturns: `String` El texto convertido.\n\nLa conversión cubre los caracteres `á ä č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž ć` en mayúsculas y minúsculas. Los demás caracteres no cambian.\n\nExample: Eliminar los diacríticos\n```js\n'Žluťoučký kůň'.toASCII(); // \"Zlutoucky kun\"\n'Señor'.toASCII(); // \"Señor\"\n```\n\n### str.toSearch()\n\nType: `method`\n\nNormaliza el texto para búsquedas aproximadas.\n\nReturns: `String` El texto normalizado.\n\nEl método elimina los signos de puntuación excepto los dos puntos, convierte el texto a ASCII en minúsculas, sustituye `y` por `i` y reduce los caracteres repetidos a uno.\n\nExample: Normalizar un término de búsqueda\n```js\n'Žluťoučký Kůň!'.toSearch(); // \"zlutoucki kun\"\n'Yellow Sunny'.toSearch(); // \"ielow suni\"\n```\n\n### str.VARIABLES([args])\n\nType: `method`\n\nLee las definiciones `--name=value--` del texto y sustituye los marcadores `--name--`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Valores predefinidos. Las definiciones encontradas en el texto se añaden a este objeto. |\n\nReturns: `String` El texto procesado.\n\nLas definiciones se eliminan del texto y se guardan en `args`. Un marcador sin valor se queda en el texto.\n\nExample: Variables en un texto\n```js\n'--color=red--Color: --color--'.VARIABLES(); // \"Color: red\"\n'Size: --size--'.VARIABLES({ size: '10px' }); // \"Size: 10px\"\n'Size: --size--'.VARIABLES(); // \"Size: --size--\"\n```\n","entries":[{"type":"method","name":"arg()","signature":"str.arg(obj, [encode], [def])","since":"","deprecated":false},{"type":"method","name":"COMPILABLE()","signature":"str.COMPILABLE()","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"str.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"str.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"str.flags([path], [value], [type])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"str.format(a, [b], [c], ...)","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"str.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"str.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"str.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"str.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"str.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"str.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"str.parseConfig([def], [callback])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"str.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseEncoded()","signature":"str.parseEncoded()","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"str.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"str.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"str.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"str.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"removeTags()","signature":"str.removeTags()","since":"","deprecated":false},{"type":"method","name":"render()","signature":"str.render(model, [repository])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"str.ROOT([nobase])","since":"","deprecated":false},{"type":"method","name":"SCOPE()","signature":"str.SCOPE(element)","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"str.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"str.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"str.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"str.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammj3Amj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/string/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"String","summary":"Les méthodes que jComponent ajoute à String.prototype pour formater, analyser, valider et convertir du texte.","markdown":"---\ntitle: String\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/string/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# String\n\n> Les méthodes que jComponent ajoute à String.prototype pour formater, analyser, valider et convertir du texte.\n\njComponent ajoute ces méthodes à `String.prototype`, elles sont donc disponibles sur chaque chaîne dès que la bibliothèque est chargée. Les nombres et les dates ont leurs propres helpers sur les pages [Number](../number/) et [Date](../date/), et [Modèles avec Tangular](../../guides/tangular/) explique la syntaxe de modèle utilisée par `render()`.\n\n## API\n\n### str.arg(obj, [encode], [def])\n\nType: `method`\n\nRemplace les espaces réservés `{key}` et `{{ key }}` par des valeurs lues dans un objet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | La source des valeurs. |\n| `encode` | `Boolean, String or Function` | no |  | La façon dont les valeurs sont encodées. |\n| `def` | `String` | no |  | Le texte utilisé pour les espaces réservés sans valeur. |\n\nReturns: `String` Le texte avec les valeurs appliquées.\n\nUne clé peut être un path imbriqué comme `{user.name}`. Un espace réservé sans valeur reste dans le texte, sauf si `def` est défini. `args()` est un autre nom de la même méthode.\n\nL'argument `encode` modifie la façon dont les valeurs sont écrites :\n\n| Valeur | Résultat |\n| --- | --- |\n| `true` | La valeur est encodée pour une URL. |\n| `'escape'` | La valeur est encodée en HTML. Chaque espace réservé doit avoir une valeur. |\n| `'json'` | La valeur est écrite en JSON. Chaque espace réservé doit avoir une valeur. |\n| Fonction | `function(value, key)` renvoie le texte à écrire. |\n\nExample: Emplacements\n```js\n'Hello {name}, {age}'.arg({ name: 'Ann', age: 30 }); // \"Hello Ann, 30\"\n'Hello {{ user.name }}'.arg({ user: { name: 'Ann' } }); // \"Hello Ann\"\n'Hello {name}'.arg({}); // \"Hello {name}\"\n'Hello {name}'.arg({}, undefined, 'guest'); // \"Hello guest\"\n```\n\nExample: Encodage\n```js\n'/search?q={q}'.arg({ q: 'a b&c' }, true); // \"/search?q=a%20b%26c\"\n'<b>{name}</b>'.arg({ name: '<i>' }, 'escape'); // \"<b>&lt;i&gt;</b>\"\n'data={value}'.arg({ value: { id: 1 } }, 'json'); // \"data={\\\"id\\\":1}\"\n'{price}'.arg({ price: 2 }, (value, key) => key + '=' + (value * 2)); // \"price=4\"\n```\n\n### str.COMPILABLE()\n\nType: `method`\n\nVérifie si une chaîne HTML contient un attribut de liaison ou une déclaration de composant.\n\nReturns: `Boolean` `true` quand le texte contient l'un d'eux.\n\nLa méthode recherche les attributs `data--`, `data---`, `data-import`, `-bind` et `bind`, ainsi qu'un appel à `COMPONENT(`.\n\nExample: Vérifier un modèle\n```js\n'<div data-bind=\"user.name\"></div>'.COMPILABLE(); // true\n'<div>Hello</div>'.COMPILABLE(); // false\n```\n\n### str.encode()\n\nType: `method`\n\nEncode les caractères `<`, `>`, `&` et `\"` sous forme d'entités HTML.\n\nReturns: `String` Le texte encodé.\n\nExample: Encoder du texte\n```js\n'<a href=\"#\">Tom & Ann</a>'.encode(); // \"&lt;a href=&quot;#&quot;&gt;Tom &amp; Ann&lt;/a&gt;\"\n```\n\n### str.env()\n\nType: `method`\n\nRemplace `[key]` par une valeur de `ENV()` et `[.path]` par une valeur du modèle de données.\n\nReturns: `String` Le texte avec les valeurs appliquées.\n\nUne clé sans valeur reste dans le texte.\n\nExample: Lire des valeurs d'environnement\n```js\nENV('site', 'Docs');\nSET('common.title', 'Hello');\n'[site] page'.env(); // \"Docs page\"\n'[.common.title] page'.env(); // \"Hello page\"\n'[missing] page'.env(); // \"[missing] page\"\n```\n\n### str.flags([path], [value], [type])\n\nType: `method`\n\nSupprime les mots `@flag` du texte et émet un événement pour chacun d'eux.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Le premier argument de l'événement. |\n| `value` | `Object` | no |  | Le deuxième argument de l'événement. |\n| `type` | `Number or String` | no |  | Le troisième argument de l'événement. |\n\nReturns: `String` Le texte sans les flags.\n\nChaque flag émet l'événement `@flag name` avec les arguments `path`, `value` et `type`. Le guide [Flags et modificateurs de path](../../guides/flags/) explique comment utiliser les flags.\n\nExample: Supprimer les flags\n```js\nON('@flag hidden', function(path, value, type) {\n\tconsole.log('flag', path, value, type);\n});\n\nvar path = 'user.name @hidden'.flags('user.name', 'Ann', 1);\nconsole.log(path);\n```\n\n### str.format(a, [b], [c], ...)\n\nType: `method`\n\nRemplace les espaces réservés positionnels `{0}`, `{1}` et ainsi de suite par les arguments.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `a` | `Object` | yes |  | La valeur pour `{0}`. Chaque argument suivant remplit la position suivante. |\n\nReturns: `String` Le texte formaté.\n\nUn argument absent ou `null` écrit un texte vide. Un tableau est concaténé sans séparateur.\n\nExample: Valeurs positionnelles\n```js\n'{0} and {1}'.format('Ann', 'Bob'); // \"Ann and Bob\"\n'{0}-{1}-{2}'.format('a', null, ['x', 'y']); // \"a--xy\"\n```\n\n### str.isEmail()\n\nType: `method`\n\nVérifie si le texte est une adresse e-mail.\n\nReturns: `Boolean` `true` pour une adresse valide.\n\nExample: Valider une adresse\n```js\n'ann@example.com'.isEmail(); // true\n'ann@example'.isEmail(); // false\n```\n\n### str.isJSONDate()\n\nType: `method`\n\nVérifie si le texte a la forme d'une date sérialisée en JSON.\n\nReturns: `Boolean` `true` quand le texte a la forme `yyyy-MM-ddTHH:mm:ss.sssZ`.\n\nLa méthode vérifie la longueur, la position des séparateurs et le `Z` final. Elle ne valide pas les valeurs.\n\nExample: Détecter une date JSON\n```js\n'2026-11-18T10:20:30.000Z'.isJSONDate(); // true\n'2026-11-18'.isJSONDate(); // false\n```\n\n### str.isPhone()\n\nType: `method`\n\nVérifie si le texte est un numéro de téléphone.\n\nReturns: `Boolean` `true` pour un numéro valide.\n\nLe numéro comporte un `+` facultatif, un groupe de trois chiffres qui peut être entre parenthèses, un groupe de trois chiffres et un groupe de quatre à huit chiffres. Les groupes peuvent être séparés par un seul espace, `-` ou `.`.\n\nExample: Valider un numéro\n```js\n'+421903123456'.isPhone(); // true\n'123-456-7890'.isPhone(); // true\n'12345'.isPhone(); // false\n```\n\n### str.isURL()\n\nType: `method`\n\nVérifie si le texte est une adresse `http` ou `https`.\n\nReturns: `Boolean` `true` pour une adresse valide.\n\nExample: Valider une adresse\n```js\n'https://www.totaljs.com'.isURL(); // true\n'ftp://example.com/file'.isURL(); // false\n'totaljs.com'.isURL(); // false\n```\n\n### str.padLeft(length, [char])\n\nType: `method`\n\nAjoute un caractère à gauche jusqu'à ce que le texte atteigne une longueur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `' '` | Le caractère à ajouter. |\n\nReturns: `String` Le texte complété.\n\nUn texte déjà assez long est renvoyé tel quel.\n\nExample: Compléter à gauche\n```js\n'5'.padLeft(3, '0'); // \"005\"\n'5'.padLeft(3); // \"  5\"\n'hello'.padLeft(3, '0'); // \"hello\"\n```\n\n### str.padRight(length, [char])\n\nType: `method`\n\nAjoute un caractère à droite jusqu'à ce que le texte atteigne une longueur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `' '` | Le caractère à ajouter. |\n\nReturns: `String` Le texte complété.\n\nUn texte déjà assez long est renvoyé tel quel.\n\nExample: Compléter à droite\n```js\n'5'.padRight(3, '-'); // \"5--\"\n```\n\n### str.parseConfig([def], [callback])\n\nType: `method`\n\nAnalyse un texte `key:value;key:value` et le convertit en objet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String, Object or Function` | no |  | Les valeurs par défaut sous forme de texte de configuration ou d'objet. Une fonction est utilisée comme `callback`. |\n| `callback` | `Function` | no |  | `function(key, value)` est appelée pour chaque paire analysée. |\n\nReturns: `Object` La configuration analysée.\n\nLes valeurs `true` et `false` deviennent des booléens et les valeurs numériques deviennent des nombres. Utilise `\\:` et `\\;` pour écrire ces caractères dans une valeur ; le deux-points d'une adresse `http://`, `https://`, `ws://` ou `wss://` n'a pas besoin d'être échappé. Les clés et les valeurs passent par [env()](#env). Une paire avec plus d'un deux-points non échappé est ignorée.\n\nQuand `def` est un objet, les valeurs sont écrites dans cet objet et ce même objet est renvoyé.\n\nExample: Analyser une configuration\n```js\n'title:Hello;limit:10;visible:true'.parseConfig(); // {\"title\":\"Hello\",\"limit\":10,\"visible\":true}\n'url:https://www.totaljs.com;size:2'.parseConfig(); // {\"url\":\"https://www.totaljs.com\",\"size\":2}\n```\n\nExample: Valeurs par défaut et callback\n```js\n'limit:10'.parseConfig('limit:5;page:1'); // {\"limit\":10,\"page\":1}\n\nvar keys = [];\n'a:1;b:2'.parseConfig((key, value) => keys.push(key + '=' + value));\nkeys; // [\"a=1\",\"b=2\"]\n```\n\n### str.parseDate([format])\n\nType: `method`\n\nConvertit le texte en `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | La disposition du texte. |\n\nReturns: `Date` La date analysée, ou `null` pour un texte vide.\n\nSans `format`, la méthode lit `yyyy-MM-dd` et `dd.MM.yyyy`, éventuellement suivis d'une heure de la forme `HH:mm` ou `HH:mm:ss`, séparée par un espace ou par `T`. Un texte qui se termine par `Z` est lu comme une date UTC. Tout autre texte est passé au constructeur `Date`. Une heure seule utilise la date du jour.\n\nAvec `format`, les chiffres du texte sont lus par position, chaque valeur doit donc avoir la largeur de son jeton. Les jetons pris en charge sont `yyyy`, `yy`, `MM`, `dd`, `HH`, `mm` et `ss`. Une année à deux chiffres est ajoutée à 2000. Le format doit contenir le jour.\n\nExample: Détection automatique\n```js\n'2026-11-18 14:05:09'.parseDate().format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\n'18.11.2026'.parseDate().format('yyyy-MM-dd'); // \"2026-11-18\"\n'2026-11-18T13:05:09.000Z'.parseDate().getTime() === Date.UTC(2026, 10, 18, 13, 5, 9); // true\n''.parseDate(); // null\n```\n\nExample: Une disposition personnalisée\n```js\n'18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd'); // \"2026-11-18\"\n'20261118'.parseDate('yyyyMMdd').format('yyyy-MM-dd'); // \"2026-11-18\"\n'18.11.26 14:05'.parseDate('dd.MM.yy HH:mm').format('yyyy-MM-dd HH:mm'); // \"2026-11-18 14:05\"\n```\n\n### str.parseEncoded()\n\nType: `method`\n\nAnalyse une chaîne de requête d'URL et la convertit en objet.\n\nReturns: `Object` Les valeurs analysées.\n\nTout ce qui précède le `?` et tout ce qui suit le `#` est ignoré. Les clés et les valeurs sont décodées avec `decodeURIComponent()`, et toutes les valeurs restent des chaînes.\n\nExample: Lire une chaîne de requête\n```js\n'name=Ann&city=New%20York'.parseEncoded(); // {\"name\":\"Ann\",\"city\":\"New York\"}\n'/products/?page=2&sort=asc#top'.parseEncoded(); // {\"page\":\"2\",\"sort\":\"asc\"}\n```\n\n### str.parseExpire()\n\nType: `method`\n\nConvertit une durée comme `5 minutes` en millisecondes.\n\nReturns: `Number` La durée en millisecondes.\n\nLe texte comporte un nombre, un espace et une unité. Une unité inconnue renvoie `0`, tout comme un texte qui ne commence pas par un nombre.\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\nExample: Durées\n```js\n'30 seconds'.parseExpire(); // 30000\n'5 minutes'.parseExpire(); // 300000\n'1 day'.parseExpire(); // 86400000\n'1 month'.parseExpire(); // 2419200000\n'none'.parseExpire(); // 0\n```\n\n### str.parseFloat([def])\n\nType: `method`\n\nLit le premier nombre décimal du texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | La valeur renvoyée quand le texte ne contient aucun nombre valide. |\n\nReturns: `Number` Le nombre analysé.\n\nLe séparateur décimal peut être un point ou une virgule. Un nombre qui contient les deux, comme `1,234.5`, n'est pas valide et renvoie la valeur par défaut.\n\nExample: Lire un nombre décimal\n```js\n'12.5'.parseFloat(); // 12.5\n'12,5'.parseFloat(); // 12.5\n'-3.25 kg'.parseFloat(); // -3.25\n'abc'.parseFloat(1.5); // 1.5\n```\n\n### str.parseInt([def])\n\nType: `method`\n\nLit le premier nombre entier du texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | La valeur renvoyée quand le texte ne contient aucun nombre. |\n\nReturns: `Number` Le nombre analysé.\n\nExample: Lire un nombre entier\n```js\n'123abc'.parseInt(); // 123\n' -42 '.parseInt(); // -42\n'a12b3'.parseInt(); // 12\n'abc'.parseInt(7); // 7\n```\n\n### str.parseSource([type])\n\nType: `method`\n\nAnalyse une liste `id|name|icon` et la convertit en tableau d'objets.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number or String` | no |  | Utilise `Number` ou `'number'` pour convertir les identifiants en nombres. |\n\nReturns: `Array` Des objets avec les champs `id`, `name` et `icon`.\n\nLes éléments sont séparés par des virgules. Le nom vaut par défaut l'identifiant et l'icône un texte vide.\n\nExample: Analyser une liste\n```js\n'1|One|ti ti-star,2|Two'.parseSource(); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti ti-star\"},{\"id\":\"2\",\"name\":\"Two\",\"icon\":\"\"}]\n'1|One,2'.parseSource(Number); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"},{\"id\":2,\"name\":\"2\",\"icon\":\"\"}]\n```\n\n### str.removeTags()\n\nType: `method`\n\nSupprime les balises HTML du texte.\n\nReturns: `String` Le texte sans balises.\n\nTout ce qui se trouve entre un `<` et le `>` suivant est traité comme une balise.\n\nExample: Retirer le HTML\n```js\n'<p>Hello <b>world</b></p>'.removeTags(); // \"Hello world\"\n```\n\n### str.render(model, [repository])\n\nType: `method`\n\nCompile le texte comme un modèle Tangular et en effectue le rendu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `Object` | yes |  | Les données du modèle. |\n| `repository` | `Object` | no |  | Des données supplémentaires, disponibles dans le modèle sous le nom `$`. |\n\nReturns: `String` La sortie rendue.\n\nLe guide [Modèles avec Tangular](../../guides/tangular/) décrit la syntaxe.\n\nExample: Effectuer le rendu d'un modèle\n```js\n'Hello {{ name }}'.render({ name: '<Ann>' }); // \"Hello &lt;Ann&gt;\"\n'{{ $.title }}: {{ name }}'.render({ name: 'Ann' }, { title: 'User' }); // \"User: Ann\"\n```\n\n### str.ROOT([nobase])\n\nType: `method`\n\nAjoute `DEF.root` ou `DEF.baseurl` devant une URL relative.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `nobase` | `Boolean` | no |  | Utilise `true` pour ignorer `DEF.baseurl`. |\n\nReturns: `String` L'URL finale.\n\n`DEF.root` est utilisé quand il est défini ; sinon, c'est `DEF.baseurl`. Les deux peuvent être une chaîne ou une fonction qui reçoit l'URL et renvoie la nouvelle. Un préfixe de type chaîne n'est pas ajouté à une URL absolue. Les barres obliques répétées dans le résultat sont réduites à une seule. Consulte [DEF](../def/).\n\nExample: Préfixer une URL\n```js\nDEF.root = '/app';\n'/users/'.ROOT(); // \"/app/users/\"\n'https://www.totaljs.com/'.ROOT(); // \"https://www.totaljs.com/\"\nDEF.root = '';\n\nDEF.baseurl = '/base';\n'/users/'.ROOT(); // \"/base/users/\"\n'/users/'.ROOT(true); // \"/users/\"\nDEF.baseurl = '';\n```\n\n### str.SCOPE(element)\n\nType: `method`\n\nRemplace `?` dans un path par le path du scope d'un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element, jQuery, Component, Plugin or Scope` | yes |  | L'objet qui fournit le scope. |\n\nReturns: `String` Le path final.\n\nUn path sans `?` est renvoyé tel quel. Consulte [Scopes](../../guides/scopes/).\n\nExample: Résoudre un path dans un scope\n```html\n<ui-plugin path=\"orders\"><div id=\"field\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tvar path = '?.name'.SCOPE($('#field'));\n\tconsole.log(path);\n}, 500);\n</script>\n```\n\n### str.slug([max])\n\nType: `method`\n\nConvertit le texte en un identifiant en minuscules, adapté aux URL.\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()](#toascii). Les espaces et la ponctuation deviennent un seul `-`, et les caractères sans équivalent ASCII sont supprimés.\n\nExample: Créer un slug\n```js\n'Hello World!'.slug(); // \"hello-world\"\n'  Žluťoučký kůň  '.slug(); // \"zlutoucky-kun\"\n'one two three'.slug(7); // \"one-two\"\n```\n\n### str.toASCII()\n\nType: `method`\n\nRemplace les caractères diacritiques par leurs lettres ASCII.\n\nReturns: `String` Le texte converti.\n\nLa conversion couvre les caractères `á ä č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž ć` en minuscules et en majuscules. Les autres caractères restent inchangés.\n\nExample: Supprimer les signes diacritiques\n```js\n'Žluťoučký kůň'.toASCII(); // \"Zlutoucky kun\"\n'Señor'.toASCII(); // \"Señor\"\n```\n\n### str.toSearch()\n\nType: `method`\n\nNormalise le texte pour la recherche approximative.\n\nReturns: `String` Le texte normalisé.\n\nLa méthode supprime la ponctuation sauf le deux-points, convertit le texte en ASCII minuscule, remplace `y` par `i` et réduit les caractères répétés.\n\nExample: Normaliser un terme de recherche\n```js\n'Žluťoučký Kůň!'.toSearch(); // \"zlutoucki kun\"\n'Yellow Sunny'.toSearch(); // \"ielow suni\"\n```\n\n### str.VARIABLES([args])\n\nType: `method`\n\nLit les définitions `--name=value--` du texte et remplace les espaces réservés `--name--`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Des valeurs prédéfinies. Les définitions trouvées dans le texte sont ajoutées à cet objet. |\n\nReturns: `String` Le texte traité.\n\nLes définitions sont retirées du texte et stockées dans `args`. Un espace réservé sans valeur reste dans le texte.\n\nExample: Variables dans un texte\n```js\n'--color=red--Color: --color--'.VARIABLES(); // \"Color: red\"\n'Size: --size--'.VARIABLES({ size: '10px' }); // \"Size: 10px\"\n'Size: --size--'.VARIABLES(); // \"Size: --size--\"\n```\n","entries":[{"type":"method","name":"arg()","signature":"str.arg(obj, [encode], [def])","since":"","deprecated":false},{"type":"method","name":"COMPILABLE()","signature":"str.COMPILABLE()","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"str.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"str.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"str.flags([path], [value], [type])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"str.format(a, [b], [c], ...)","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"str.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"str.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"str.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"str.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"str.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"str.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"str.parseConfig([def], [callback])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"str.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseEncoded()","signature":"str.parseEncoded()","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"str.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"str.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"str.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"str.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"removeTags()","signature":"str.removeTags()","since":"","deprecated":false},{"type":"method","name":"render()","signature":"str.render(model, [repository])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"str.ROOT([nobase])","since":"","deprecated":false},{"type":"method","name":"SCOPE()","signature":"str.SCOPE(element)","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"str.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"str.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"str.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"str.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammj3Amj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/string/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"String","summary":"Metodi che jComponent aggiunge a String.prototype per formattare, analizzare, convalidare e convertire il testo.","markdown":"---\ntitle: String\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/string/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# String\n\n> Metodi che jComponent aggiunge a String.prototype per formattare, analizzare, convalidare e convertire il testo.\n\njComponent aggiunge questi metodi a `String.prototype`, quindi sono disponibili su ogni stringa non appena la libreria viene caricata. Numeri e date hanno i propri helper nelle pagine [Number](../number/) e [Date](../date/), e [Template con Tangular](../../guides/tangular/) spiega la sintassi dei template usata da `render()`.\n\n## API\n\n### str.arg(obj, [encode], [def])\n\nType: `method`\n\nSostituisce i segnaposto `{key}` e `{{ key }}` con i valori letti da un oggetto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | L'origine dei valori. |\n| `encode` | `Boolean, String or Function` | no |  | Come vengono codificati i valori. |\n| `def` | `String` | no |  | Il testo usato per i segnaposto senza valore. |\n\nReturns: `String` Il testo con i valori applicati.\n\nUna chiave può essere un path annidato come `{user.name}`. Un segnaposto senza valore resta nel testo, a meno che non sia impostato `def`. `args()` è un altro nome dello stesso metodo.\n\nL'argomento `encode` cambia il modo in cui vengono scritti i valori:\n\n| Valore | Risultato |\n| --- | --- |\n| `true` | Il valore viene codificato per URL. |\n| `'escape'` | Il valore viene codificato in HTML. Ogni segnaposto deve avere un valore. |\n| `'json'` | Il valore viene scritto come JSON. Ogni segnaposto deve avere un valore. |\n| Funzione | `function(value, key)` restituisce il testo da scrivere. |\n\nExample: Segnaposto\n```js\n'Hello {name}, {age}'.arg({ name: 'Ann', age: 30 }); // \"Hello Ann, 30\"\n'Hello {{ user.name }}'.arg({ user: { name: 'Ann' } }); // \"Hello Ann\"\n'Hello {name}'.arg({}); // \"Hello {name}\"\n'Hello {name}'.arg({}, undefined, 'guest'); // \"Hello guest\"\n```\n\nExample: Codifica\n```js\n'/search?q={q}'.arg({ q: 'a b&c' }, true); // \"/search?q=a%20b%26c\"\n'<b>{name}</b>'.arg({ name: '<i>' }, 'escape'); // \"<b>&lt;i&gt;</b>\"\n'data={value}'.arg({ value: { id: 1 } }, 'json'); // \"data={\\\"id\\\":1}\"\n'{price}'.arg({ price: 2 }, (value, key) => key + '=' + (value * 2)); // \"price=4\"\n```\n\n### str.COMPILABLE()\n\nType: `method`\n\nControlla se una stringa HTML contiene un attributo di associazione o una dichiarazione di componente.\n\nReturns: `Boolean` `true` quando il testo ne contiene uno.\n\nIl metodo cerca gli attributi `data--`, `data---`, `data-import`, `-bind` e `bind`, oltre a una chiamata `COMPONENT(`.\n\nExample: Controlla un template\n```js\n'<div data-bind=\"user.name\"></div>'.COMPILABLE(); // true\n'<div>Hello</div>'.COMPILABLE(); // false\n```\n\n### str.encode()\n\nType: `method`\n\nCodifica i caratteri `<`, `>`, `&` e `\"` come entità HTML.\n\nReturns: `String` Il testo codificato.\n\nExample: Codifica un testo\n```js\n'<a href=\"#\">Tom & Ann</a>'.encode(); // \"&lt;a href=&quot;#&quot;&gt;Tom &amp; Ann&lt;/a&gt;\"\n```\n\n### str.env()\n\nType: `method`\n\nSostituisce `[key]` con un valore di `ENV()` e `[.path]` con un valore del modello.\n\nReturns: `String` Il testo con i valori applicati.\n\nUna chiave senza valore resta nel testo.\n\nExample: Leggi i valori dell'ambiente\n```js\nENV('site', 'Docs');\nSET('common.title', 'Hello');\n'[site] page'.env(); // \"Docs page\"\n'[.common.title] page'.env(); // \"Hello page\"\n'[missing] page'.env(); // \"[missing] page\"\n```\n\n### str.flags([path], [value], [type])\n\nType: `method`\n\nRimuove le parole `@flag` dal testo ed emette un evento per ciascuna.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il primo argomento dell'evento. |\n| `value` | `Object` | no |  | Il secondo argomento dell'evento. |\n| `type` | `Number or String` | no |  | Il terzo argomento dell'evento. |\n\nReturns: `String` Il testo senza i flag.\n\nOgni flag emette l'evento `@flag name` con gli argomenti `path`, `value` e `type`. La guida [Flag e modificatori di path](../../guides/flags/) spiega come si usano i flag.\n\nExample: Rimuovi i flag\n```js\nON('@flag hidden', function(path, value, type) {\n\tconsole.log('flag', path, value, type);\n});\n\nvar path = 'user.name @hidden'.flags('user.name', 'Ann', 1);\nconsole.log(path);\n```\n\n### str.format(a, [b], [c], ...)\n\nType: `method`\n\nSostituisce i segnaposto posizionali `{0}`, `{1}` e così via con gli argomenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `a` | `Object` | yes |  | Il valore per `{0}`. Ogni argomento successivo riempie la posizione seguente. |\n\nReturns: `String` Il testo formattato.\n\nUn argomento mancante o `null` scrive un testo vuoto. Un array viene unito senza separatore.\n\nExample: Valori posizionali\n```js\n'{0} and {1}'.format('Ann', 'Bob'); // \"Ann and Bob\"\n'{0}-{1}-{2}'.format('a', null, ['x', 'y']); // \"a--xy\"\n```\n\n### str.isEmail()\n\nType: `method`\n\nControlla se il testo è un indirizzo email.\n\nReturns: `Boolean` `true` per un indirizzo valido.\n\nExample: Convalida un indirizzo\n```js\n'ann@example.com'.isEmail(); // true\n'ann@example'.isEmail(); // false\n```\n\n### str.isJSONDate()\n\nType: `method`\n\nControlla se il testo ha la forma di una data serializzata in JSON.\n\nReturns: `Boolean` `true` quando il testo ha la forma `yyyy-MM-ddTHH:mm:ss.sssZ`.\n\nIl metodo controlla la lunghezza, le posizioni dei separatori e la `Z` finale. Non convalida i valori.\n\nExample: Rileva una data JSON\n```js\n'2026-11-18T10:20:30.000Z'.isJSONDate(); // true\n'2026-11-18'.isJSONDate(); // false\n```\n\n### str.isPhone()\n\nType: `method`\n\nControlla se il testo è un numero di telefono.\n\nReturns: `Boolean` `true` per un numero valido.\n\nIl numero ha un `+` facoltativo, un gruppo di tre cifre che può stare tra parentesi, un gruppo di tre cifre e un gruppo da quattro a otto cifre. I gruppi possono essere separati da un singolo spazio, `-` o `.`.\n\nExample: Convalida un numero\n```js\n'+421903123456'.isPhone(); // true\n'123-456-7890'.isPhone(); // true\n'12345'.isPhone(); // false\n```\n\n### str.isURL()\n\nType: `method`\n\nControlla se il testo è un indirizzo `http` o `https`.\n\nReturns: `Boolean` `true` per un indirizzo valido.\n\nExample: Convalida un indirizzo\n```js\n'https://www.totaljs.com'.isURL(); // true\n'ftp://example.com/file'.isURL(); // false\n'totaljs.com'.isURL(); // false\n```\n\n### str.padLeft(length, [char])\n\nType: `method`\n\nAggiunge un carattere a sinistra finché il testo non raggiunge una certa lunghezza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `' '` | Il carattere da aggiungere. |\n\nReturns: `String` Il testo riempito.\n\nUn testo già abbastanza lungo viene restituito senza modifiche.\n\nExample: Riempi a sinistra\n```js\n'5'.padLeft(3, '0'); // \"005\"\n'5'.padLeft(3); // \"  5\"\n'hello'.padLeft(3, '0'); // \"hello\"\n```\n\n### str.padRight(length, [char])\n\nType: `method`\n\nAggiunge un carattere a destra finché il testo non raggiunge una certa lunghezza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `' '` | Il carattere da aggiungere. |\n\nReturns: `String` Il testo riempito.\n\nUn testo già abbastanza lungo viene restituito senza modifiche.\n\nExample: Riempi a destra\n```js\n'5'.padRight(3, '-'); // \"5--\"\n```\n\n### str.parseConfig([def], [callback])\n\nType: `method`\n\nAnalizza un testo `key:value;key:value` e lo converte in un oggetto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String, Object or Function` | no |  | I valori predefiniti come testo di configurazione o come oggetto. Una funzione viene usata come `callback`. |\n| `callback` | `Function` | no |  | `function(key, value)` viene chiamata per ogni coppia analizzata. |\n\nReturns: `Object` La configurazione analizzata.\n\nI valori `true` e `false` diventano booleani e i valori numerici diventano numeri. Usa `\\:` e `\\;` per scrivere questi caratteri in un valore; i due punti di un indirizzo `http://`, `https://`, `ws://` o `wss://` non richiedono l'escape. Chiavi e valori passano attraverso [env()](#env). Una coppia con più di due punti senza escape viene saltata.\n\nQuando `def` è un oggetto, i valori vengono scritti in quell'oggetto e viene restituito lo stesso oggetto.\n\nExample: Analizza una configurazione\n```js\n'title:Hello;limit:10;visible:true'.parseConfig(); // {\"title\":\"Hello\",\"limit\":10,\"visible\":true}\n'url:https://www.totaljs.com;size:2'.parseConfig(); // {\"url\":\"https://www.totaljs.com\",\"size\":2}\n```\n\nExample: Valori predefiniti e un callback\n```js\n'limit:10'.parseConfig('limit:5;page:1'); // {\"limit\":10,\"page\":1}\n\nvar keys = [];\n'a:1;b:2'.parseConfig((key, value) => keys.push(key + '=' + value));\nkeys; // [\"a=1\",\"b=2\"]\n```\n\n### str.parseDate([format])\n\nType: `method`\n\nConverte il testo in un `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | Il layout del testo. |\n\nReturns: `Date` La data analizzata, oppure `null` per un testo vuoto.\n\nSenza `format`, il metodo legge `yyyy-MM-dd` e `dd.MM.yyyy`, eventualmente seguiti da un orario nella forma `HH:mm` o `HH:mm:ss`, separato da uno spazio o da `T`. Un testo che termina con `Z` viene letto come data UTC. Qualsiasi altro testo passa al costruttore `Date`. Un orario da solo usa la data corrente.\n\nCon `format`, le cifre del testo vengono lette in base alla posizione, quindi ogni valore deve avere la larghezza del proprio token. I token supportati sono `yyyy`, `yy`, `MM`, `dd`, `HH`, `mm` e `ss`. Un anno a due cifre viene sommato a 2000. Il formato deve contenere il giorno.\n\nExample: Rilevamento automatico\n```js\n'2026-11-18 14:05:09'.parseDate().format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\n'18.11.2026'.parseDate().format('yyyy-MM-dd'); // \"2026-11-18\"\n'2026-11-18T13:05:09.000Z'.parseDate().getTime() === Date.UTC(2026, 10, 18, 13, 5, 9); // true\n''.parseDate(); // null\n```\n\nExample: Un layout personalizzato\n```js\n'18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd'); // \"2026-11-18\"\n'20261118'.parseDate('yyyyMMdd').format('yyyy-MM-dd'); // \"2026-11-18\"\n'18.11.26 14:05'.parseDate('dd.MM.yy HH:mm').format('yyyy-MM-dd HH:mm'); // \"2026-11-18 14:05\"\n```\n\n### str.parseEncoded()\n\nType: `method`\n\nAnalizza una stringa di query di un URL e la converte in un oggetto.\n\nReturns: `Object` I valori analizzati.\n\nTutto ciò che precede `?` e tutto ciò che segue `#` viene ignorato. Chiavi e valori vengono decodificati con `decodeURIComponent()` e tutti i valori restano stringhe.\n\nExample: Leggi una stringa di query\n```js\n'name=Ann&city=New%20York'.parseEncoded(); // {\"name\":\"Ann\",\"city\":\"New York\"}\n'/products/?page=2&sort=asc#top'.parseEncoded(); // {\"page\":\"2\",\"sort\":\"asc\"}\n```\n\n### str.parseExpire()\n\nType: `method`\n\nConverte una durata come `5 minutes` in millisecondi.\n\nReturns: `Number` La durata in millisecondi.\n\nIl testo contiene un numero, uno spazio e un'unità. Un'unità sconosciuta restituisce `0`, così come un testo che non inizia con un numero.\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\nExample: Durate\n```js\n'30 seconds'.parseExpire(); // 30000\n'5 minutes'.parseExpire(); // 300000\n'1 day'.parseExpire(); // 86400000\n'1 month'.parseExpire(); // 2419200000\n'none'.parseExpire(); // 0\n```\n\n### str.parseFloat([def])\n\nType: `method`\n\nLegge il primo numero decimale dal testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Il valore restituito quando il testo non contiene un numero valido. |\n\nReturns: `Number` Il numero analizzato.\n\nIl separatore decimale può essere un punto o una virgola. Un numero che li contiene entrambi, come `1,234.5`, non è valido e restituisce il valore predefinito.\n\nExample: Leggi un numero decimale\n```js\n'12.5'.parseFloat(); // 12.5\n'12,5'.parseFloat(); // 12.5\n'-3.25 kg'.parseFloat(); // -3.25\n'abc'.parseFloat(1.5); // 1.5\n```\n\n### str.parseInt([def])\n\nType: `method`\n\nLegge il primo numero intero dal testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Il valore restituito quando il testo non contiene un numero. |\n\nReturns: `Number` Il numero analizzato.\n\nExample: Leggi un numero intero\n```js\n'123abc'.parseInt(); // 123\n' -42 '.parseInt(); // -42\n'a12b3'.parseInt(); // 12\n'abc'.parseInt(7); // 7\n```\n\n### str.parseSource([type])\n\nType: `method`\n\nAnalizza un elenco `id|name|icon` e lo converte in un array di oggetti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number or String` | no |  | Usa `Number` o `'number'` per convertire gli identificatori in numeri. |\n\nReturns: `Array` Oggetti con i campi `id`, `name` e `icon`.\n\nGli elementi sono separati da virgole. Il nome predefinito è l'identificatore e l'icona predefinita è un testo vuoto.\n\nExample: Analizza un elenco\n```js\n'1|One|ti ti-star,2|Two'.parseSource(); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti ti-star\"},{\"id\":\"2\",\"name\":\"Two\",\"icon\":\"\"}]\n'1|One,2'.parseSource(Number); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"},{\"id\":2,\"name\":\"2\",\"icon\":\"\"}]\n```\n\n### str.removeTags()\n\nType: `method`\n\nRimuove i tag HTML dal testo.\n\nReturns: `String` Il testo senza tag.\n\nTutto ciò che va da un `<` al `>` successivo viene trattato come un tag.\n\nExample: Rimuovi l'HTML\n```js\n'<p>Hello <b>world</b></p>'.removeTags(); // \"Hello world\"\n```\n\n### str.render(model, [repository])\n\nType: `method`\n\nCompila il testo come template Tangular e ne esegue il rendering.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `Object` | yes |  | I dati del template. |\n| `repository` | `Object` | no |  | Dati aggiuntivi, disponibili nel template come `$`. |\n\nReturns: `String` L'output renderizzato.\n\nLa guida [Template con Tangular](../../guides/tangular/) descrive la sintassi.\n\nExample: Esegui il rendering di un template\n```js\n'Hello {{ name }}'.render({ name: '<Ann>' }); // \"Hello &lt;Ann&gt;\"\n'{{ $.title }}: {{ name }}'.render({ name: 'Ann' }, { title: 'User' }); // \"User: Ann\"\n```\n\n### str.ROOT([nobase])\n\nType: `method`\n\nAntepone `DEF.root` o `DEF.baseurl` a un URL relativo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `nobase` | `Boolean` | no |  | Usa `true` per ignorare `DEF.baseurl`. |\n\nReturns: `String` L'URL finale.\n\nViene usato `DEF.root` quando è impostato, altrimenti `DEF.baseurl`. Entrambi possono essere una stringa o una funzione che riceve l'URL e restituisce quello nuovo. Un prefisso stringa non viene aggiunto a un URL assoluto. Le barre ripetute nel risultato vengono ridotte a una sola. Vedi [DEF](../def/).\n\nExample: Aggiungi un prefisso a un URL\n```js\nDEF.root = '/app';\n'/users/'.ROOT(); // \"/app/users/\"\n'https://www.totaljs.com/'.ROOT(); // \"https://www.totaljs.com/\"\nDEF.root = '';\n\nDEF.baseurl = '/base';\n'/users/'.ROOT(); // \"/base/users/\"\n'/users/'.ROOT(true); // \"/users/\"\nDEF.baseurl = '';\n```\n\n### str.SCOPE(element)\n\nType: `method`\n\nSostituisce `?` in un path con il path dello scope di un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element, jQuery, Component, Plugin or Scope` | yes |  | L'oggetto che fornisce lo scope. |\n\nReturns: `String` Il path finale.\n\nUn path senza `?` viene restituito così com'è. Vedi [Scope](../../guides/scopes/).\n\nExample: Risolvi un path con scope\n```html\n<ui-plugin path=\"orders\"><div id=\"field\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tvar path = '?.name'.SCOPE($('#field'));\n\tconsole.log(path);\n}, 500);\n</script>\n```\n\n### str.slug([max])\n\nType: `method`\n\nConverte il testo in un identificatore minuscolo adatto agli URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | La lunghezza massima. |\n\nReturns: `String` Lo slug.\n\nI diacritici vengono convertiti con [toASCII()](#toascii). Spazi e punteggiatura diventano un singolo `-` e i caratteri senza una forma ASCII vengono rimossi.\n\nExample: Crea uno slug\n```js\n'Hello World!'.slug(); // \"hello-world\"\n'  Žluťoučký kůň  '.slug(); // \"zlutoucky-kun\"\n'one two three'.slug(7); // \"one-two\"\n```\n\n### str.toASCII()\n\nType: `method`\n\nSostituisce i caratteri con diacritici con le rispettive lettere ASCII.\n\nReturns: `String` Il testo convertito.\n\nLa conversione riguarda i caratteri `á ä č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž ć`, sia maiuscoli sia minuscoli. Gli altri caratteri restano invariati.\n\nExample: Rimuovi i diacritici\n```js\n'Žluťoučký kůň'.toASCII(); // \"Zlutoucky kun\"\n'Señor'.toASCII(); // \"Señor\"\n```\n\n### str.toSearch()\n\nType: `method`\n\nNormalizza il testo per la ricerca approssimata.\n\nReturns: `String` Il testo normalizzato.\n\nIl metodo rimuove la punteggiatura tranne i due punti, converte il testo in ASCII minuscolo, sostituisce `y` con `i` e comprime i caratteri ripetuti.\n\nExample: Normalizza un termine di ricerca\n```js\n'Žluťoučký Kůň!'.toSearch(); // \"zlutoucki kun\"\n'Yellow Sunny'.toSearch(); // \"ielow suni\"\n```\n\n### str.VARIABLES([args])\n\nType: `method`\n\nLegge le definizioni `--name=value--` dal testo e sostituisce i segnaposto `--name--`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Valori predefiniti. Le definizioni trovate nel testo vengono aggiunte a questo oggetto. |\n\nReturns: `String` Il testo elaborato.\n\nLe definizioni vengono rimosse dal testo e memorizzate in `args`. Un segnaposto senza valore resta nel testo.\n\nExample: Variabili in un testo\n```js\n'--color=red--Color: --color--'.VARIABLES(); // \"Color: red\"\n'Size: --size--'.VARIABLES({ size: '10px' }); // \"Size: 10px\"\n'Size: --size--'.VARIABLES(); // \"Size: --size--\"\n```\n","entries":[{"type":"method","name":"arg()","signature":"str.arg(obj, [encode], [def])","since":"","deprecated":false},{"type":"method","name":"COMPILABLE()","signature":"str.COMPILABLE()","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"str.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"str.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"str.flags([path], [value], [type])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"str.format(a, [b], [c], ...)","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"str.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"str.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"str.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"str.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"str.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"str.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"str.parseConfig([def], [callback])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"str.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseEncoded()","signature":"str.parseEncoded()","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"str.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"str.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"str.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"str.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"removeTags()","signature":"str.removeTags()","since":"","deprecated":false},{"type":"method","name":"render()","signature":"str.render(model, [repository])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"str.ROOT([nobase])","since":"","deprecated":false},{"type":"method","name":"SCOPE()","signature":"str.SCOPE(element)","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"str.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"str.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"str.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"str.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammj3Amj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/string/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"String","summary":"Metódy, ktoré jComponent pridáva do String.prototype na formátovanie, spracovanie, overovanie a prevod textu.","markdown":"---\ntitle: String\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/string/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# String\n\n> Metódy, ktoré jComponent pridáva do String.prototype na formátovanie, spracovanie, overovanie a prevod textu.\n\njComponent pridáva tieto metódy do `String.prototype`, takže sú dostupné na každom reťazci hneď po načítaní knižnice. Čísla a dátumy majú vlastné helpery na stránkach [Number](../number/) a [Date](../date/) a syntax šablón, ktorú používa `render()`, vysvetľuje časť [Šablóny s Tangular](../../guides/tangular/).\n\n## API\n\n### str.arg(obj, [encode], [def])\n\nType: `method`\n\nNahradí zástupné symboly `{key}` a `{{ key }}` hodnotami prečítanými z objektu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | Zdroj hodnôt. |\n| `encode` | `Boolean, String or Function` | no |  | Spôsob kódovania hodnôt. |\n| `def` | `String` | no |  | Text použitý pre zástupné symboly bez hodnoty. |\n\nReturns: `String` Text s doplnenými hodnotami.\n\nKľúč môže byť vnorená path, napríklad `{user.name}`. Zástupný symbol bez hodnoty zostane v texte, pokiaľ nie je nastavený `def`. `args()` je iný názov tej istej metódy.\n\nArgument `encode` mení spôsob zápisu hodnôt:\n\n| Hodnota | Výsledok |\n| --- | --- |\n| `true` | Hodnota sa zakóduje pre URL. |\n| `'escape'` | Hodnota sa zakóduje pre HTML. Každý zástupný symbol musí mať hodnotu. |\n| `'json'` | Hodnota sa zapíše ako JSON. Každý zástupný symbol musí mať hodnotu. |\n| Funkcia | `function(value, key)` vráti text, ktorý sa má zapísať. |\n\nExample: Zástupné symboly\n```js\n'Hello {name}, {age}'.arg({ name: 'Ann', age: 30 }); // \"Hello Ann, 30\"\n'Hello {{ user.name }}'.arg({ user: { name: 'Ann' } }); // \"Hello Ann\"\n'Hello {name}'.arg({}); // \"Hello {name}\"\n'Hello {name}'.arg({}, undefined, 'guest'); // \"Hello guest\"\n```\n\nExample: Kódovanie\n```js\n'/search?q={q}'.arg({ q: 'a b&c' }, true); // \"/search?q=a%20b%26c\"\n'<b>{name}</b>'.arg({ name: '<i>' }, 'escape'); // \"<b>&lt;i&gt;</b>\"\n'data={value}'.arg({ value: { id: 1 } }, 'json'); // \"data={\\\"id\\\":1}\"\n'{price}'.arg({ price: 2 }, (value, key) => key + '=' + (value * 2)); // \"price=4\"\n```\n\n### str.COMPILABLE()\n\nType: `method`\n\nSkontroluje, či reťazec HTML obsahuje atribút väzby alebo deklaráciu komponentu.\n\nReturns: `Boolean` `true`, keď text obsahuje niektorý z nich.\n\nMetóda hľadá atribúty `data--`, `data---`, `data-import`, `-bind` a `bind` a volanie `COMPONENT(`.\n\nExample: Skontroluj šablónu\n```js\n'<div data-bind=\"user.name\"></div>'.COMPILABLE(); // true\n'<div>Hello</div>'.COMPILABLE(); // false\n```\n\n### str.encode()\n\nType: `method`\n\nZakóduje znaky `<`, `>`, `&` a `\"` ako entity HTML.\n\nReturns: `String` Zakódovaný text.\n\nExample: Zakóduj text\n```js\n'<a href=\"#\">Tom & Ann</a>'.encode(); // \"&lt;a href=&quot;#&quot;&gt;Tom &amp; Ann&lt;/a&gt;\"\n```\n\n### str.env()\n\nType: `method`\n\nNahradí `[key]` hodnotou z `ENV()` a `[.path]` hodnotou z modelu.\n\nReturns: `String` Text s doplnenými hodnotami.\n\nKľúč bez hodnoty zostane v texte.\n\nExample: Prečítaj hodnoty prostredia\n```js\nENV('site', 'Docs');\nSET('common.title', 'Hello');\n'[site] page'.env(); // \"Docs page\"\n'[.common.title] page'.env(); // \"Hello page\"\n'[missing] page'.env(); // \"[missing] page\"\n```\n\n### str.flags([path], [value], [type])\n\nType: `method`\n\nOdstráni z textu slová `@flag` a pre každé z nich vyvolá udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Prvý argument udalosti. |\n| `value` | `Object` | no |  | Druhý argument udalosti. |\n| `type` | `Number or String` | no |  | Tretí argument udalosti. |\n\nReturns: `String` Text bez flagov.\n\nKaždý flag vyvolá udalosť `@flag name` s argumentmi `path`, `value` a `type`. Ako sa flagy používajú, vysvetľuje príručka [Flagy a modifikátory path](../../guides/flags/).\n\nExample: Odstráň flagy\n```js\nON('@flag hidden', function(path, value, type) {\n\tconsole.log('flag', path, value, type);\n});\n\nvar path = 'user.name @hidden'.flags('user.name', 'Ann', 1);\nconsole.log(path);\n```\n\n### str.format(a, [b], [c], ...)\n\nType: `method`\n\nNahradí pozičné zástupné symboly `{0}`, `{1}` a ďalšie argumentmi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `a` | `Object` | yes |  | Hodnota pre `{0}`. Každý ďalší argument vyplní nasledujúcu pozíciu. |\n\nReturns: `String` Naformátovaný text.\n\nPri chýbajúcom argumente alebo argumente `null` sa zapíše prázdny text. Pole sa spojí bez oddeľovača.\n\nExample: Pozičné hodnoty\n```js\n'{0} and {1}'.format('Ann', 'Bob'); // \"Ann and Bob\"\n'{0}-{1}-{2}'.format('a', null, ['x', 'y']); // \"a--xy\"\n```\n\n### str.isEmail()\n\nType: `method`\n\nSkontroluje, či je text e-mailová adresa.\n\nReturns: `Boolean` `true` pre platnú adresu.\n\nExample: Over adresu\n```js\n'ann@example.com'.isEmail(); // true\n'ann@example'.isEmail(); // false\n```\n\n### str.isJSONDate()\n\nType: `method`\n\nSkontroluje, či má text tvar dátumu serializovaného do JSON.\n\nReturns: `Boolean` `true`, keď má text tvar `yyyy-MM-ddTHH:mm:ss.sssZ`.\n\nMetóda kontroluje dĺžku, pozície oddeľovačov a koncové `Z`. Hodnoty neoveruje.\n\nExample: Rozpoznaj dátum JSON\n```js\n'2026-11-18T10:20:30.000Z'.isJSONDate(); // true\n'2026-11-18'.isJSONDate(); // false\n```\n\n### str.isPhone()\n\nType: `method`\n\nSkontroluje, či je text telefónne číslo.\n\nReturns: `Boolean` `true` pre platné číslo.\n\nČíslo má voliteľné `+`, skupinu troch číslic, ktorá môže byť v zátvorkách, skupinu troch číslic a skupinu štyroch až ôsmich číslic. Skupiny môžu byť oddelené jednou medzerou, `-` alebo `.`.\n\nExample: Over číslo\n```js\n'+421903123456'.isPhone(); // true\n'123-456-7890'.isPhone(); // true\n'12345'.isPhone(); // false\n```\n\n### str.isURL()\n\nType: `method`\n\nSkontroluje, či je text adresa `http` alebo `https`.\n\nReturns: `Boolean` `true` pre platnú adresu.\n\nExample: Over adresu\n```js\n'https://www.totaljs.com'.isURL(); // true\n'ftp://example.com/file'.isURL(); // false\n'totaljs.com'.isURL(); // false\n```\n\n### str.padLeft(length, [char])\n\nType: `method`\n\nPridáva znak na ľavú stranu, kým text nedosiahne zadanú dĺžku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `' '` | Znak, ktorý sa má pridať. |\n\nReturns: `String` Doplnený text.\n\nText, ktorý je už dostatočne dlhý, sa vráti bez zmeny.\n\nExample: Doplň zľava\n```js\n'5'.padLeft(3, '0'); // \"005\"\n'5'.padLeft(3); // \"  5\"\n'hello'.padLeft(3, '0'); // \"hello\"\n```\n\n### str.padRight(length, [char])\n\nType: `method`\n\nPridáva znak na pravú stranu, kým text nedosiahne zadanú dĺžku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `' '` | Znak, ktorý sa má pridať. |\n\nReturns: `String` Doplnený text.\n\nText, ktorý je už dostatočne dlhý, sa vráti bez zmeny.\n\nExample: Doplň sprava\n```js\n'5'.padRight(3, '-'); // \"5--\"\n```\n\n### str.parseConfig([def], [callback])\n\nType: `method`\n\nSpracuje text `key:value;key:value` na objekt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String, Object or Function` | no |  | Predvolené hodnoty ako konfiguračný text alebo objekt. Funkcia sa použije ako `callback`. |\n| `callback` | `Function` | no |  | `function(key, value)` sa zavolá pre každú spracovanú dvojicu. |\n\nReturns: `Object` Analyzovaná konfigurácia.\n\nHodnoty `true` a `false` sa stanú logickými hodnotami a číselné hodnoty číslami. Ak chceš tieto znaky zapísať do hodnoty, použi `\\:` a `\\;`; dvojbodku v adrese `http://`, `https://`, `ws://` alebo `wss://` escapovať netreba. Kľúče a hodnoty prechádzajú cez [env()](#env). Dvojica s viac ako jednou neescapovanou dvojbodkou sa preskočí.\n\nKeď je `def` objekt, hodnoty sa zapíšu do tohto objektu a vráti sa ten istý objekt.\n\nExample: Spracuj konfiguráciu\n```js\n'title:Hello;limit:10;visible:true'.parseConfig(); // {\"title\":\"Hello\",\"limit\":10,\"visible\":true}\n'url:https://www.totaljs.com;size:2'.parseConfig(); // {\"url\":\"https://www.totaljs.com\",\"size\":2}\n```\n\nExample: Predvolené hodnoty a callback\n```js\n'limit:10'.parseConfig('limit:5;page:1'); // {\"limit\":10,\"page\":1}\n\nvar keys = [];\n'a:1;b:2'.parseConfig((key, value) => keys.push(key + '=' + value));\nkeys; // [\"a=1\",\"b=2\"]\n```\n\n### str.parseDate([format])\n\nType: `method`\n\nPrevedie text na `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | Rozloženie textu. |\n\nReturns: `Date` Spracovaný dátum alebo `null` pre prázdny text.\n\nBez `format` metóda číta `yyyy-MM-dd` a `dd.MM.yyyy`, za ktorými môže nasledovať čas v tvare `HH:mm` alebo `HH:mm:ss`, oddelený medzerou alebo `T`. Text končiaci na `Z` sa číta ako dátum UTC. Akýkoľvek iný text sa odovzdá konštruktoru `Date`. Samotný čas použije aktuálny dátum.\n\nS `format` sa číslice textu čítajú podľa pozície, takže každá hodnota musí mať šírku svojho tokenu. Podporované tokeny sú `yyyy`, `yy`, `MM`, `dd`, `HH`, `mm` a `ss`. K dvojcifernému roku sa pripočíta 2000. Formát musí obsahovať deň.\n\nExample: Automatické rozpoznanie\n```js\n'2026-11-18 14:05:09'.parseDate().format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\n'18.11.2026'.parseDate().format('yyyy-MM-dd'); // \"2026-11-18\"\n'2026-11-18T13:05:09.000Z'.parseDate().getTime() === Date.UTC(2026, 10, 18, 13, 5, 9); // true\n''.parseDate(); // null\n```\n\nExample: Vlastné rozloženie\n```js\n'18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd'); // \"2026-11-18\"\n'20261118'.parseDate('yyyyMMdd').format('yyyy-MM-dd'); // \"2026-11-18\"\n'18.11.26 14:05'.parseDate('dd.MM.yy HH:mm').format('yyyy-MM-dd HH:mm'); // \"2026-11-18 14:05\"\n```\n\n### str.parseEncoded()\n\nType: `method`\n\nSpracuje reťazec dotazu URL na objekt.\n\nReturns: `Object` Spracované hodnoty.\n\nVšetko po znak `?` a všetko za znakom `#` sa ignoruje. Kľúče a hodnoty sa dekódujú pomocou `decodeURIComponent()` a všetky hodnoty zostávajú reťazcami.\n\nExample: Prečítaj reťazec dotazu\n```js\n'name=Ann&city=New%20York'.parseEncoded(); // {\"name\":\"Ann\",\"city\":\"New York\"}\n'/products/?page=2&sort=asc#top'.parseEncoded(); // {\"page\":\"2\",\"sort\":\"asc\"}\n```\n\n### str.parseExpire()\n\nType: `method`\n\nPrevedie trvanie, napríklad `5 minutes`, na milisekundy.\n\nReturns: `Number` Trvanie v milisekundách.\n\nText obsahuje číslo, medzeru a jednotku. Neznáma jednotka vráti `0` a rovnako aj text, ktorý sa nezačína číslom.\n\n| Jednotka | Akceptované 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\nExample: Trvania\n```js\n'30 seconds'.parseExpire(); // 30000\n'5 minutes'.parseExpire(); // 300000\n'1 day'.parseExpire(); // 86400000\n'1 month'.parseExpire(); // 2419200000\n'none'.parseExpire(); // 0\n```\n\n### str.parseFloat([def])\n\nType: `method`\n\nPrečíta z textu prvé desatinné číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Hodnota vrátená, keď text neobsahuje platné číslo. |\n\nReturns: `Number` Analyzované číslo.\n\nDesatinný oddeľovač môže byť bodka alebo čiarka. Číslo, ktoré obsahuje oba, napríklad `1,234.5`, nie je platné a vráti predvolenú hodnotu.\n\nExample: Prečítaj desatinné číslo\n```js\n'12.5'.parseFloat(); // 12.5\n'12,5'.parseFloat(); // 12.5\n'-3.25 kg'.parseFloat(); // -3.25\n'abc'.parseFloat(1.5); // 1.5\n```\n\n### str.parseInt([def])\n\nType: `method`\n\nPrečíta z textu prvé celé číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Hodnota vrátená, keď text neobsahuje číslo. |\n\nReturns: `Number` Analyzované číslo.\n\nExample: Prečítaj celé číslo\n```js\n'123abc'.parseInt(); // 123\n' -42 '.parseInt(); // -42\n'a12b3'.parseInt(); // 12\n'abc'.parseInt(7); // 7\n```\n\n### str.parseSource([type])\n\nType: `method`\n\nSpracuje zoznam `id|name|icon` na pole objektov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Number or String` | no |  | Ak chceš previesť identifikátory na čísla, použi `Number` alebo `'number'`. |\n\nReturns: `Array` Objekty s poľami `id`, `name` a `icon`.\n\nPoložky sú oddelené čiarkami. Predvolený názov je identifikátor a predvolená ikona je prázdny text.\n\nExample: Analyzuj zoznam\n```js\n'1|One|ti ti-star,2|Two'.parseSource(); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti ti-star\"},{\"id\":\"2\",\"name\":\"Two\",\"icon\":\"\"}]\n'1|One,2'.parseSource(Number); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"},{\"id\":2,\"name\":\"2\",\"icon\":\"\"}]\n```\n\n### str.removeTags()\n\nType: `method`\n\nOdstráni z textu značky HTML.\n\nReturns: `String` Text bez značiek.\n\nVšetko od znaku `<` po nasledujúci znak `>` sa považuje za značku.\n\nExample: Odstráň HTML\n```js\n'<p>Hello <b>world</b></p>'.removeTags(); // \"Hello world\"\n```\n\n### str.render(model, [repository])\n\nType: `method`\n\nSkompiluje text ako šablónu Tangular a vykreslí ju.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `model` | `Object` | yes |  | Údaje šablóny. |\n| `repository` | `Object` | no |  | Ďalšie údaje, ktoré sú v šablóne dostupné ako `$`. |\n\nReturns: `String` Vykreslený výstup.\n\nSyntax popisuje príručka [Šablóny s Tangular](../../guides/tangular/).\n\nExample: Vykresli šablónu\n```js\n'Hello {{ name }}'.render({ name: '<Ann>' }); // \"Hello &lt;Ann&gt;\"\n'{{ $.title }}: {{ name }}'.render({ name: 'Ann' }, { title: 'User' }); // \"User: Ann\"\n```\n\n### str.ROOT([nobase])\n\nType: `method`\n\nPridá pred relatívnu URL `DEF.root` alebo `DEF.baseurl`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `nobase` | `Boolean` | no |  | Použi `true`, ak chceš ignorovať `DEF.baseurl`. |\n\nReturns: `String` Výsledná URL.\n\nPoužije sa `DEF.root`, ak je nastavený; inak sa použije `DEF.baseurl`. Oba môžu byť reťazec alebo funkcia, ktorá dostane URL a vráti novú. Reťazcová predpona sa k absolútnej URL nepridáva. Opakované lomky sa vo výsledku zredukujú na jednu. Pozri [DEF](../def/).\n\nExample: Pridaj predponu k URL\n```js\nDEF.root = '/app';\n'/users/'.ROOT(); // \"/app/users/\"\n'https://www.totaljs.com/'.ROOT(); // \"https://www.totaljs.com/\"\nDEF.root = '';\n\nDEF.baseurl = '/base';\n'/users/'.ROOT(); // \"/base/users/\"\n'/users/'.ROOT(true); // \"/users/\"\nDEF.baseurl = '';\n```\n\n### str.SCOPE(element)\n\nType: `method`\n\nNahradí `?` v path za path scopu elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element, jQuery, Component, Plugin or Scope` | yes |  | Objekt, ktorý určuje scope. |\n\nReturns: `String` Výsledná path.\n\nPath bez `?` sa vráti tak, ako je. Pozri [Scopy](../../guides/scopes/).\n\nExample: Prelož path v scope\n```html\n<ui-plugin path=\"orders\"><div id=\"field\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tvar path = '?.name'.SCOPE($('#field'));\n\tconsole.log(path);\n}, 500);\n</script>\n```\n\n### str.slug([max])\n\nType: `method`\n\nPrevedie text na identifikátor malými písmenami vhodný do URL.\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()](#toascii). Medzery a interpunkcia sa zmenia na jeden znak `-` a znaky bez tvaru ASCII sa odstránia.\n\nExample: Vytvor slug\n```js\n'Hello World!'.slug(); // \"hello-world\"\n'  Žluťoučký kůň  '.slug(); // \"zlutoucky-kun\"\n'one two three'.slug(7); // \"one-two\"\n```\n\n### str.toASCII()\n\nType: `method`\n\nNahradí znaky s diakritikou ich písmenami ASCII.\n\nReturns: `String` Prevedený text.\n\nPrevod pokrýva znaky `á ä č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž ć` v oboch veľkostiach. Ostatné znaky zostávajú bez zmeny.\n\nExample: Odstráň diakritiku\n```js\n'Žluťoučký kůň'.toASCII(); // \"Zlutoucky kun\"\n'Señor'.toASCII(); // \"Señor\"\n```\n\n### str.toSearch()\n\nType: `method`\n\nNormalizuje text na približné vyhľadávanie.\n\nReturns: `String` Normalizovaný text.\n\nMetóda odstráni interpunkciu okrem dvojbodky, prevedie text na malé písmená ASCII, nahradí `y` za `i` a zlúči opakované znaky.\n\nExample: Normalizuj hľadaný výraz\n```js\n'Žluťoučký Kůň!'.toSearch(); // \"zlutoucki kun\"\n'Yellow Sunny'.toSearch(); // \"ielow suni\"\n```\n\n### str.VARIABLES([args])\n\nType: `method`\n\nPrečíta z textu definície `--name=value--` a nahradí zástupné symboly `--name--`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Preddefinované hodnoty. Definície nájdené v texte sa pridajú do tohto objektu. |\n\nReturns: `String` Spracovaný text.\n\nDefinície sa z textu odstránia a uložia do `args`. Zástupný symbol bez hodnoty zostane v texte.\n\nExample: Premenné v texte\n```js\n'--color=red--Color: --color--'.VARIABLES(); // \"Color: red\"\n'Size: --size--'.VARIABLES({ size: '10px' }); // \"Size: 10px\"\n'Size: --size--'.VARIABLES(); // \"Size: --size--\"\n```\n","entries":[{"type":"method","name":"arg()","signature":"str.arg(obj, [encode], [def])","since":"","deprecated":false},{"type":"method","name":"COMPILABLE()","signature":"str.COMPILABLE()","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"str.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"str.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"str.flags([path], [value], [type])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"str.format(a, [b], [c], ...)","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"str.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"str.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"str.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"str.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"str.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"str.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"str.parseConfig([def], [callback])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"str.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseEncoded()","signature":"str.parseEncoded()","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"str.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"str.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"str.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"str.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"removeTags()","signature":"str.removeTags()","since":"","deprecated":false},{"type":"method","name":"render()","signature":"str.render(model, [repository])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"str.ROOT([nobase])","since":"","deprecated":false},{"type":"method","name":"SCOPE()","signature":"str.SCOPE(element)","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"str.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"str.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"str.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"str.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammgn84j61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/number/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Number","summary":"Methods that jComponent adds to Number.prototype for calculating, rounding and formatting numbers.","markdown":"---\ntitle: Number\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/number/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Number\n\n> Methods that jComponent adds to Number.prototype for calculating, rounding and formatting numbers.\n\njComponent adds these methods to `Number.prototype`. Write a number literal in parentheses to call a method on it, for example `(5).add(3)`. The separators and currencies used here come from [DEF](../def/), and templates reach the same formatting through the [Tangular helpers](../tangular-helpers/).\n\n## API\n\n### num.add(value, [decimals])\n\nType: `method`\n\nAdds a number or applies an operation written as text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number or String` | yes |  | The number to add, or the operation. |\n| `decimals` | `Number` | no |  | Rounds a text operation down to this number of decimals. |\n\nReturns: `Number` The result.\n\nA number is added to the current value. A text starts with an operator:\n\n| Text | Result for `200` |\n| --- | --- |\n| `'+10'` | `210` |\n| `'-10'` | `190` |\n| `'*10'` | `2000` |\n| `'/10'` | `20` |\n| `'+10%'` | `220` |\n| `'-10%'` | `180` |\n| `'10%'` | `20` |\n\n`inc()` is another name for the same method.\n\nExample: Operations\n```js\n(5).add(3); // 8\n(200).add('+10'); // 210\n(200).add('*10'); // 2000\n(200).add('+10%'); // 220\n(200).add('-10%'); // 180\n(200).add('10%'); // 20\n(10).add('/3', 2); // 3.33\n```\n\n### num.between(condition, [otherwise])\n\nType: `method`\n\nReturns the value assigned to the range that contains the number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Object` | yes |  | The ranges and their values. |\n| `otherwise` | `Object` | no |  | The value returned when no range matches. |\n\nReturns: `Object` The value of the matching range, or `otherwise`.\n\nEach key of `condition` is a range: `'0-3'` includes both limits, `'7-'` means 7 or more and `'-3'` means 3 or less. Ranges are checked in the order of the keys and the first match wins. The limits cannot be negative numbers.\n\nExample: Pick a label\n```js\nvar ranges = { '0-3': 'low', '4-6': 'medium', '7-': 'high' };\n(5).between(ranges); // \"medium\"\n(9).between(ranges); // \"high\"\n(2).between({ '5-9': 'middle' }, 'other'); // \"other\"\n```\n\n### num.currency([currency], [a], [b], [c])\n\nType: `method`\n\nFormats the number with a formatter registered in `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `currency` | `String` | no |  | The currency code. |\n| `a` | `Object` | no |  | A custom argument for the formatter. |\n| `b` | `Object` | no |  | A custom argument for the formatter. |\n| `c` | `Object` | no |  | A custom argument for the formatter. |\n\nReturns: `String` The formatted amount.\n\nA formatter is a `function(value, a, b, c)` stored under its code. When `currency` is missing, `DEF.currency` is used. A code in the form `[key]` is read from `ENV()`. Without a matching formatter, the number is written with two decimals.\n\nExample: Register a currency\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\n(1234.5).currency('eur'); // \"1 234.50 EUR\"\n(1234.5).currency('unknown'); // \"1 234.50\"\n```\n\n### num.floor(decimals)\n\nType: `method`\n\nRounds the number down to a number of decimals.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | The number of decimals. Use `0` for a whole number. |\n\nReturns: `Number` The rounded number.\n\nExample: Round down\n```js\n(1.999).floor(2); // 1.99\n(5.5).floor(0); // 5\n(-1.555).floor(2); // -1.56\n```\n\n### num.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nWrites the number with a thousands separator and a fixed number of decimals.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | The number of decimals. |\n| `separator` | `String` | no |  | The thousands separator. |\n| `decimalSeparator` | `String` | no |  | The decimal separator. |\n\nReturns: `String` The formatted number.\n\nExtra decimals are cut off, not rounded; use [round()](#round) first when rounding matters. Without `decimals`, the number keeps its own decimals. The separators default to `DEF.thousandsseparator` (a space) and `DEF.decimalseparator` (a dot).\n\nWhen the first argument is a text, it has one of two meanings. A text in the form `[key]` reads an existing `ENV()` value, which is the number of decimals or an object with the fields `decimals`, `separator` and `decimalseparator`. Any other text is the thousands separator, and the second argument is then the number of decimals.\n\nExample: Decimals and separators\n```js\n(1234567.891).format(); // \"1 234 567.891\"\n(1234.5).format(2); // \"1 234.50\"\n(1.999).format(2); // \"1.99\"\n(1234.5).format(0); // \"1 234\"\n(1234.5).format(2, '.', ','); // \"1.234,50\"\n(1234.5).format(','); // \"1,234.5\"\n```\n\nExample: Settings from the environment\n```js\nENV('price', { decimals: 1, separator: ',', decimalseparator: '.' });\n(1234.56).format('[price]'); // \"1,234.5\"\n```\n\n### num.padLeft(length, [char])\n\nType: `method`\n\nWrites the number as text and pads it on the left side.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `'0'` | The character to add. |\n\nReturns: `String` The padded text.\n\nExample: Leading zeros\n```js\n(5).padLeft(3); // \"005\"\n(5).padLeft(3, ' '); // \"  5\"\n```\n\n### num.padRight(length, [char])\n\nType: `method`\n\nWrites the number as text and pads it on the right side.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `'0'` | The character to add. |\n\nReturns: `String` The padded text.\n\nExample: Trailing characters\n```js\n(5).padRight(3); // \"500\"\n(5).padRight(3, 'x'); // \"5xx\"\n```\n\n### num.parseDate([offset])\n\nType: `method`\n\nCreates a `Date` from a number of milliseconds.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Milliseconds added to the number. |\n\nReturns: `Date` The new date.\n\nExample: From a timestamp\n```js\n(1700000000000).parseDate().getTime(); // 1700000000000\n(1700000000000).parseDate(1000).getTime(); // 1700000001000\n```\n\n### num.pluralize(zero, one, few, other)\n\nType: `method`\n\nChooses a text by the size of the number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | The text for 0, or all four forms. |\n| `one` | `String` | yes |  | The text for 1. |\n| `few` | `String` | yes |  | The text for numbers greater than 1 and lower than 5. |\n| `other` | `String` | yes |  | The text for all other numbers. |\n\nReturns: `String` The chosen text.\n\nThe text `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 chosen text, `#` writes the number and `##` writes it with [format()](#format).\n\nThe four forms can also be passed as one array or as one text separated by commas. A text in the form `[key]` is read from `ENV()`. All four forms are required.\n\nExample: Choose a form\n```js\n(0).pluralize('no items', '# item', '# items', '# items'); // \"no items\"\n(1).pluralize('no items', '# item', '# items', '# items'); // \"1 item\"\n(3).pluralize('no items', '# item', '# items', '# items'); // \"3 items\"\n(5000).pluralize('none', 'one', 'few', '## items'); // \"5 000 items\"\n(2).pluralize('none,one,few,many'); // \"few\"\n(7).pluralize(['none', 'one', 'few', 'many']); // \"many\"\n```\n\n### num.round([decimals])\n\nType: `method`\n\nRounds the number to a number of decimals.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | The number of decimals. |\n\nReturns: `Number` The rounded number.\n\nThe number of decimals cannot be negative.\n\nExample: Round a number\n```js\n(1.005).round(2); // 1.01\n(1.5).round(); // 2\n(1.4).round(); // 1\n```\n","entries":[{"type":"method","name":"add()","signature":"num.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"between()","signature":"num.between(condition, [otherwise])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"num.currency([currency], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"num.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"num.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"num.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"num.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"num.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"num.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"num.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammgn84j61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/number/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Number","summary":"Methoden, die jComponent zu Number.prototype hinzufügt, um Zahlen zu berechnen, zu runden und zu formatieren.","markdown":"---\ntitle: Number\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/number/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Number\n\n> Methoden, die jComponent zu Number.prototype hinzufügt, um Zahlen zu berechnen, zu runden und zu formatieren.\n\njComponent fügt diese Methoden zu `Number.prototype` hinzu. Schreibe ein Zahlenliteral in Klammern, um eine Methode darauf aufzurufen, zum Beispiel `(5).add(3)`. Die hier verwendeten Trennzeichen und Währungen stammen aus [DEF](../def/), und Templates erreichen dieselbe Formatierung über die [Tangular-Helper](../tangular-helpers/).\n\n## API\n\n### num.add(value, [decimals])\n\nType: `method`\n\nAddiert eine Zahl oder wendet eine als Text geschriebene Operation an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number or String` | yes |  | Die zu addierende Zahl oder die Operation. |\n| `decimals` | `Number` | no |  | Rundet eine Textoperation auf diese Anzahl von Dezimalstellen ab. |\n\nReturns: `Number` Das Ergebnis.\n\nEine Zahl wird zum aktuellen Wert addiert. Ein Text beginnt mit einem Operator:\n\n| Text | Ergebnis für `200` |\n| --- | --- |\n| `'+10'` | `210` |\n| `'-10'` | `190` |\n| `'*10'` | `2000` |\n| `'/10'` | `20` |\n| `'+10%'` | `220` |\n| `'-10%'` | `180` |\n| `'10%'` | `20` |\n\n`inc()` ist ein anderer Name für dieselbe Methode.\n\nExample: Operationen\n```js\n(5).add(3); // 8\n(200).add('+10'); // 210\n(200).add('*10'); // 2000\n(200).add('+10%'); // 220\n(200).add('-10%'); // 180\n(200).add('10%'); // 20\n(10).add('/3', 2); // 3.33\n```\n\n### num.between(condition, [otherwise])\n\nType: `method`\n\nGibt den Wert zurück, der dem Bereich zugeordnet ist, in dem die Zahl liegt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Object` | yes |  | Die Bereiche und ihre Werte. |\n| `otherwise` | `Object` | no |  | Der Wert, der zurückgegeben wird, wenn kein Bereich passt. |\n\nReturns: `Object` Der Wert des passenden Bereichs oder `otherwise`.\n\nJeder Schlüssel von `condition` ist ein Bereich: `'0-3'` schließt beide Grenzen ein, `'7-'` bedeutet 7 oder mehr und `'-3'` bedeutet 3 oder weniger. Die Bereiche werden in der Reihenfolge der Schlüssel geprüft, und der erste Treffer gewinnt. Die Grenzen dürfen keine negativen Zahlen sein.\n\nExample: Eine Bezeichnung auswählen\n```js\nvar ranges = { '0-3': 'low', '4-6': 'medium', '7-': 'high' };\n(5).between(ranges); // \"medium\"\n(9).between(ranges); // \"high\"\n(2).between({ '5-9': 'middle' }, 'other'); // \"other\"\n```\n\n### num.currency([currency], [a], [b], [c])\n\nType: `method`\n\nFormatiert die Zahl mit einem in `DEF.currencies` registrierten Formatter.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `currency` | `String` | no |  | Der Währungscode. |\n| `a` | `Object` | no |  | Ein eigenes Argument für den Formatter. |\n| `b` | `Object` | no |  | Ein eigenes Argument für den Formatter. |\n| `c` | `Object` | no |  | Ein eigenes Argument für den Formatter. |\n\nReturns: `String` Der formatierte Betrag.\n\nEin Formatter ist eine `function(value, a, b, c)`, die unter ihrem Code gespeichert ist. Fehlt `currency`, wird `DEF.currency` verwendet. Ein Code in der Form `[key]` wird aus `ENV()` gelesen. Ohne passenden Formatter wird die Zahl mit zwei Dezimalstellen geschrieben.\n\nExample: Eine Währung registrieren\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\n(1234.5).currency('eur'); // \"1 234.50 EUR\"\n(1234.5).currency('unknown'); // \"1 234.50\"\n```\n\n### num.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 Anzahl der Dezimalstellen. Verwende `0` für eine ganze Zahl. |\n\nReturns: `Number` Die gerundete Zahl.\n\nExample: Abrunden\n```js\n(1.999).floor(2); // 1.99\n(5.5).floor(0); // 5\n(-1.555).floor(2); // -1.56\n```\n\n### num.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nSchreibt die Zahl mit einem Tausendertrennzeichen und einer festen Anzahl von Dezimalstellen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Die Anzahl der Dezimalstellen. |\n| `separator` | `String` | no |  | Das Tausendertrennzeichen. |\n| `decimalSeparator` | `String` | no |  | Das Dezimaltrennzeichen. |\n\nReturns: `String` Die formatierte Zahl.\n\nÜberzählige Dezimalstellen werden abgeschnitten, nicht gerundet; verwende zuerst [round()](#round), wenn es auf das Runden ankommt. Ohne `decimals` behält die Zahl ihre eigenen Dezimalstellen. Die Trennzeichen sind standardmäßig `DEF.thousandsseparator` (ein Leerzeichen) und `DEF.decimalseparator` (ein Punkt).\n\nIst das erste Argument ein Text, hat es eine von zwei Bedeutungen. Ein Text in der Form `[key]` liest einen vorhandenen `ENV()`-Wert, der die Anzahl der Dezimalstellen oder ein Objekt mit den Feldern `decimals`, `separator` und `decimalseparator` ist. Jeder andere Text ist das Tausendertrennzeichen, und das zweite Argument ist dann die Anzahl der Dezimalstellen.\n\nExample: Dezimalstellen und Trennzeichen\n```js\n(1234567.891).format(); // \"1 234 567.891\"\n(1234.5).format(2); // \"1 234.50\"\n(1.999).format(2); // \"1.99\"\n(1234.5).format(0); // \"1 234\"\n(1234.5).format(2, '.', ','); // \"1.234,50\"\n(1234.5).format(','); // \"1,234.5\"\n```\n\nExample: Einstellungen aus der Umgebung\n```js\nENV('price', { decimals: 1, separator: ',', decimalseparator: '.' });\n(1234.56).format('[price]'); // \"1,234.5\"\n```\n\n### num.padLeft(length, [char])\n\nType: `method`\n\nSchreibt die Zahl als Text und füllt sie links auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `'0'` | Das hinzuzufügende Zeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nExample: Führende Nullen\n```js\n(5).padLeft(3); // \"005\"\n(5).padLeft(3, ' '); // \"  5\"\n```\n\n### num.padRight(length, [char])\n\nType: `method`\n\nSchreibt die Zahl als Text und füllt sie rechts auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `'0'` | Das hinzuzufügende Zeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nExample: Nachgestellte Zeichen\n```js\n(5).padRight(3); // \"500\"\n(5).padRight(3, 'x'); // \"5xx\"\n```\n\n### num.parseDate([offset])\n\nType: `method`\n\nErstellt ein `Date` aus einer Anzahl von Millisekunden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Millisekunden, die zur Zahl addiert werden. |\n\nReturns: `Date` Das neue Datum.\n\nExample: Aus einem Zeitstempel\n```js\n(1700000000000).parseDate().getTime(); // 1700000000000\n(1700000000000).parseDate(1000).getTime(); // 1700000001000\n```\n\n### num.pluralize(zero, one, few, other)\n\nType: `method`\n\nWählt einen Text anhand der Größe der Zahl aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Der Text für 0 oder alle vier Formen. |\n| `one` | `String` | yes |  | Der Text für 1. |\n| `few` | `String` | yes |  | Der Text für Zahlen größer als 1 und kleiner als 5. |\n| `other` | `String` | yes |  | Der Text für alle anderen Zahlen. |\n\nReturns: `String` Der ausgewählte Text.\n\nDer Text `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 `##` schreibt sie mit [format()](#format).\n\nDie vier Formen können auch als ein Array oder als ein durch Kommas getrennter Text übergeben werden. Ein Text in der Form `[key]` wird aus `ENV()` gelesen. Alle vier Formen sind erforderlich.\n\nExample: Eine Form auswählen\n```js\n(0).pluralize('no items', '# item', '# items', '# items'); // \"no items\"\n(1).pluralize('no items', '# item', '# items', '# items'); // \"1 item\"\n(3).pluralize('no items', '# item', '# items', '# items'); // \"3 items\"\n(5000).pluralize('none', 'one', 'few', '## items'); // \"5 000 items\"\n(2).pluralize('none,one,few,many'); // \"few\"\n(7).pluralize(['none', 'one', 'few', 'many']); // \"many\"\n```\n\n### num.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 Anzahl der Dezimalstellen. |\n\nReturns: `Number` Die gerundete Zahl.\n\nDie Anzahl der Dezimalstellen darf nicht negativ sein.\n\nExample: Eine Zahl runden\n```js\n(1.005).round(2); // 1.01\n(1.5).round(); // 2\n(1.4).round(); // 1\n```\n","entries":[{"type":"method","name":"add()","signature":"num.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"between()","signature":"num.between(condition, [otherwise])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"num.currency([currency], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"num.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"num.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"num.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"num.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"num.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"num.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"num.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammgn84j61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/number/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Number","summary":"Métodos que jComponent añade a Number.prototype para calcular, redondear y dar formato a números.","markdown":"---\ntitle: Number\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/number/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Number\n\n> Métodos que jComponent añade a Number.prototype para calcular, redondear y dar formato a números.\n\njComponent añade estos métodos a `Number.prototype`. Escribe un literal numérico entre paréntesis para llamar a un método sobre él, por ejemplo `(5).add(3)`. Los separadores y las monedas que se usan aquí vienen de [DEF](../def/), y las plantillas acceden al mismo formato mediante los [helpers de Tangular](../tangular-helpers/).\n\n## API\n\n### num.add(value, [decimals])\n\nType: `method`\n\nSuma un número o aplica una operación escrita como texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number or String` | yes |  | El número que se suma o la operación. |\n| `decimals` | `Number` | no |  | Redondea hacia abajo una operación de texto a este número de decimales. |\n\nReturns: `Number` El resultado.\n\nUn número se suma al valor actual. Un texto empieza por un operador:\n\n| Texto | Resultado para `200` |\n| --- | --- |\n| `'+10'` | `210` |\n| `'-10'` | `190` |\n| `'*10'` | `2000` |\n| `'/10'` | `20` |\n| `'+10%'` | `220` |\n| `'-10%'` | `180` |\n| `'10%'` | `20` |\n\n`inc()` es otro nombre del mismo método.\n\nExample: Operaciones\n```js\n(5).add(3); // 8\n(200).add('+10'); // 210\n(200).add('*10'); // 2000\n(200).add('+10%'); // 220\n(200).add('-10%'); // 180\n(200).add('10%'); // 20\n(10).add('/3', 2); // 3.33\n```\n\n### num.between(condition, [otherwise])\n\nType: `method`\n\nDevuelve el valor asignado al rango que contiene el número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Object` | yes |  | Los rangos y sus valores. |\n| `otherwise` | `Object` | no |  | El valor que se devuelve cuando ningún rango coincide. |\n\nReturns: `Object` El valor del rango coincidente, o `otherwise`.\n\nCada clave de `condition` es un rango: `'0-3'` incluye ambos límites, `'7-'` significa 7 o más y `'-3'` significa 3 o menos. Los rangos se comprueban en el orden de las claves y gana la primera coincidencia. Los límites no pueden ser números negativos.\n\nExample: Elegir una etiqueta\n```js\nvar ranges = { '0-3': 'low', '4-6': 'medium', '7-': 'high' };\n(5).between(ranges); // \"medium\"\n(9).between(ranges); // \"high\"\n(2).between({ '5-9': 'middle' }, 'other'); // \"other\"\n```\n\n### num.currency([currency], [a], [b], [c])\n\nType: `method`\n\nDa formato al número con un formatter registrado en `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `currency` | `String` | no |  | El código de moneda. |\n| `a` | `Object` | no |  | Un argumento personalizado para el formatter. |\n| `b` | `Object` | no |  | Un argumento personalizado para el formatter. |\n| `c` | `Object` | no |  | Un argumento personalizado para el formatter. |\n\nReturns: `String` El importe formateado.\n\nUn formatter es una `function(value, a, b, c)` guardada con su código. Cuando falta `currency`, se usa `DEF.currency`. Un código con la forma `[key]` se lee de `ENV()`. Si no hay ningún formatter coincidente, el número se escribe con dos decimales.\n\nExample: Registrar una moneda\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\n(1234.5).currency('eur'); // \"1 234.50 EUR\"\n(1234.5).currency('unknown'); // \"1 234.50\"\n```\n\n### num.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 |  | El número de decimales. Usa `0` para obtener un número entero. |\n\nReturns: `Number` El número redondeado.\n\nExample: Redondear hacia abajo\n```js\n(1.999).floor(2); // 1.99\n(5.5).floor(0); // 5\n(-1.555).floor(2); // -1.56\n```\n\n### num.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nEscribe el número con separador de miles y un número fijo de decimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | El número de decimales. |\n| `separator` | `String` | no |  | El separador de miles. |\n| `decimalSeparator` | `String` | no |  | El separador decimal. |\n\nReturns: `String` El número con formato.\n\nLos decimales sobrantes se cortan, no se redondean; usa antes [round()](#round) cuando importe el redondeo. Sin `decimals`, el número conserva sus propios decimales. Los separadores son, de forma predeterminada, `DEF.thousandsseparator` (un espacio) y `DEF.decimalseparator` (un punto).\n\nCuando el primer argumento es un texto, tiene uno de dos significados. Un texto con la forma `[key]` lee un valor existente de `ENV()`, que es el número de decimales o un objeto con los campos `decimals`, `separator` y `decimalseparator`. Cualquier otro texto es el separador de miles, y el segundo argumento es entonces el número de decimales.\n\nExample: Decimales y separadores\n```js\n(1234567.891).format(); // \"1 234 567.891\"\n(1234.5).format(2); // \"1 234.50\"\n(1.999).format(2); // \"1.99\"\n(1234.5).format(0); // \"1 234\"\n(1234.5).format(2, '.', ','); // \"1.234,50\"\n(1234.5).format(','); // \"1,234.5\"\n```\n\nExample: Ajustes del entorno\n```js\nENV('price', { decimals: 1, separator: ',', decimalseparator: '.' });\n(1234.56).format('[price]'); // \"1,234.5\"\n```\n\n### num.padLeft(length, [char])\n\nType: `method`\n\nEscribe el número como texto y lo rellena por la izquierda.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `'0'` | El carácter que se añade. |\n\nReturns: `String` El texto rellenado.\n\nExample: Ceros a la izquierda\n```js\n(5).padLeft(3); // \"005\"\n(5).padLeft(3, ' '); // \"  5\"\n```\n\n### num.padRight(length, [char])\n\nType: `method`\n\nEscribe el número como texto y lo rellena por la derecha.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `'0'` | El carácter que se añade. |\n\nReturns: `String` El texto rellenado.\n\nExample: Caracteres a la derecha\n```js\n(5).padRight(3); // \"500\"\n(5).padRight(3, 'x'); // \"5xx\"\n```\n\n### num.parseDate([offset])\n\nType: `method`\n\nCrea un `Date` a partir de un número de milisegundos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Milisegundos que se suman al número. |\n\nReturns: `Date` La nueva fecha.\n\nExample: A partir de una marca de tiempo\n```js\n(1700000000000).parseDate().getTime(); // 1700000000000\n(1700000000000).parseDate(1000).getTime(); // 1700000001000\n```\n\n### num.pluralize(zero, one, few, other)\n\nType: `method`\n\nElige un texto según la magnitud del número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | El texto para 0, o las cuatro formas. |\n| `one` | `String` | yes |  | El texto para 1. |\n| `few` | `String` | yes |  | El texto para números mayores que 1 y menores que 5. |\n| `other` | `String` | yes |  | El texto para todos los demás números. |\n\nReturns: `String` El texto elegido.\n\nEl texto `zero` se usa para 0, `one` para 1, `few` para números mayores que 1 y menores que 5, y `other` para el resto. En el texto elegido, `#` escribe el número y `##` lo escribe con [format()](#format).\n\nLas cuatro formas también se pueden pasar como un solo array o como un solo texto separado por comas. Un texto con la forma `[key]` se lee de `ENV()`. Las cuatro formas son obligatorias.\n\nExample: Elegir una forma\n```js\n(0).pluralize('no items', '# item', '# items', '# items'); // \"no items\"\n(1).pluralize('no items', '# item', '# items', '# items'); // \"1 item\"\n(3).pluralize('no items', '# item', '# items', '# items'); // \"3 items\"\n(5000).pluralize('none', 'one', 'few', '## items'); // \"5 000 items\"\n(2).pluralize('none,one,few,many'); // \"few\"\n(7).pluralize(['none', 'one', 'few', 'many']); // \"many\"\n```\n\n### num.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` | El número de decimales. |\n\nReturns: `Number` El número redondeado.\n\nEl número de decimales no puede ser negativo.\n\nExample: Redondear un número\n```js\n(1.005).round(2); // 1.01\n(1.5).round(); // 2\n(1.4).round(); // 1\n```\n","entries":[{"type":"method","name":"add()","signature":"num.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"between()","signature":"num.between(condition, [otherwise])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"num.currency([currency], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"num.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"num.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"num.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"num.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"num.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"num.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"num.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammgn84j61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/number/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Number","summary":"Les méthodes que jComponent ajoute à Number.prototype pour calculer, arrondir et formater des nombres.","markdown":"---\ntitle: Number\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/number/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Number\n\n> Les méthodes que jComponent ajoute à Number.prototype pour calculer, arrondir et formater des nombres.\n\njComponent ajoute ces méthodes à `Number.prototype`. Écris un nombre littéral entre parenthèses pour appeler une méthode dessus, par exemple `(5).add(3)`. Les séparateurs et les devises utilisés ici proviennent de [DEF](../def/), et les modèles accèdent au même formatage grâce aux [helpers Tangular](../tangular-helpers/).\n\n## API\n\n### num.add(value, [decimals])\n\nType: `method`\n\nAjoute un nombre ou applique une opération écrite sous forme de texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number or String` | yes |  | Le nombre à ajouter, ou l'opération. |\n| `decimals` | `Number` | no |  | Arrondit une opération textuelle vers le bas à ce nombre de décimales. |\n\nReturns: `Number` Le résultat.\n\nUn nombre est ajouté à la valeur actuelle. Un texte commence par un opérateur :\n\n| Texte | Résultat pour `200` |\n| --- | --- |\n| `'+10'` | `210` |\n| `'-10'` | `190` |\n| `'*10'` | `2000` |\n| `'/10'` | `20` |\n| `'+10%'` | `220` |\n| `'-10%'` | `180` |\n| `'10%'` | `20` |\n\n`inc()` est un autre nom de la même méthode.\n\nExample: Opérations\n```js\n(5).add(3); // 8\n(200).add('+10'); // 210\n(200).add('*10'); // 2000\n(200).add('+10%'); // 220\n(200).add('-10%'); // 180\n(200).add('10%'); // 20\n(10).add('/3', 2); // 3.33\n```\n\n### num.between(condition, [otherwise])\n\nType: `method`\n\nRenvoie la valeur assignée à la plage qui contient le nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Object` | yes |  | Les plages et leurs valeurs. |\n| `otherwise` | `Object` | no |  | La valeur renvoyée quand aucune plage ne correspond. |\n\nReturns: `Object` La valeur de la plage correspondante, ou `otherwise`.\n\nChaque clé de `condition` est une plage : `'0-3'` inclut les deux limites, `'7-'` signifie 7 ou plus et `'-3'` signifie 3 ou moins. Les plages sont vérifiées dans l'ordre des clés et la première correspondance l'emporte. Les limites ne peuvent pas être des nombres négatifs.\n\nExample: Choisir un libellé\n```js\nvar ranges = { '0-3': 'low', '4-6': 'medium', '7-': 'high' };\n(5).between(ranges); // \"medium\"\n(9).between(ranges); // \"high\"\n(2).between({ '5-9': 'middle' }, 'other'); // \"other\"\n```\n\n### num.currency([currency], [a], [b], [c])\n\nType: `method`\n\nFormate le nombre avec un formateur enregistré dans `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `currency` | `String` | no |  | Le code de la devise. |\n| `a` | `Object` | no |  | Un argument personnalisé pour le formateur. |\n| `b` | `Object` | no |  | Un argument personnalisé pour le formateur. |\n| `c` | `Object` | no |  | Un argument personnalisé pour le formateur. |\n\nReturns: `String` Le montant formaté.\n\nUn formateur est une `function(value, a, b, c)` stockée sous son code. Quand `currency` est absent, `DEF.currency` est utilisé. Un code de la forme `[key]` est lu depuis `ENV()`. Sans formateur correspondant, le nombre est écrit avec deux décimales.\n\nExample: Enregistrer une devise\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\n(1234.5).currency('eur'); // \"1 234.50 EUR\"\n(1234.5).currency('unknown'); // \"1 234.50\"\n```\n\n### num.floor(decimals)\n\nType: `method`\n\nArrondit le nombre vers le bas à un nombre de décimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Le nombre de décimales. Utilise `0` pour un nombre entier. |\n\nReturns: `Number` Le nombre arrondi.\n\nExample: Arrondir vers le bas\n```js\n(1.999).floor(2); // 1.99\n(5.5).floor(0); // 5\n(-1.555).floor(2); // -1.56\n```\n\n### num.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nÉcrit le nombre avec un séparateur de milliers et un nombre fixe de décimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Le nombre de décimales. |\n| `separator` | `String` | no |  | Le séparateur de milliers. |\n| `decimalSeparator` | `String` | no |  | Le séparateur décimal. |\n\nReturns: `String` Le nombre formaté.\n\nLes décimales en trop sont tronquées, pas arrondies ; utilise d'abord [round()](#round) si l'arrondi compte. Sans `decimals`, le nombre conserve ses propres décimales. Les séparateurs valent par défaut `DEF.thousandsseparator` (un espace) et `DEF.decimalseparator` (un point).\n\nQuand le premier argument est un texte, il a l'une de ces deux significations. Un texte de la forme `[key]` lit une valeur `ENV()` existante, qui est le nombre de décimales ou un objet avec les champs `decimals`, `separator` et `decimalseparator`. Tout autre texte est le séparateur de milliers, et le deuxième argument est alors le nombre de décimales.\n\nExample: Décimales et séparateurs\n```js\n(1234567.891).format(); // \"1 234 567.891\"\n(1234.5).format(2); // \"1 234.50\"\n(1.999).format(2); // \"1.99\"\n(1234.5).format(0); // \"1 234\"\n(1234.5).format(2, '.', ','); // \"1.234,50\"\n(1234.5).format(','); // \"1,234.5\"\n```\n\nExample: Paramètres issus de l'environnement\n```js\nENV('price', { decimals: 1, separator: ',', decimalseparator: '.' });\n(1234.56).format('[price]'); // \"1,234.5\"\n```\n\n### num.padLeft(length, [char])\n\nType: `method`\n\nÉcrit le nombre sous forme de texte et le complète à gauche.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `'0'` | Le caractère à ajouter. |\n\nReturns: `String` Le texte complété.\n\nExample: Zéros de tête\n```js\n(5).padLeft(3); // \"005\"\n(5).padLeft(3, ' '); // \"  5\"\n```\n\n### num.padRight(length, [char])\n\nType: `method`\n\nÉcrit le nombre sous forme de texte et le complète à droite.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `'0'` | Le caractère à ajouter. |\n\nReturns: `String` Le texte complété.\n\nExample: Caractères de fin\n```js\n(5).padRight(3); // \"500\"\n(5).padRight(3, 'x'); // \"5xx\"\n```\n\n### num.parseDate([offset])\n\nType: `method`\n\nCrée une `Date` à partir d'un nombre de millisecondes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Les millisecondes ajoutées au nombre. |\n\nReturns: `Date` La nouvelle date.\n\nExample: À partir d'un timestamp\n```js\n(1700000000000).parseDate().getTime(); // 1700000000000\n(1700000000000).parseDate(1000).getTime(); // 1700000001000\n```\n\n### num.pluralize(zero, one, few, other)\n\nType: `method`\n\nChoisit un texte selon la taille du nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Le texte pour 0, ou les quatre formes. |\n| `one` | `String` | yes |  | Le texte pour 1. |\n| `few` | `String` | yes |  | Le texte pour les nombres supérieurs à 1 et inférieurs à 5. |\n| `other` | `String` | yes |  | Le texte pour tous les autres nombres. |\n\nReturns: `String` Le texte choisi.\n\nLe texte `zero` est utilisé pour 0, `one` pour 1, `few` pour les nombres supérieurs à 1 et inférieurs à 5, et `other` pour les autres. Dans le texte choisi, `#` écrit le nombre et `##` l'écrit avec [format()](#format).\n\nLes quatre formes peuvent aussi être passées dans un seul tableau ou dans un seul texte séparé par des virgules. Un texte de la forme `[key]` est lu depuis `ENV()`. Les quatre formes sont obligatoires.\n\nExample: Choisir une forme\n```js\n(0).pluralize('no items', '# item', '# items', '# items'); // \"no items\"\n(1).pluralize('no items', '# item', '# items', '# items'); // \"1 item\"\n(3).pluralize('no items', '# item', '# items', '# items'); // \"3 items\"\n(5000).pluralize('none', 'one', 'few', '## items'); // \"5 000 items\"\n(2).pluralize('none,one,few,many'); // \"few\"\n(7).pluralize(['none', 'one', 'few', 'many']); // \"many\"\n```\n\n### num.round([decimals])\n\nType: `method`\n\nArrondit le nombre à un nombre de décimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Le nombre de décimales. |\n\nReturns: `Number` Le nombre arrondi.\n\nLe nombre de décimales ne peut pas être négatif.\n\nExample: Arrondir un nombre\n```js\n(1.005).round(2); // 1.01\n(1.5).round(); // 2\n(1.4).round(); // 1\n```\n","entries":[{"type":"method","name":"add()","signature":"num.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"between()","signature":"num.between(condition, [otherwise])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"num.currency([currency], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"num.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"num.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"num.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"num.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"num.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"num.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"num.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammgn84j61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/number/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Number","summary":"Metodi che jComponent aggiunge a Number.prototype per calcolare, arrotondare e formattare i numeri.","markdown":"---\ntitle: Number\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/number/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Number\n\n> Metodi che jComponent aggiunge a Number.prototype per calcolare, arrotondare e formattare i numeri.\n\njComponent aggiunge questi metodi a `Number.prototype`. Scrivi un numero letterale tra parentesi per chiamarci un metodo, ad esempio `(5).add(3)`. I separatori e le valute usati qui provengono da [DEF](../def/), e i template accedono alla stessa formattazione tramite gli [helper di Tangular](../tangular-helpers/).\n\n## API\n\n### num.add(value, [decimals])\n\nType: `method`\n\nAggiunge un numero o applica un'operazione scritta come testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number or String` | yes |  | Il numero da sommare o l'operazione. |\n| `decimals` | `Number` | no |  | Arrotonda per difetto un'operazione testuale a questo numero di decimali. |\n\nReturns: `Number` Il risultato.\n\nUn numero viene sommato al valore corrente. Un testo inizia con un operatore:\n\n| Testo | Risultato per `200` |\n| --- | --- |\n| `'+10'` | `210` |\n| `'-10'` | `190` |\n| `'*10'` | `2000` |\n| `'/10'` | `20` |\n| `'+10%'` | `220` |\n| `'-10%'` | `180` |\n| `'10%'` | `20` |\n\n`inc()` è un altro nome dello stesso metodo.\n\nExample: Operazioni\n```js\n(5).add(3); // 8\n(200).add('+10'); // 210\n(200).add('*10'); // 2000\n(200).add('+10%'); // 220\n(200).add('-10%'); // 180\n(200).add('10%'); // 20\n(10).add('/3', 2); // 3.33\n```\n\n### num.between(condition, [otherwise])\n\nType: `method`\n\nRestituisce il valore assegnato all'intervallo che contiene il numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Object` | yes |  | Gli intervalli e i relativi valori. |\n| `otherwise` | `Object` | no |  | Il valore restituito quando nessun intervallo corrisponde. |\n\nReturns: `Object` Il valore dell'intervallo corrispondente, oppure `otherwise`.\n\nOgni chiave di `condition` è un intervallo: `'0-3'` include entrambi i limiti, `'7-'` significa 7 o più e `'-3'` significa 3 o meno. Gli intervalli vengono controllati nell'ordine delle chiavi e vince la prima corrispondenza. I limiti non possono essere numeri negativi.\n\nExample: Scegli un'etichetta\n```js\nvar ranges = { '0-3': 'low', '4-6': 'medium', '7-': 'high' };\n(5).between(ranges); // \"medium\"\n(9).between(ranges); // \"high\"\n(2).between({ '5-9': 'middle' }, 'other'); // \"other\"\n```\n\n### num.currency([currency], [a], [b], [c])\n\nType: `method`\n\nFormatta il numero con un formatter registrato in `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `currency` | `String` | no |  | Il codice della valuta. |\n| `a` | `Object` | no |  | Un argomento personalizzato per il formatter. |\n| `b` | `Object` | no |  | Un argomento personalizzato per il formatter. |\n| `c` | `Object` | no |  | Un argomento personalizzato per il formatter. |\n\nReturns: `String` L'importo formattato.\n\nUn formatter è una `function(value, a, b, c)` memorizzata sotto il proprio codice. Quando manca `currency`, viene usato `DEF.currency`. Un codice nella forma `[key]` viene letto da `ENV()`. Senza un formatter corrispondente, il numero viene scritto con due decimali.\n\nExample: Registra una valuta\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\n(1234.5).currency('eur'); // \"1 234.50 EUR\"\n(1234.5).currency('unknown'); // \"1 234.50\"\n```\n\n### num.floor(decimals)\n\nType: `method`\n\nArrotonda il numero per difetto a un certo numero di decimali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Il numero di decimali. Usa `0` per un numero intero. |\n\nReturns: `Number` Il numero arrotondato.\n\nExample: Arrotonda per difetto\n```js\n(1.999).floor(2); // 1.99\n(5.5).floor(0); // 5\n(-1.555).floor(2); // -1.56\n```\n\n### num.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nScrive il numero con un separatore delle migliaia e un numero fisso di decimali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Il numero di decimali. |\n| `separator` | `String` | no |  | Il separatore delle migliaia. |\n| `decimalSeparator` | `String` | no |  | Il separatore decimale. |\n\nReturns: `String` Il numero formattato.\n\nI decimali in eccesso vengono troncati, non arrotondati; usa prima [round()](#round) quando l'arrotondamento è importante. Senza `decimals`, il numero mantiene i propri decimali. I separatori predefiniti sono `DEF.thousandsseparator` (uno spazio) e `DEF.decimalseparator` (un punto).\n\nQuando il primo argomento è un testo, ha uno di due significati. Un testo nella forma `[key]` legge un valore esistente di `ENV()`, che è il numero di decimali o un oggetto con i campi `decimals`, `separator` e `decimalseparator`. Qualsiasi altro testo è il separatore delle migliaia e il secondo argomento è allora il numero di decimali.\n\nExample: Decimali e separatori\n```js\n(1234567.891).format(); // \"1 234 567.891\"\n(1234.5).format(2); // \"1 234.50\"\n(1.999).format(2); // \"1.99\"\n(1234.5).format(0); // \"1 234\"\n(1234.5).format(2, '.', ','); // \"1.234,50\"\n(1234.5).format(','); // \"1,234.5\"\n```\n\nExample: Impostazioni dall'ambiente\n```js\nENV('price', { decimals: 1, separator: ',', decimalseparator: '.' });\n(1234.56).format('[price]'); // \"1,234.5\"\n```\n\n### num.padLeft(length, [char])\n\nType: `method`\n\nScrive il numero come testo e lo riempie a sinistra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `'0'` | Il carattere da aggiungere. |\n\nReturns: `String` Il testo riempito.\n\nExample: Zeri iniziali\n```js\n(5).padLeft(3); // \"005\"\n(5).padLeft(3, ' '); // \"  5\"\n```\n\n### num.padRight(length, [char])\n\nType: `method`\n\nScrive il numero come testo e lo riempie a destra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `'0'` | Il carattere da aggiungere. |\n\nReturns: `String` Il testo riempito.\n\nExample: Caratteri finali\n```js\n(5).padRight(3); // \"500\"\n(5).padRight(3, 'x'); // \"5xx\"\n```\n\n### num.parseDate([offset])\n\nType: `method`\n\nCrea un `Date` da un numero di millisecondi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | I millisecondi sommati al numero. |\n\nReturns: `Date` La nuova data.\n\nExample: Da un timestamp\n```js\n(1700000000000).parseDate().getTime(); // 1700000000000\n(1700000000000).parseDate(1000).getTime(); // 1700000001000\n```\n\n### num.pluralize(zero, one, few, other)\n\nType: `method`\n\nSceglie un testo in base alla grandezza del numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Il testo per 0, oppure tutte e quattro le forme. |\n| `one` | `String` | yes |  | Il testo per 1. |\n| `few` | `String` | yes |  | Il testo per i numeri maggiori di 1 e minori di 5. |\n| `other` | `String` | yes |  | Il testo per tutti gli altri numeri. |\n\nReturns: `String` Il testo scelto.\n\nIl testo `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 scelto, `#` scrive il numero e `##` lo scrive con [format()](#format).\n\nPuoi passare le quattro forme anche come un unico array o come un unico testo separato da virgole. Un testo nella forma `[key]` viene letto da `ENV()`. Tutte e quattro le forme sono obbligatorie.\n\nExample: Scegli una forma\n```js\n(0).pluralize('no items', '# item', '# items', '# items'); // \"no items\"\n(1).pluralize('no items', '# item', '# items', '# items'); // \"1 item\"\n(3).pluralize('no items', '# item', '# items', '# items'); // \"3 items\"\n(5000).pluralize('none', 'one', 'few', '## items'); // \"5 000 items\"\n(2).pluralize('none,one,few,many'); // \"few\"\n(7).pluralize(['none', 'one', 'few', 'many']); // \"many\"\n```\n\n### num.round([decimals])\n\nType: `method`\n\nArrotonda il numero a un certo numero di decimali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Il numero di decimali. |\n\nReturns: `Number` Il numero arrotondato.\n\nIl numero di decimali non può essere negativo.\n\nExample: Arrotonda un numero\n```js\n(1.005).round(2); // 1.01\n(1.5).round(); // 2\n(1.4).round(); // 1\n```\n","entries":[{"type":"method","name":"add()","signature":"num.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"between()","signature":"num.between(condition, [otherwise])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"num.currency([currency], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"num.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"num.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"num.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"num.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"num.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"num.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"num.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"Jammgn84j61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/number/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Number","summary":"Metódy, ktoré jComponent pridáva do Number.prototype na výpočty, zaokrúhľovanie a formátovanie čísel.","markdown":"---\ntitle: Number\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/number/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Number\n\n> Metódy, ktoré jComponent pridáva do Number.prototype na výpočty, zaokrúhľovanie a formátovanie čísel.\n\njComponent pridáva tieto metódy do `Number.prototype`. Ak chceš zavolať metódu na číselnom literáli, napíš ho do zátvoriek, napríklad `(5).add(3)`. Oddeľovače a meny použité v tejto časti pochádzajú z [DEF](../def/) a šablóny sa k rovnakému formátovaniu dostanú cez [helpery Tangular](../tangular-helpers/).\n\n## API\n\n### num.add(value, [decimals])\n\nType: `method`\n\nPripočíta číslo alebo vykoná operáciu zapísanú ako text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Number or String` | yes |  | Číslo, ktoré sa má pripočítať, alebo operácia. |\n| `decimals` | `Number` | no |  | Zaokrúhli výsledok textovej operácie nadol na tento počet desatinných miest. |\n\nReturns: `Number` Výsledok.\n\nČíslo sa pripočíta k aktuálnej hodnote. Text sa začína operátorom:\n\n| Text | Výsledok pre `200` |\n| --- | --- |\n| `'+10'` | `210` |\n| `'-10'` | `190` |\n| `'*10'` | `2000` |\n| `'/10'` | `20` |\n| `'+10%'` | `220` |\n| `'-10%'` | `180` |\n| `'10%'` | `20` |\n\n`inc()` je iný názov tej istej metódy.\n\nExample: Operácie\n```js\n(5).add(3); // 8\n(200).add('+10'); // 210\n(200).add('*10'); // 2000\n(200).add('+10%'); // 220\n(200).add('-10%'); // 180\n(200).add('10%'); // 20\n(10).add('/3', 2); // 3.33\n```\n\n### num.between(condition, [otherwise])\n\nType: `method`\n\nVráti hodnotu priradenú rozsahu, ktorý obsahuje dané číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Object` | yes |  | Rozsahy a ich hodnoty. |\n| `otherwise` | `Object` | no |  | Hodnota vrátená, keď nezodpovedá žiadny rozsah. |\n\nReturns: `Object` Hodnota zodpovedajúceho rozsahu alebo `otherwise`.\n\nKaždý kľúč objektu `condition` je rozsah: `'0-3'` zahŕňa obe hranice, `'7-'` znamená 7 alebo viac a `'-3'` znamená 3 alebo menej. Rozsahy sa kontrolujú v poradí kľúčov a vyhráva prvá zhoda. Hranice nemôžu byť záporné čísla.\n\nExample: Vyber označenie\n```js\nvar ranges = { '0-3': 'low', '4-6': 'medium', '7-': 'high' };\n(5).between(ranges); // \"medium\"\n(9).between(ranges); // \"high\"\n(2).between({ '5-9': 'middle' }, 'other'); // \"other\"\n```\n\n### num.currency([currency], [a], [b], [c])\n\nType: `method`\n\nNaformátuje číslo formátovačom zaregistrovaným v `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `currency` | `String` | no |  | Kód meny. |\n| `a` | `Object` | no |  | Vlastný argument pre formátovač. |\n| `b` | `Object` | no |  | Vlastný argument pre formátovač. |\n| `c` | `Object` | no |  | Vlastný argument pre formátovač. |\n\nReturns: `String` Naformátovaná suma.\n\nFormátovač je `function(value, a, b, c)` uložená pod svojím kódom. Keď `currency` chýba, použije sa `DEF.currency`. Kód v tvare `[key]` sa prečíta z `ENV()`. Bez zodpovedajúceho formátovača sa číslo zapíše s dvoma desatinnými miestami.\n\nExample: Zaregistruj menu\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\n(1234.5).currency('eur'); // \"1 234.50 EUR\"\n(1234.5).currency('unknown'); // \"1 234.50\"\n```\n\n### num.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. Pre celé číslo použi `0`. |\n\nReturns: `Number` Zaokrúhlené číslo.\n\nExample: Zaokrúhli nadol\n```js\n(1.999).floor(2); // 1.99\n(5.5).floor(0); // 5\n(-1.555).floor(2); // -1.56\n```\n\n### num.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nZapíše číslo s oddeľovačom tisícok a pevným počtom desatinných miest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Počet desatinných miest. |\n| `separator` | `String` | no |  | Oddeľovač tisícov. |\n| `decimalSeparator` | `String` | no |  | Desatinný oddeľovač. |\n\nReturns: `String` Naformátované číslo.\n\nNadbytočné desatinné miesta sa odrežú, nezaokrúhľujú sa; ak ti záleží na zaokrúhlení, použi najprv [round()](#round). Bez `decimals` si číslo zachová vlastné desatinné miesta. Predvolené oddeľovače sú `DEF.thousandsseparator` (medzera) a `DEF.decimalseparator` (bodka).\n\nKeď je prvý argument text, má jeden z dvoch významov. Text v tvare `[key]` prečíta existujúcu hodnotu `ENV()`, ktorá je počtom desatinných miest alebo objektom s poľami `decimals`, `separator` a `decimalseparator`. Akýkoľvek iný text je oddeľovač tisícok a druhý argument je potom počet desatinných miest.\n\nExample: Desatinné miesta a oddeľovače\n```js\n(1234567.891).format(); // \"1 234 567.891\"\n(1234.5).format(2); // \"1 234.50\"\n(1.999).format(2); // \"1.99\"\n(1234.5).format(0); // \"1 234\"\n(1234.5).format(2, '.', ','); // \"1.234,50\"\n(1234.5).format(','); // \"1,234.5\"\n```\n\nExample: Nastavenia z prostredia\n```js\nENV('price', { decimals: 1, separator: ',', decimalseparator: '.' });\n(1234.56).format('[price]'); // \"1,234.5\"\n```\n\n### num.padLeft(length, [char])\n\nType: `method`\n\nZapíše číslo ako text a doplní ho zľava.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `'0'` | Znak, ktorý sa má pridať. |\n\nReturns: `String` Doplnený text.\n\nExample: Úvodné nuly\n```js\n(5).padLeft(3); // \"005\"\n(5).padLeft(3, ' '); // \"  5\"\n```\n\n### num.padRight(length, [char])\n\nType: `method`\n\nZapíše číslo ako text a doplní ho sprava.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `'0'` | Znak, ktorý sa má pridať. |\n\nReturns: `String` Doplnený text.\n\nExample: Koncové znaky\n```js\n(5).padRight(3); // \"500\"\n(5).padRight(3, 'x'); // \"5xx\"\n```\n\n### num.parseDate([offset])\n\nType: `method`\n\nVytvorí `Date` z počtu milisekúnd.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Milisekundy pripočítané k číslu. |\n\nReturns: `Date` Nový dátum.\n\nExample: Z časovej značky\n```js\n(1700000000000).parseDate().getTime(); // 1700000000000\n(1700000000000).parseDate(1000).getTime(); // 1700000001000\n```\n\n### num.pluralize(zero, one, few, other)\n\nType: `method`\n\nVyberie text podľa veľkosti čísla.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Text pre 0 alebo všetky štyri tvary. |\n| `one` | `String` | yes |  | Text pre 1. |\n| `few` | `String` | yes |  | Text pre čísla väčšie ako 1 a menšie ako 5. |\n| `other` | `String` | yes |  | Text pre všetky ostatné čísla. |\n\nReturns: `String` Vybraný text.\n\nText `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é. V zvolenom texte `#` zapíše číslo a `##` ho zapíše pomocou [format()](#format).\n\nŠtyri tvary môžeš odovzdať aj ako jedno pole alebo ako jeden text oddelený čiarkami. Text v tvare `[key]` sa prečíta z `ENV()`. Všetky štyri tvary sú povinné.\n\nExample: Vyber tvar\n```js\n(0).pluralize('no items', '# item', '# items', '# items'); // \"no items\"\n(1).pluralize('no items', '# item', '# items', '# items'); // \"1 item\"\n(3).pluralize('no items', '# item', '# items', '# items'); // \"3 items\"\n(5000).pluralize('none', 'one', 'few', '## items'); // \"5 000 items\"\n(2).pluralize('none,one,few,many'); // \"few\"\n(7).pluralize(['none', 'one', 'few', 'many']); // \"many\"\n```\n\n### num.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. |\n\nReturns: `Number` Zaokrúhlené číslo.\n\nPočet desatinných miest nemôže byť záporný.\n\nExample: Zaokrúhli číslo\n```js\n(1.005).round(2); // 1.01\n(1.5).round(); // 2\n(1.4).round(); // 1\n```\n","entries":[{"type":"method","name":"add()","signature":"num.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"between()","signature":"num.between(condition, [otherwise])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"num.currency([currency], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"num.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"num.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"num.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"num.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"num.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"num.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"num.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUG2AM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/array/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Array","summary":"Methods that jComponent adds to Array.prototype for finding, sorting, grouping and processing items.","markdown":"---\ntitle: Array\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/array/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Array\n\n> Methods that jComponent adds to Array.prototype for finding, sorting, grouping and processing items.\n\njComponent adds these methods to `Array.prototype`. `findIndex()` replaces the native method and accepts the arguments described here. The find methods are often used with code lists stored in [DEF](../def/).\n\n## API\n\n### arr.async([threads], [callback])\n\nType: `method`\n\nRuns an array of functions one after another or in parallel.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `threads` | `Number` | no | `1` | How many functions run at the same time. |\n| `callback` | `Function` | no |  | Called when all functions have finished. |\n\nReturns: `Array` The same array.\n\nEach function receives a `next` function that it must call when its work is done. The array is emptied while it runs. `threads` must not be higher than the number of functions in the array.\n\nExample: Run tasks in order\n```js\nvar log = [];\n\nvar tasks = [\n\tfunction(next) { log.push('first'); setTimeout(next, 20); },\n\tfunction(next) { log.push('second'); next(); }\n];\n\ntasks.async(function() {\n\tconsole.log(log.join(', '));\n});\n```\n\n### arr.attr(name, [value])\n\nType: `method`\n\nAdds an HTML attribute to an array used as an HTML builder.\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 HTML-encoded and goes through `env()`. With one argument, the attribute name is also its value. With two arguments, a `null` or `undefined` value adds nothing.\n\nExample: Build an element\n```js\nvar builder = ['<div'];\nbuilder.attr('id', 'box').attr('title', 'a<b').attr('hidden').attr('data-x', null);\nbuilder.join(' ') + '>'; // \"<div id=\\\"box\\\" title=\\\"a&lt;b\\\" hidden=\\\"hidden\\\">\"\n```\n\n### arr.findAll(cb, [value])\n\nType: `method`\n\nReturns all items that match a condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | A function, a field name or a value to find. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Array` A new array with the matching items.\n\nThe condition is one of three forms: a `function(item, index)`, a field name with a value, or a value compared with each item.\n\nExample: Find many items\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findAll('age', 25).length; // 1\nusers.findAll(user => user.age >= 30).length; // 2\n['a', 'b', 'a'].findAll('a'); // [\"a\",\"a\"]\n```\n\n### arr.findIndex(cb, [value])\n\nType: `method`\n\nReturns the index of the first item that matches a condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | A function, a field name or a value to find. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Number` The index, or `-1`.\n\nThe condition has the same forms as in [findAll()](#findall).\n\nExample: Find an index\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findIndex('id', 2); // 1\nusers.findIndex(user => user.age > 30); // 2\nusers.findIndex('id', 99); // -1\n['a', 'b'].findIndex('b'); // 1\n```\n\n### arr.findItem(cb, [value])\n\nType: `method`\n\nReturns the first item that matches a condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | A function, a field name or a value to find. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Object` The item, or `undefined`.\n\nThe condition has the same forms as in [findAll()](#findall).\n\nExample: Find an item\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findItem('id', 2).name; // \"Bob\"\nusers.findItem(user => user.age > 30).name; // \"Cid\"\nusers.findItem('id', 99); // undefined\n```\n\n### arr.findValue(cb, value, path, [def])\n\nType: `method`\n\nFinds an item and returns one of its values.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String or Function` | yes |  | A field name or a `function(item, index)`. |\n| `value` | `Object` | yes |  | The value of the field. |\n| `path` | `String` | yes |  | The path of the value to read from the item. |\n| `def` | `Object` | no |  | The value returned when the item or its value does not exist. |\n\nReturns: `Object` The value that was read, or `def`.\n\nWith a function as the condition, leave out `value`: `arr.findValue(fn, path, [def])`. The `path` can be nested, such as `address.city`.\n\nExample: Read a value\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', address: { city: 'Rome' } },\n\t{ id: 2, name: 'Bob' }\n];\n\nusers.findValue('id', 1, 'name'); // \"Ann\"\nusers.findValue('id', 1, 'address.city'); // \"Rome\"\nusers.findValue('id', 9, 'name', 'unknown'); // \"unknown\"\nusers.findValue(user => user.id === 2, 'name'); // \"Bob\"\n```\n\n### arr.group(name)\n\nType: `method`\n\nGroups objects by the value of a field.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The field name. |\n\nReturns: `Array` Objects with the fields `name` and `items`.\n\nThe group names are texts, and the groups are sorted by name as text. Items without a value go to a group with an empty name.\n\nExample: Group users\n```js\nvar users = [{ name: 'Ann', role: 'dev' }, { name: 'Bob', role: 'ops' }, { name: 'Cid', role: 'dev' }, { name: 'Dan' }];\nusers.group('role').map(group => group.name + ':' + group.items.length); // [\":1\",\"dev:2\",\"ops:1\"]\n```\n\n### arr.last([def])\n\nType: `method`\n\nReturns the last item of the array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | The value returned when the last item is `undefined`. |\n\nReturns: `Object` The last item, or `def`.\n\nExample: Read the last item\n```js\n[1, 2, 3].last(); // 3\n[].last('empty'); // \"empty\"\n```\n\n### arr.quicksort([sort], [direction])\n\nType: `method`\n\nSorts the array in place by one or more fields.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | The fields to sort by. |\n| `direction` | `String, Boolean or Number` | no |  | Use `'desc'`, `false` or `2` to sort a single field in descending order. |\n\nReturns: `Array` The same array.\n\n`sort` contains field names separated by commas. Each name can end with `_asc` or `_desc`, and it can be a nested path such as `address.city`. Text uses a locale-aware comparison. Numbers, booleans and dates are compared by their type.\n\nWithout `sort`, the items themselves are compared as text in ascending order, so numbers sort as text.\n\nExample: Sort by fields\n```js\nvar users = [{ name: 'Bob', age: 25 }, { name: 'Ann', age: 30 }, { name: 'Cid', age: 25 }];\nvar names = () => users.map(user => user.name).join();\n\nusers.quicksort('name');\nnames(); // \"Ann,Bob,Cid\"\nusers.quicksort('name_desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('name', 'desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('age,name_desc');\nnames(); // \"Cid,Bob,Ann\"\n```\n\nExample: Sort values\n```js\n['b', 'c', 'a'].quicksort(); // [\"a\",\"b\",\"c\"]\n[10, 9, 100].quicksort(); // [10,100,9]\n```\n\n### arr.remove(cb, [value])\n\nType: `method`\n\nReturns a new array without the items that match a condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | A function, a field name or a value to remove. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Array` A new array with the remaining items.\n\nThe original array is not changed. The condition has the same forms as in [findAll()](#findall).\n\nExample: Remove items\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.remove('id', 2).length; // 2\nusers.remove(user => user.age > 26).length; // 1\n['a', 'b', 'a'].remove('a'); // [\"b\"]\nusers.length; // 3\n```\n\n### arr.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 |  | How many items to skip. |\n\nReturns: `Array` A new array.\n\nExample: Skip items\n```js\n[1, 2, 3, 4].skip(2); // [3,4]\n```\n\n### arr.take(count)\n\nType: `method`\n\nReturns the first `count` items.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | How many items to take. |\n\nReturns: `Array` A new array.\n\nThe count must be 1 or more.\n\nExample: Take items\n```js\n[1, 2, 3, 4].take(2); // [1,2]\n[1, 2].take(9); // [1,2]\n```\n\n### arr.takeskip(take, skip)\n\nType: `method`\n\nSkips a number of items and returns the next ones.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | How many items to return. |\n| `skip` | `Number` | yes |  | How many items to skip. |\n\nReturns: `Array` A new array.\n\nThis is useful for reading one page of a list.\n\nExample: Read a page\n```js\n[1, 2, 3, 4, 5].takeskip(2, 1); // [2,3]\n```\n\n### arr.trim([empty])\n\nType: `method`\n\nTrims the strings of the array and removes empty values.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `empty` | `Boolean` | no |  | Use `true` to keep empty values. |\n\nReturns: `Array` A new array.\n\nStrings are trimmed in the original array too. Without `empty`, the result leaves out every value that is falsy, including `0` and `null`.\n\nExample: Clean a list\n```js\n[' a ', '', ' b', 0, 1].trim(); // [\"a\",\"b\",1]\n[' a ', '', 0].trim(true); // [\"a\",\"\",0]\n```\n\n### arr.wait(onItem, [callback], [threads])\n\nType: `method`\n\nProcesses the items one by one or in parallel with an asynchronous function.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Processes one item. |\n| `callback` | `Function` | no |  | Called when all items are done. |\n| `threads` | `Number or Boolean` | no | `1` | How many items run at the same time, or `true` to remove processed items. |\n\nReturns: `Array` The same array.\n\n`onItem` is called as `function(item, next, index)` with the array as `this`, and it must call `next` when the item is done. `index` is the position of the item, starting at 1.\n\nWhen `threads` is `true`, the items are removed from the array as they are processed, and `index` is always `0`.\n\nExample: Process items in order\n```js\nvar output = [];\n\n['a', 'b', 'c'].wait(function(item, next, index) {\n\toutput.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(output.join(', '));\n});\n```\n\nExample: Two items at a time\n```js\nvar output = [];\n\n[1, 2, 3].wait(function(item, next) {\n\toutput.push('start ' + item);\n\tsetTimeout(function() {\n\t\toutput.push('end ' + item);\n\t\tnext();\n\t}, item === 1 ? 30 : 5);\n}, function() {\n\tconsole.log(output.join(', '));\n}, 2);\n```\n\nExample: Remove processed items\n```js\nvar items = [1, 2];\n\nitems.wait(function(item, next) {\n\tnext();\n}, function() {\n\tconsole.log(items.length);\n}, true);\n```\n","entries":[{"type":"method","name":"async()","signature":"arr.async([threads], [callback])","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"arr.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"arr.findAll(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"arr.findIndex(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"arr.findItem(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"arr.findValue(cb, value, path, [def])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"arr.group(name)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"arr.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"arr.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"arr.remove(cb, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"arr.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"arr.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"arr.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"arr.trim([empty])","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"arr.wait(onItem, [callback], [threads])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUG2AM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/array/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Array","summary":"Methoden, die jComponent zu Array.prototype hinzufügt, um Einträge zu finden, zu sortieren, zu gruppieren und zu verarbeiten.","markdown":"---\ntitle: Array\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/array/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Array\n\n> Methoden, die jComponent zu Array.prototype hinzufügt, um Einträge zu finden, zu sortieren, zu gruppieren und zu verarbeiten.\n\njComponent fügt diese Methoden zu `Array.prototype` hinzu. `findIndex()` ersetzt die native Methode und akzeptiert die hier beschriebenen Argumente. Die Suchmethoden werden oft mit Codelisten verwendet, die in [DEF](../def/) gespeichert sind.\n\n## API\n\n### arr.async([threads], [callback])\n\nType: `method`\n\nFührt ein Array von Funktionen nacheinander oder parallel aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `threads` | `Number` | no | `1` | Wie viele Funktionen gleichzeitig laufen. |\n| `callback` | `Function` | no |  | Wird aufgerufen, wenn alle Funktionen fertig sind. |\n\nReturns: `Array` Dasselbe Array.\n\nJede Funktion erhält eine Funktion `next`, die sie aufrufen muss, wenn ihre Arbeit erledigt ist. Das Array wird während des Laufs geleert. `threads` darf nicht größer sein als die Anzahl der Funktionen im Array.\n\nExample: Aufgaben der Reihe nach ausführen\n```js\nvar log = [];\n\nvar tasks = [\n\tfunction(next) { log.push('first'); setTimeout(next, 20); },\n\tfunction(next) { log.push('second'); next(); }\n];\n\ntasks.async(function() {\n\tconsole.log(log.join(', '));\n});\n```\n\n### arr.attr(name, [value])\n\nType: `method`\n\nFügt einem Array, das als HTML-Builder dient, ein HTML-Attribut 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 HTML-kodiert und durchläuft `env()`. Mit einem Argument ist der Attributname zugleich sein Wert. Mit zwei Argumenten fügt ein Wert `null` oder `undefined` nichts hinzu.\n\nExample: Ein Element aufbauen\n```js\nvar builder = ['<div'];\nbuilder.attr('id', 'box').attr('title', 'a<b').attr('hidden').attr('data-x', null);\nbuilder.join(' ') + '>'; // \"<div id=\\\"box\\\" title=\\\"a&lt;b\\\" hidden=\\\"hidden\\\">\"\n```\n\n### arr.findAll(cb, [value])\n\nType: `method`\n\nGibt alle Einträge zurück, die einer Bedingung entsprechen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Eine Funktion, ein Feldname oder ein zu suchender Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Array` Ein neues Array mit den passenden Einträgen.\n\nDie Bedingung hat eine von drei Formen: eine `function(item, index)`, ein Feldname mit einem Wert oder ein Wert, der mit jedem Eintrag verglichen wird.\n\nExample: Mehrere Einträge finden\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findAll('age', 25).length; // 1\nusers.findAll(user => user.age >= 30).length; // 2\n['a', 'b', 'a'].findAll('a'); // [\"a\",\"a\"]\n```\n\n### arr.findIndex(cb, [value])\n\nType: `method`\n\nGibt den Index des ersten Eintrags zurück, der einer Bedingung entspricht.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Eine Funktion, ein Feldname oder ein zu suchender Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Number` Der Index oder `-1`.\n\nDie Bedingung hat dieselben Formen wie bei [findAll()](#findall).\n\nExample: Einen Index finden\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findIndex('id', 2); // 1\nusers.findIndex(user => user.age > 30); // 2\nusers.findIndex('id', 99); // -1\n['a', 'b'].findIndex('b'); // 1\n```\n\n### arr.findItem(cb, [value])\n\nType: `method`\n\nGibt den ersten Eintrag zurück, der einer Bedingung entspricht.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Eine Funktion, ein Feldname oder ein zu suchender Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Object` Der Eintrag oder `undefined`.\n\nDie Bedingung hat dieselben Formen wie bei [findAll()](#findall).\n\nExample: Einen Eintrag finden\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findItem('id', 2).name; // \"Bob\"\nusers.findItem(user => user.age > 30).name; // \"Cid\"\nusers.findItem('id', 99); // undefined\n```\n\n### arr.findValue(cb, value, path, [def])\n\nType: `method`\n\nFindet einen Eintrag und gibt einen seiner Werte zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String or Function` | yes |  | Ein Feldname oder eine `function(item, index)`. |\n| `value` | `Object` | yes |  | Der Wert des Feldes. |\n| `path` | `String` | yes |  | Der Path des Werts, der aus dem Eintrag gelesen wird. |\n| `def` | `Object` | no |  | Der Wert, der zurückgegeben wird, wenn der Eintrag oder sein Wert nicht existiert. |\n\nReturns: `Object` Der gelesene Wert oder `def`.\n\nMit einer Funktion als Bedingung lässt du `value` weg: `arr.findValue(fn, path, [def])`. Der `path` kann verschachtelt sein, etwa `address.city`.\n\nExample: Wert lesen\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', address: { city: 'Rome' } },\n\t{ id: 2, name: 'Bob' }\n];\n\nusers.findValue('id', 1, 'name'); // \"Ann\"\nusers.findValue('id', 1, 'address.city'); // \"Rome\"\nusers.findValue('id', 9, 'name', 'unknown'); // \"unknown\"\nusers.findValue(user => user.id === 2, 'name'); // \"Bob\"\n```\n\n### arr.group(name)\n\nType: `method`\n\nGruppiert Objekte nach dem Wert eines Felds.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Feldname. |\n\nReturns: `Array` Objekte mit den Feldern `name` und `items`.\n\nDie Gruppennamen sind Texte, und die Gruppen werden als Text nach ihrem Namen sortiert. Einträge ohne Wert kommen in eine Gruppe mit leerem Namen.\n\nExample: Benutzer gruppieren\n```js\nvar users = [{ name: 'Ann', role: 'dev' }, { name: 'Bob', role: 'ops' }, { name: 'Cid', role: 'dev' }, { name: 'Dan' }];\nusers.group('role').map(group => group.name + ':' + group.items.length); // [\":1\",\"dev:2\",\"ops:1\"]\n```\n\n### arr.last([def])\n\nType: `method`\n\nGibt den letzten Eintrag des Arrays zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | Der Wert, der zurückgegeben wird, wenn der letzte Eintrag `undefined` ist. |\n\nReturns: `Object` Der letzte Eintrag oder `def`.\n\nExample: Den letzten Eintrag lesen\n```js\n[1, 2, 3].last(); // 3\n[].last('empty'); // \"empty\"\n```\n\n### arr.quicksort([sort], [direction])\n\nType: `method`\n\nSortiert das Array direkt nach einem oder mehreren Feldern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Die Felder, nach denen sortiert wird. |\n| `direction` | `String, Boolean or Number` | no |  | Verwende `'desc'`, `false` oder `2`, um ein einzelnes Feld absteigend zu sortieren. |\n\nReturns: `Array` Dasselbe Array.\n\n`sort` enthält durch Kommas getrennte Feldnamen. Jeder Name kann auf `_asc` oder `_desc` enden und ein verschachtelter Path wie `address.city` sein. Text wird gebietsschemabezogen verglichen. Zahlen, boolesche Werte und Datumswerte werden nach ihrem Typ verglichen.\n\nOhne `sort` werden die Einträge selbst aufsteigend als Text verglichen, Zahlen werden also als Text sortiert.\n\nExample: Nach Feldern sortieren\n```js\nvar users = [{ name: 'Bob', age: 25 }, { name: 'Ann', age: 30 }, { name: 'Cid', age: 25 }];\nvar names = () => users.map(user => user.name).join();\n\nusers.quicksort('name');\nnames(); // \"Ann,Bob,Cid\"\nusers.quicksort('name_desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('name', 'desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('age,name_desc');\nnames(); // \"Cid,Bob,Ann\"\n```\n\nExample: Werte sortieren\n```js\n['b', 'c', 'a'].quicksort(); // [\"a\",\"b\",\"c\"]\n[10, 9, 100].quicksort(); // [10,100,9]\n```\n\n### arr.remove(cb, [value])\n\nType: `method`\n\nGibt ein neues Array ohne die Einträge zurück, die einer Bedingung entsprechen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Eine Funktion, ein Feldname oder ein zu entfernender Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Array` Ein neues Array mit den verbleibenden Einträgen.\n\nDas ursprüngliche Array wird nicht verändert. Die Bedingung hat dieselben Formen wie bei [findAll()](#findall).\n\nExample: Einträge entfernen\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.remove('id', 2).length; // 2\nusers.remove(user => user.age > 26).length; // 1\n['a', 'b', 'a'].remove('a'); // [\"b\"]\nusers.length; // 3\n```\n\n### arr.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 |  | Wie viele Einträge übersprungen werden. |\n\nReturns: `Array` Ein neues Array.\n\nExample: Einträge überspringen\n```js\n[1, 2, 3, 4].skip(2); // [3,4]\n```\n\n### arr.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 |  | Wie viele Einträge genommen werden. |\n\nReturns: `Array` Ein neues Array.\n\nDie Anzahl muss mindestens 1 sein.\n\nExample: Einträge nehmen\n```js\n[1, 2, 3, 4].take(2); // [1,2]\n[1, 2].take(9); // [1,2]\n```\n\n### arr.takeskip(take, skip)\n\nType: `method`\n\nÜberspringt eine Anzahl von Einträgen und gibt die nächsten zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Wie viele Einträge zurückgegeben werden. |\n| `skip` | `Number` | yes |  | Wie viele Einträge übersprungen werden. |\n\nReturns: `Array` Ein neues Array.\n\nDas ist nützlich, um eine Seite einer Liste zu lesen.\n\nExample: Eine Seite lesen\n```js\n[1, 2, 3, 4, 5].takeskip(2, 1); // [2,3]\n```\n\n### arr.trim([empty])\n\nType: `method`\n\nKürzt die Strings des Arrays und entfernt leere Werte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `empty` | `Boolean` | no |  | Verwende `true`, um leere Werte zu behalten. |\n\nReturns: `Array` Ein neues Array.\n\nStrings werden auch im ursprünglichen Array gekürzt. Ohne `empty` lässt das Ergebnis jeden falsy Wert weg, auch `0` und `null`.\n\nExample: Eine Liste bereinigen\n```js\n[' a ', '', ' b', 0, 1].trim(); // [\"a\",\"b\",1]\n[' a ', '', 0].trim(true); // [\"a\",\"\",0]\n```\n\n### arr.wait(onItem, [callback], [threads])\n\nType: `method`\n\nVerarbeitet die Einträge nacheinander oder parallel mit einer asynchronen Funktion.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Verarbeitet einen Eintrag. |\n| `callback` | `Function` | no |  | Wird aufgerufen, wenn alle Einträge erledigt sind. |\n| `threads` | `Number or Boolean` | no | `1` | Wie viele Einträge gleichzeitig laufen, oder `true`, um verarbeitete Einträge zu entfernen. |\n\nReturns: `Array` Dasselbe Array.\n\n`onItem` wird als `function(item, next, index)` mit dem Array als `this` aufgerufen und muss `next` aufrufen, wenn der Eintrag erledigt ist. `index` ist die Position des Eintrags, beginnend bei 1.\n\nIst `threads` gleich `true`, werden die Einträge bei der Verarbeitung aus dem Array entfernt, und `index` ist immer `0`.\n\nExample: Einträge der Reihe nach verarbeiten\n```js\nvar output = [];\n\n['a', 'b', 'c'].wait(function(item, next, index) {\n\toutput.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(output.join(', '));\n});\n```\n\nExample: Zwei Einträge gleichzeitig\n```js\nvar output = [];\n\n[1, 2, 3].wait(function(item, next) {\n\toutput.push('start ' + item);\n\tsetTimeout(function() {\n\t\toutput.push('end ' + item);\n\t\tnext();\n\t}, item === 1 ? 30 : 5);\n}, function() {\n\tconsole.log(output.join(', '));\n}, 2);\n```\n\nExample: Verarbeitete Einträge entfernen\n```js\nvar items = [1, 2];\n\nitems.wait(function(item, next) {\n\tnext();\n}, function() {\n\tconsole.log(items.length);\n}, true);\n```\n","entries":[{"type":"method","name":"async()","signature":"arr.async([threads], [callback])","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"arr.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"arr.findAll(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"arr.findIndex(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"arr.findItem(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"arr.findValue(cb, value, path, [def])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"arr.group(name)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"arr.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"arr.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"arr.remove(cb, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"arr.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"arr.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"arr.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"arr.trim([empty])","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"arr.wait(onItem, [callback], [threads])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUG2AM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/array/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Array","summary":"Métodos que jComponent añade a Array.prototype para buscar, ordenar, agrupar y procesar ítems.","markdown":"---\ntitle: Array\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/array/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Array\n\n> Métodos que jComponent añade a Array.prototype para buscar, ordenar, agrupar y procesar ítems.\n\njComponent añade estos métodos a `Array.prototype`. `findIndex()` sustituye al método nativo y admite los argumentos que se describen aquí. Los métodos de búsqueda se usan a menudo con listas de códigos guardadas en [DEF](../def/).\n\n## API\n\n### arr.async([threads], [callback])\n\nType: `method`\n\nEjecuta un array de funciones una tras otra o en paralelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `threads` | `Number` | no | `1` | Cuántas funciones se ejecutan a la vez. |\n| `callback` | `Function` | no |  | Se llama cuando todas las funciones han terminado. |\n\nReturns: `Array` El mismo array.\n\nCada función recibe una función `next` a la que debe llamar cuando termina su trabajo. El array se vacía durante la ejecución. `threads` no debe ser mayor que el número de funciones del array.\n\nExample: Ejecutar tareas en orden\n```js\nvar log = [];\n\nvar tasks = [\n\tfunction(next) { log.push('first'); setTimeout(next, 20); },\n\tfunction(next) { log.push('second'); next(); }\n];\n\ntasks.async(function() {\n\tconsole.log(log.join(', '));\n});\n```\n\n### arr.attr(name, [value])\n\nType: `method`\n\nAñade un atributo HTML a un array que se usa para construir HTML.\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 codifica en HTML y pasa por `env()`. Con un argumento, el nombre del atributo es también su valor. Con dos argumentos, un valor `null` o `undefined` no añade nada.\n\nExample: Construir un elemento\n```js\nvar builder = ['<div'];\nbuilder.attr('id', 'box').attr('title', 'a<b').attr('hidden').attr('data-x', null);\nbuilder.join(' ') + '>'; // \"<div id=\\\"box\\\" title=\\\"a&lt;b\\\" hidden=\\\"hidden\\\">\"\n```\n\n### arr.findAll(cb, [value])\n\nType: `method`\n\nDevuelve todos los ítems que cumplen una condición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una función, un nombre de campo o un valor que se busca. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Array` Un array nuevo con los elementos que coinciden.\n\nLa condición tiene una de estas tres formas: una `function(item, index)`, un nombre de campo con un valor, o un valor que se compara con cada ítem.\n\nExample: Buscar varios ítems\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findAll('age', 25).length; // 1\nusers.findAll(user => user.age >= 30).length; // 2\n['a', 'b', 'a'].findAll('a'); // [\"a\",\"a\"]\n```\n\n### arr.findIndex(cb, [value])\n\nType: `method`\n\nDevuelve el índice del primer ítem que cumple una condición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una función, un nombre de campo o un valor que se busca. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Number` El índice, o `-1`.\n\nLa condición tiene las mismas formas que en [findAll()](#findall).\n\nExample: Buscar un índice\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findIndex('id', 2); // 1\nusers.findIndex(user => user.age > 30); // 2\nusers.findIndex('id', 99); // -1\n['a', 'b'].findIndex('b'); // 1\n```\n\n### arr.findItem(cb, [value])\n\nType: `method`\n\nDevuelve el primer ítem que cumple una condición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una función, un nombre de campo o un valor que se busca. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Object` El ítem, o `undefined`.\n\nLa condición tiene las mismas formas que en [findAll()](#findall).\n\nExample: Buscar un ítem\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findItem('id', 2).name; // \"Bob\"\nusers.findItem(user => user.age > 30).name; // \"Cid\"\nusers.findItem('id', 99); // undefined\n```\n\n### arr.findValue(cb, value, path, [def])\n\nType: `method`\n\nBusca un ítem y devuelve uno de sus valores.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String or Function` | yes |  | Un nombre de campo o una `function(item, index)`. |\n| `value` | `Object` | yes |  | El valor del campo. |\n| `path` | `String` | yes |  | El path del valor que se lee del ítem. |\n| `def` | `Object` | no |  | El valor que se devuelve cuando el ítem o su valor no existen. |\n\nReturns: `Object` El valor leído, o `def`.\n\nSi la condición es una función, omite `value`: `arr.findValue(fn, path, [def])`. El `path` puede ser anidado, como `address.city`.\n\nExample: Leer un valor\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', address: { city: 'Rome' } },\n\t{ id: 2, name: 'Bob' }\n];\n\nusers.findValue('id', 1, 'name'); // \"Ann\"\nusers.findValue('id', 1, 'address.city'); // \"Rome\"\nusers.findValue('id', 9, 'name', 'unknown'); // \"unknown\"\nusers.findValue(user => user.id === 2, 'name'); // \"Bob\"\n```\n\n### arr.group(name)\n\nType: `method`\n\nAgrupa objetos por el valor de un campo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del campo. |\n\nReturns: `Array` Objetos con los campos `name` e `items`.\n\nLos nombres de los grupos son textos, y los grupos se ordenan por nombre como texto. Los ítems sin valor van a un grupo con el nombre vacío.\n\nExample: Agrupar usuarios\n```js\nvar users = [{ name: 'Ann', role: 'dev' }, { name: 'Bob', role: 'ops' }, { name: 'Cid', role: 'dev' }, { name: 'Dan' }];\nusers.group('role').map(group => group.name + ':' + group.items.length); // [\":1\",\"dev:2\",\"ops:1\"]\n```\n\n### arr.last([def])\n\nType: `method`\n\nDevuelve el último ítem del array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | El valor que se devuelve cuando el último ítem es `undefined`. |\n\nReturns: `Object` El último ítem, o `def`.\n\nExample: Leer el último ítem\n```js\n[1, 2, 3].last(); // 3\n[].last('empty'); // \"empty\"\n```\n\n### arr.quicksort([sort], [direction])\n\nType: `method`\n\nOrdena el propio array, sin crear una copia, por uno o varios campos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Los campos por los que se ordena. |\n| `direction` | `String, Boolean or Number` | no |  | Usa `'desc'`, `false` o `2` para ordenar un solo campo en orden descendente. |\n\nReturns: `Array` El mismo array.\n\n`sort` contiene nombres de campos separados por comas. Cada nombre puede terminar en `_asc` o `_desc`, y puede ser un path anidado como `address.city`. El texto se compara teniendo en cuenta la configuración regional. Los números, los booleanos y las fechas se comparan según su tipo.\n\nSin `sort`, los propios ítems se comparan como texto en orden ascendente, de modo que los números se ordenan como texto.\n\nExample: Ordenar por campos\n```js\nvar users = [{ name: 'Bob', age: 25 }, { name: 'Ann', age: 30 }, { name: 'Cid', age: 25 }];\nvar names = () => users.map(user => user.name).join();\n\nusers.quicksort('name');\nnames(); // \"Ann,Bob,Cid\"\nusers.quicksort('name_desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('name', 'desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('age,name_desc');\nnames(); // \"Cid,Bob,Ann\"\n```\n\nExample: Ordenar valores\n```js\n['b', 'c', 'a'].quicksort(); // [\"a\",\"b\",\"c\"]\n[10, 9, 100].quicksort(); // [10,100,9]\n```\n\n### arr.remove(cb, [value])\n\nType: `method`\n\nDevuelve un array nuevo sin los ítems que cumplen una condición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una función, un nombre de campo o un valor que se elimina. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Array` Un array nuevo con los elementos restantes.\n\nEl array original no cambia. La condición tiene las mismas formas que en [findAll()](#findall).\n\nExample: Eliminar ítems\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.remove('id', 2).length; // 2\nusers.remove(user => user.age > 26).length; // 1\n['a', 'b', 'a'].remove('a'); // [\"b\"]\nusers.length; // 3\n```\n\n### arr.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 |  | Cuántos ítems se omiten. |\n\nReturns: `Array` Un array nuevo.\n\nExample: Omitir ítems\n```js\n[1, 2, 3, 4].skip(2); // [3,4]\n```\n\n### arr.take(count)\n\nType: `method`\n\nDevuelve los primeros `count` elementos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Cuántos ítems se toman. |\n\nReturns: `Array` Un array nuevo.\n\nLa cantidad debe ser 1 o más.\n\nExample: Tomar ítems\n```js\n[1, 2, 3, 4].take(2); // [1,2]\n[1, 2].take(9); // [1,2]\n```\n\n### arr.takeskip(take, skip)\n\nType: `method`\n\nOmite una cantidad de ítems y devuelve los siguientes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Cuántos ítems se devuelven. |\n| `skip` | `Number` | yes |  | Cuántos ítems se omiten. |\n\nReturns: `Array` Un array nuevo.\n\nResulta útil para leer una página de una lista.\n\nExample: Leer una página\n```js\n[1, 2, 3, 4, 5].takeskip(2, 1); // [2,3]\n```\n\n### arr.trim([empty])\n\nType: `method`\n\nRecorta las cadenas del array y elimina los valores vacíos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `empty` | `Boolean` | no |  | Usa `true` para conservar los valores vacíos. |\n\nReturns: `Array` Un array nuevo.\n\nLas cadenas también se recortan en el array original. Sin `empty`, el resultado omite todos los valores falsy, incluidos `0` y `null`.\n\nExample: Limpiar una lista\n```js\n[' a ', '', ' b', 0, 1].trim(); // [\"a\",\"b\",1]\n[' a ', '', 0].trim(true); // [\"a\",\"\",0]\n```\n\n### arr.wait(onItem, [callback], [threads])\n\nType: `method`\n\nProcesa los ítems uno a uno o en paralelo con una función asíncrona.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Procesa un ítem. |\n| `callback` | `Function` | no |  | Se llama cuando todos los ítems han terminado. |\n| `threads` | `Number or Boolean` | no | `1` | Cuántos ítems se ejecutan a la vez, o `true` para eliminar los ítems procesados. |\n\nReturns: `Array` El mismo array.\n\n`onItem` se llama como `function(item, next, index)` con el array como `this`, y debe llamar a `next` cuando termina con el ítem. `index` es la posición del ítem, empezando por 1.\n\nCuando `threads` es `true`, los ítems se eliminan del array a medida que se procesan, e `index` es siempre `0`.\n\nExample: Procesar ítems en orden\n```js\nvar output = [];\n\n['a', 'b', 'c'].wait(function(item, next, index) {\n\toutput.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(output.join(', '));\n});\n```\n\nExample: Dos elementos cada vez\n```js\nvar output = [];\n\n[1, 2, 3].wait(function(item, next) {\n\toutput.push('start ' + item);\n\tsetTimeout(function() {\n\t\toutput.push('end ' + item);\n\t\tnext();\n\t}, item === 1 ? 30 : 5);\n}, function() {\n\tconsole.log(output.join(', '));\n}, 2);\n```\n\nExample: Eliminar los ítems procesados\n```js\nvar items = [1, 2];\n\nitems.wait(function(item, next) {\n\tnext();\n}, function() {\n\tconsole.log(items.length);\n}, true);\n```\n","entries":[{"type":"method","name":"async()","signature":"arr.async([threads], [callback])","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"arr.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"arr.findAll(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"arr.findIndex(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"arr.findItem(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"arr.findValue(cb, value, path, [def])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"arr.group(name)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"arr.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"arr.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"arr.remove(cb, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"arr.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"arr.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"arr.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"arr.trim([empty])","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"arr.wait(onItem, [callback], [threads])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUG2AM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/array/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Array","summary":"Les méthodes que jComponent ajoute à Array.prototype pour trouver, trier, regrouper et traiter des éléments.","markdown":"---\ntitle: Array\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/array/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Array\n\n> Les méthodes que jComponent ajoute à Array.prototype pour trouver, trier, regrouper et traiter des éléments.\n\njComponent ajoute ces méthodes à `Array.prototype`. `findIndex()` remplace la méthode native et accepte les arguments décrits ici. Les méthodes de recherche sont souvent utilisées avec les listes de codes stockées dans [DEF](../def/).\n\n## API\n\n### arr.async([threads], [callback])\n\nType: `method`\n\nExécute un tableau de fonctions l'une après l'autre ou en parallèle.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `threads` | `Number` | no | `1` | Le nombre de fonctions exécutées en même temps. |\n| `callback` | `Function` | no |  | Appelée quand toutes les fonctions sont terminées. |\n\nReturns: `Array` Le même tableau.\n\nChaque fonction reçoit une fonction `next` qu'elle doit appeler quand son travail est terminé. Le tableau se vide pendant l'exécution. `threads` ne doit pas dépasser le nombre de fonctions du tableau.\n\nExample: Exécuter des tâches dans l'ordre\n```js\nvar log = [];\n\nvar tasks = [\n\tfunction(next) { log.push('first'); setTimeout(next, 20); },\n\tfunction(next) { log.push('second'); next(); }\n];\n\ntasks.async(function() {\n\tconsole.log(log.join(', '));\n});\n```\n\n### arr.attr(name, [value])\n\nType: `method`\n\nAjoute un attribut HTML à un tableau utilisé pour construire du HTML.\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 encodée en HTML et passe par `env()`. Avec un seul argument, le nom de l'attribut est aussi sa valeur. Avec deux arguments, une valeur `null` ou `undefined` n'ajoute rien.\n\nExample: Construire un élément\n```js\nvar builder = ['<div'];\nbuilder.attr('id', 'box').attr('title', 'a<b').attr('hidden').attr('data-x', null);\nbuilder.join(' ') + '>'; // \"<div id=\\\"box\\\" title=\\\"a&lt;b\\\" hidden=\\\"hidden\\\">\"\n```\n\n### arr.findAll(cb, [value])\n\nType: `method`\n\nRenvoie tous les éléments qui remplissent une condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Une fonction, un nom de champ ou une valeur à trouver. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Array` Un nouveau tableau contenant les éléments correspondants.\n\nLa condition prend l'une de ces trois formes : une `function(item, index)`, un nom de champ avec une valeur, ou une valeur comparée à chaque élément.\n\nExample: Trouver plusieurs éléments\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findAll('age', 25).length; // 1\nusers.findAll(user => user.age >= 30).length; // 2\n['a', 'b', 'a'].findAll('a'); // [\"a\",\"a\"]\n```\n\n### arr.findIndex(cb, [value])\n\nType: `method`\n\nRenvoie l'index du premier élément qui remplit une condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Une fonction, un nom de champ ou une valeur à trouver. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Number` L'index, ou `-1`.\n\nLa condition a les mêmes formes que dans [findAll()](#findall).\n\nExample: Trouver un index\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findIndex('id', 2); // 1\nusers.findIndex(user => user.age > 30); // 2\nusers.findIndex('id', 99); // -1\n['a', 'b'].findIndex('b'); // 1\n```\n\n### arr.findItem(cb, [value])\n\nType: `method`\n\nRenvoie le premier élément qui remplit une condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Une fonction, un nom de champ ou une valeur à trouver. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Object` L'élément, ou `undefined`.\n\nLa condition a les mêmes formes que dans [findAll()](#findall).\n\nExample: Trouver un élément\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findItem('id', 2).name; // \"Bob\"\nusers.findItem(user => user.age > 30).name; // \"Cid\"\nusers.findItem('id', 99); // undefined\n```\n\n### arr.findValue(cb, value, path, [def])\n\nType: `method`\n\nTrouve un élément et renvoie l'une de ses valeurs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String or Function` | yes |  | Un nom de champ ou une `function(item, index)`. |\n| `value` | `Object` | yes |  | La valeur du champ. |\n| `path` | `String` | yes |  | Le path de la valeur à lire dans l'élément. |\n| `def` | `Object` | no |  | La valeur renvoyée quand l'élément ou sa valeur n'existe pas. |\n\nReturns: `Object` La valeur lue, ou `def`.\n\nAvec une fonction comme condition, omets `value` : `arr.findValue(fn, path, [def])`. Le `path` peut être imbriqué, comme `address.city`.\n\nExample: Lire une valeur\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', address: { city: 'Rome' } },\n\t{ id: 2, name: 'Bob' }\n];\n\nusers.findValue('id', 1, 'name'); // \"Ann\"\nusers.findValue('id', 1, 'address.city'); // \"Rome\"\nusers.findValue('id', 9, 'name', 'unknown'); // \"unknown\"\nusers.findValue(user => user.id === 2, 'name'); // \"Bob\"\n```\n\n### arr.group(name)\n\nType: `method`\n\nRegroupe des objets selon la valeur d'un champ.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du champ. |\n\nReturns: `Array` Des objets avec les champs `name` et `items`.\n\nLes noms de groupe sont des textes, et les groupes sont triés par nom en tant que texte. Les éléments sans valeur vont dans un groupe au nom vide.\n\nExample: Regrouper des utilisateurs\n```js\nvar users = [{ name: 'Ann', role: 'dev' }, { name: 'Bob', role: 'ops' }, { name: 'Cid', role: 'dev' }, { name: 'Dan' }];\nusers.group('role').map(group => group.name + ':' + group.items.length); // [\":1\",\"dev:2\",\"ops:1\"]\n```\n\n### arr.last([def])\n\nType: `method`\n\nRenvoie le dernier élément du tableau.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | La valeur renvoyée quand le dernier élément vaut `undefined`. |\n\nReturns: `Object` Le dernier élément, ou `def`.\n\nExample: Lire le dernier élément\n```js\n[1, 2, 3].last(); // 3\n[].last('empty'); // \"empty\"\n```\n\n### arr.quicksort([sort], [direction])\n\nType: `method`\n\nTrie le tableau sur place selon un ou plusieurs champs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Les champs de tri. |\n| `direction` | `String, Boolean or Number` | no |  | Utilise `'desc'`, `false` ou `2` pour trier un seul champ par ordre décroissant. |\n\nReturns: `Array` Le même tableau.\n\n`sort` contient des noms de champs séparés par des virgules. Chaque nom peut se terminer par `_asc` ou `_desc`, et il peut être un path imbriqué comme `address.city`. Le texte utilise une comparaison tenant compte de la locale. Les nombres, les booléens et les dates sont comparés selon leur type.\n\nSans `sort`, les éléments eux-mêmes sont comparés en tant que texte par ordre croissant, les nombres sont donc triés comme du texte.\n\nExample: Trier par champs\n```js\nvar users = [{ name: 'Bob', age: 25 }, { name: 'Ann', age: 30 }, { name: 'Cid', age: 25 }];\nvar names = () => users.map(user => user.name).join();\n\nusers.quicksort('name');\nnames(); // \"Ann,Bob,Cid\"\nusers.quicksort('name_desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('name', 'desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('age,name_desc');\nnames(); // \"Cid,Bob,Ann\"\n```\n\nExample: Trier des valeurs\n```js\n['b', 'c', 'a'].quicksort(); // [\"a\",\"b\",\"c\"]\n[10, 9, 100].quicksort(); // [10,100,9]\n```\n\n### arr.remove(cb, [value])\n\nType: `method`\n\nRenvoie un nouveau tableau sans les éléments qui remplissent une condition.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Une fonction, un nom de champ ou une valeur à supprimer. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Array` Un nouveau tableau contenant les éléments restants.\n\nLe tableau d'origine n'est pas modifié. La condition a les mêmes formes que dans [findAll()](#findall).\n\nExample: Supprimer des éléments\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.remove('id', 2).length; // 2\nusers.remove(user => user.age > 26).length; // 1\n['a', 'b', 'a'].remove('a'); // [\"b\"]\nusers.length; // 3\n```\n\n### arr.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 à ignorer. |\n\nReturns: `Array` Un nouveau tableau.\n\nExample: Ignorer des éléments\n```js\n[1, 2, 3, 4].skip(2); // [3,4]\n```\n\n### arr.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 à prendre. |\n\nReturns: `Array` Un nouveau tableau.\n\nLe nombre doit être supérieur ou égal à 1.\n\nExample: Prendre des éléments\n```js\n[1, 2, 3, 4].take(2); // [1,2]\n[1, 2].take(9); // [1,2]\n```\n\n### arr.takeskip(take, skip)\n\nType: `method`\n\nIgnore 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 à ignorer. |\n\nReturns: `Array` Un nouveau tableau.\n\nC'est utile pour lire une page d'une liste.\n\nExample: Lire une page\n```js\n[1, 2, 3, 4, 5].takeskip(2, 1); // [2,3]\n```\n\n### arr.trim([empty])\n\nType: `method`\n\nSupprime les espaces autour des chaînes du tableau et retire les valeurs vides.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `empty` | `Boolean` | no |  | Utilise `true` pour conserver les valeurs vides. |\n\nReturns: `Array` Un nouveau tableau.\n\nLes espaces sont aussi supprimés dans les chaînes du tableau d'origine. Sans `empty`, le résultat exclut toute valeur fausse, y compris `0` et `null`.\n\nExample: Nettoyer une liste\n```js\n[' a ', '', ' b', 0, 1].trim(); // [\"a\",\"b\",1]\n[' a ', '', 0].trim(true); // [\"a\",\"\",0]\n```\n\n### arr.wait(onItem, [callback], [threads])\n\nType: `method`\n\nTraite les éléments un par un ou en parallèle avec une fonction asynchrone.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Traite un élément. |\n| `callback` | `Function` | no |  | Appelée quand tous les éléments sont terminés. |\n| `threads` | `Number or Boolean` | no | `1` | Le nombre d'éléments traités en même temps, ou `true` pour retirer les éléments traités. |\n\nReturns: `Array` Le même tableau.\n\n`onItem` est appelée sous la forme `function(item, next, index)` avec le tableau comme `this`, et elle doit appeler `next` quand l'élément est terminé. `index` est la position de l'élément, à partir de 1.\n\nQuand `threads` vaut `true`, les éléments sont retirés du tableau au fur et à mesure de leur traitement, et `index` vaut toujours `0`.\n\nExample: Traiter les éléments dans l'ordre\n```js\nvar output = [];\n\n['a', 'b', 'c'].wait(function(item, next, index) {\n\toutput.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(output.join(', '));\n});\n```\n\nExample: Deux éléments à la fois\n```js\nvar output = [];\n\n[1, 2, 3].wait(function(item, next) {\n\toutput.push('start ' + item);\n\tsetTimeout(function() {\n\t\toutput.push('end ' + item);\n\t\tnext();\n\t}, item === 1 ? 30 : 5);\n}, function() {\n\tconsole.log(output.join(', '));\n}, 2);\n```\n\nExample: Retirer les éléments traités\n```js\nvar items = [1, 2];\n\nitems.wait(function(item, next) {\n\tnext();\n}, function() {\n\tconsole.log(items.length);\n}, true);\n```\n","entries":[{"type":"method","name":"async()","signature":"arr.async([threads], [callback])","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"arr.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"arr.findAll(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"arr.findIndex(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"arr.findItem(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"arr.findValue(cb, value, path, [def])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"arr.group(name)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"arr.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"arr.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"arr.remove(cb, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"arr.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"arr.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"arr.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"arr.trim([empty])","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"arr.wait(onItem, [callback], [threads])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUG2AM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/array/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Array","summary":"Metodi che jComponent aggiunge a Array.prototype per trovare, ordinare, raggruppare ed elaborare gli elementi.","markdown":"---\ntitle: Array\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/array/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Array\n\n> Metodi che jComponent aggiunge a Array.prototype per trovare, ordinare, raggruppare ed elaborare gli elementi.\n\njComponent aggiunge questi metodi a `Array.prototype`. `findIndex()` sostituisce il metodo nativo e accetta gli argomenti descritti qui. I metodi di ricerca si usano spesso con gli elenchi di codici memorizzati in [DEF](../def/).\n\n## API\n\n### arr.async([threads], [callback])\n\nType: `method`\n\nEsegue un array di funzioni una dopo l'altra o in parallelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `threads` | `Number` | no | `1` | Quante funzioni vengono eseguite contemporaneamente. |\n| `callback` | `Function` | no |  | Chiamato quando tutte le funzioni hanno terminato. |\n\nReturns: `Array` Lo stesso array.\n\nOgni funzione riceve una funzione `next` che deve chiamare quando ha finito il proprio lavoro. L'array viene svuotato durante l'esecuzione. `threads` non deve superare il numero di funzioni nell'array.\n\nExample: Esegui le attività in ordine\n```js\nvar log = [];\n\nvar tasks = [\n\tfunction(next) { log.push('first'); setTimeout(next, 20); },\n\tfunction(next) { log.push('second'); next(); }\n];\n\ntasks.async(function() {\n\tconsole.log(log.join(', '));\n});\n```\n\n### arr.attr(name, [value])\n\nType: `method`\n\nAggiunge un attributo HTML a un array usato per costruire HTML.\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 codificato in HTML e passa attraverso `env()`. Con un solo argomento, il nome dell'attributo è anche il suo valore. Con due argomenti, un valore `null` o `undefined` non aggiunge nulla.\n\nExample: Costruisci un elemento\n```js\nvar builder = ['<div'];\nbuilder.attr('id', 'box').attr('title', 'a<b').attr('hidden').attr('data-x', null);\nbuilder.join(' ') + '>'; // \"<div id=\\\"box\\\" title=\\\"a&lt;b\\\" hidden=\\\"hidden\\\">\"\n```\n\n### arr.findAll(cb, [value])\n\nType: `method`\n\nRestituisce tutti gli elementi che soddisfano una condizione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una funzione, un nome di campo o un valore da trovare. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Array` Un nuovo array con gli elementi corrispondenti.\n\nLa condizione ha una di tre forme: una `function(item, index)`, un nome di campo con un valore, oppure un valore confrontato con ogni elemento.\n\nExample: Trova più elementi\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findAll('age', 25).length; // 1\nusers.findAll(user => user.age >= 30).length; // 2\n['a', 'b', 'a'].findAll('a'); // [\"a\",\"a\"]\n```\n\n### arr.findIndex(cb, [value])\n\nType: `method`\n\nRestituisce l'indice del primo elemento che soddisfa una condizione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una funzione, un nome di campo o un valore da trovare. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Number` L'indice, oppure `-1`.\n\nLa condizione ha le stesse forme di [findAll()](#findall).\n\nExample: Trova un indice\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findIndex('id', 2); // 1\nusers.findIndex(user => user.age > 30); // 2\nusers.findIndex('id', 99); // -1\n['a', 'b'].findIndex('b'); // 1\n```\n\n### arr.findItem(cb, [value])\n\nType: `method`\n\nRestituisce il primo elemento che soddisfa una condizione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una funzione, un nome di campo o un valore da trovare. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Object` L'elemento, oppure `undefined`.\n\nLa condizione ha le stesse forme di [findAll()](#findall).\n\nExample: Trova un elemento\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findItem('id', 2).name; // \"Bob\"\nusers.findItem(user => user.age > 30).name; // \"Cid\"\nusers.findItem('id', 99); // undefined\n```\n\n### arr.findValue(cb, value, path, [def])\n\nType: `method`\n\nTrova un elemento e restituisce uno dei suoi valori.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String or Function` | yes |  | Un nome di campo o una `function(item, index)`. |\n| `value` | `Object` | yes |  | Il valore del campo. |\n| `path` | `String` | yes |  | Il path del valore da leggere dall'elemento. |\n| `def` | `Object` | no |  | Il valore restituito quando l'elemento o il suo valore non esiste. |\n\nReturns: `Object` Il valore letto, oppure `def`.\n\nCon una funzione come condizione, ometti `value`: `arr.findValue(fn, path, [def])`. Il `path` può essere annidato, come `address.city`.\n\nExample: Leggi un valore\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', address: { city: 'Rome' } },\n\t{ id: 2, name: 'Bob' }\n];\n\nusers.findValue('id', 1, 'name'); // \"Ann\"\nusers.findValue('id', 1, 'address.city'); // \"Rome\"\nusers.findValue('id', 9, 'name', 'unknown'); // \"unknown\"\nusers.findValue(user => user.id === 2, 'name'); // \"Bob\"\n```\n\n### arr.group(name)\n\nType: `method`\n\nRaggruppa gli oggetti in base al valore di un campo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del campo. |\n\nReturns: `Array` Oggetti con i campi `name` e `items`.\n\nI nomi dei gruppi sono testi e i gruppi vengono ordinati per nome come testo. Gli elementi senza valore finiscono in un gruppo con nome vuoto.\n\nExample: Raggruppa gli utenti\n```js\nvar users = [{ name: 'Ann', role: 'dev' }, { name: 'Bob', role: 'ops' }, { name: 'Cid', role: 'dev' }, { name: 'Dan' }];\nusers.group('role').map(group => group.name + ':' + group.items.length); // [\":1\",\"dev:2\",\"ops:1\"]\n```\n\n### arr.last([def])\n\nType: `method`\n\nRestituisce l'ultimo elemento dell'array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | Il valore restituito quando l'ultimo elemento è `undefined`. |\n\nReturns: `Object` L'ultimo elemento, oppure `def`.\n\nExample: Leggi l'ultimo elemento\n```js\n[1, 2, 3].last(); // 3\n[].last('empty'); // \"empty\"\n```\n\n### arr.quicksort([sort], [direction])\n\nType: `method`\n\nOrdina l'array sul posto in base a uno o più campi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | I campi in base ai quali ordinare. |\n| `direction` | `String, Boolean or Number` | no |  | Usa `'desc'`, `false` o `2` per ordinare un singolo campo in ordine decrescente. |\n\nReturns: `Array` Lo stesso array.\n\n`sort` contiene nomi di campo separati da virgole. Ogni nome può terminare con `_asc` o `_desc` e può essere un path annidato come `address.city`. Il testo usa un confronto basato sulla lingua. Numeri, booleani e date vengono confrontati in base al tipo.\n\nSenza `sort`, gli elementi stessi vengono confrontati come testo in ordine crescente, quindi anche i numeri vengono ordinati come testo.\n\nExample: Ordina per campi\n```js\nvar users = [{ name: 'Bob', age: 25 }, { name: 'Ann', age: 30 }, { name: 'Cid', age: 25 }];\nvar names = () => users.map(user => user.name).join();\n\nusers.quicksort('name');\nnames(); // \"Ann,Bob,Cid\"\nusers.quicksort('name_desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('name', 'desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('age,name_desc');\nnames(); // \"Cid,Bob,Ann\"\n```\n\nExample: Ordina i valori\n```js\n['b', 'c', 'a'].quicksort(); // [\"a\",\"b\",\"c\"]\n[10, 9, 100].quicksort(); // [10,100,9]\n```\n\n### arr.remove(cb, [value])\n\nType: `method`\n\nRestituisce un nuovo array senza gli elementi che soddisfano una condizione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Una funzione, un nome di campo o un valore da rimuovere. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Array` Un nuovo array con gli elementi rimanenti.\n\nL'array originale non viene modificato. La condizione ha le stesse forme di [findAll()](#findall).\n\nExample: Rimuovi gli elementi\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.remove('id', 2).length; // 2\nusers.remove(user => user.age > 26).length; // 1\n['a', 'b', 'a'].remove('a'); // [\"b\"]\nusers.length; // 3\n```\n\n### arr.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 |  | Quanti elementi saltare. |\n\nReturns: `Array` Un nuovo array.\n\nExample: Salta gli elementi\n```js\n[1, 2, 3, 4].skip(2); // [3,4]\n```\n\n### arr.take(count)\n\nType: `method`\n\nRestituisce i primi `count` elementi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Quanti elementi prendere. |\n\nReturns: `Array` Un nuovo array.\n\nIl conteggio deve essere pari o superiore a 1.\n\nExample: Prendi gli elementi\n```js\n[1, 2, 3, 4].take(2); // [1,2]\n[1, 2].take(9); // [1,2]\n```\n\n### arr.takeskip(take, skip)\n\nType: `method`\n\nSalta un certo numero di elementi e restituisce i successivi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Quanti elementi restituire. |\n| `skip` | `Number` | yes |  | Quanti elementi saltare. |\n\nReturns: `Array` Un nuovo array.\n\nÈ utile per leggere una pagina di un elenco.\n\nExample: Leggi una pagina\n```js\n[1, 2, 3, 4, 5].takeskip(2, 1); // [2,3]\n```\n\n### arr.trim([empty])\n\nType: `method`\n\nElimina gli spazi dalle stringhe dell'array e rimuove i valori vuoti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `empty` | `Boolean` | no |  | Usa `true` per mantenere i valori vuoti. |\n\nReturns: `Array` Un nuovo array.\n\nGli spazi vengono eliminati anche dalle stringhe dell'array originale. Senza `empty`, il risultato esclude ogni valore falsy, compresi `0` e `null`.\n\nExample: Pulisci un elenco\n```js\n[' a ', '', ' b', 0, 1].trim(); // [\"a\",\"b\",1]\n[' a ', '', 0].trim(true); // [\"a\",\"\",0]\n```\n\n### arr.wait(onItem, [callback], [threads])\n\nType: `method`\n\nElabora gli elementi uno alla volta o in parallelo con una funzione asincrona.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Elabora un elemento. |\n| `callback` | `Function` | no |  | Chiamato quando tutti gli elementi sono completati. |\n| `threads` | `Number or Boolean` | no | `1` | Quanti elementi vengono elaborati contemporaneamente, oppure `true` per rimuovere gli elementi elaborati. |\n\nReturns: `Array` Lo stesso array.\n\n`onItem` viene chiamata come `function(item, next, index)` con l'array come `this` e deve chiamare `next` quando l'elemento è completato. `index` è la posizione dell'elemento, a partire da 1.\n\nQuando `threads` è `true`, gli elementi vengono rimossi dall'array man mano che vengono elaborati e `index` è sempre `0`.\n\nExample: Elabora gli elementi in ordine\n```js\nvar output = [];\n\n['a', 'b', 'c'].wait(function(item, next, index) {\n\toutput.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(output.join(', '));\n});\n```\n\nExample: Due elementi alla volta\n```js\nvar output = [];\n\n[1, 2, 3].wait(function(item, next) {\n\toutput.push('start ' + item);\n\tsetTimeout(function() {\n\t\toutput.push('end ' + item);\n\t\tnext();\n\t}, item === 1 ? 30 : 5);\n}, function() {\n\tconsole.log(output.join(', '));\n}, 2);\n```\n\nExample: Rimuovi gli elementi elaborati\n```js\nvar items = [1, 2];\n\nitems.wait(function(item, next) {\n\tnext();\n}, function() {\n\tconsole.log(items.length);\n}, true);\n```\n","entries":[{"type":"method","name":"async()","signature":"arr.async([threads], [callback])","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"arr.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"arr.findAll(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"arr.findIndex(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"arr.findItem(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"arr.findValue(cb, value, path, [def])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"arr.group(name)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"arr.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"arr.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"arr.remove(cb, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"arr.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"arr.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"arr.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"arr.trim([empty])","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"arr.wait(onItem, [callback], [threads])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammUG2AM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/array/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Array","summary":"Metódy, ktoré jComponent pridáva do Array.prototype na vyhľadávanie, zoraďovanie, zoskupovanie a spracovanie položiek.","markdown":"---\ntitle: Array\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/array/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Array\n\n> Metódy, ktoré jComponent pridáva do Array.prototype na vyhľadávanie, zoraďovanie, zoskupovanie a spracovanie položiek.\n\njComponent pridáva tieto metódy do `Array.prototype`. `findIndex()` nahrádza natívnu metódu a prijíma argumenty popísané v tejto časti. Vyhľadávacie metódy sa často používajú so zoznamami kódov uloženými v [DEF](../def/).\n\n## API\n\n### arr.async([threads], [callback])\n\nType: `method`\n\nSpustí pole funkcií jednu po druhej alebo paralelne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `threads` | `Number` | no | `1` | Koľko funkcií beží súčasne. |\n| `callback` | `Function` | no |  | Zavolá sa, keď všetky funkcie skončia. |\n\nReturns: `Array` To isté pole.\n\nKaždá funkcia dostane funkciu `next`, ktorú musí zavolať po dokončení svojej práce. Pole sa počas behu vyprázdňuje. `threads` nesmie byť vyššie ako počet funkcií v poli.\n\nExample: Spusti úlohy postupne\n```js\nvar log = [];\n\nvar tasks = [\n\tfunction(next) { log.push('first'); setTimeout(next, 20); },\n\tfunction(next) { log.push('second'); next(); }\n];\n\ntasks.async(function() {\n\tconsole.log(log.join(', '));\n});\n```\n\n### arr.attr(name, [value])\n\nType: `method`\n\nPridá atribút HTML do poľa používaného na zostavovanie HTML.\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 zakóduje pre HTML a prejde cez `env()`. Pri jednom argumente je názov atribútu zároveň jeho hodnotou. Pri dvoch argumentoch hodnota `null` alebo `undefined` nič nepridá.\n\nExample: Zostav element\n```js\nvar builder = ['<div'];\nbuilder.attr('id', 'box').attr('title', 'a<b').attr('hidden').attr('data-x', null);\nbuilder.join(' ') + '>'; // \"<div id=\\\"box\\\" title=\\\"a&lt;b\\\" hidden=\\\"hidden\\\">\"\n```\n\n### arr.findAll(cb, [value])\n\nType: `method`\n\nVráti všetky položky, ktoré spĺňajú podmienku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Funkcia, názov poľa alebo hľadaná hodnota. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Array` Nové pole so zodpovedajúcimi položkami.\n\nPodmienka má jeden z troch tvarov: `function(item, index)`, názov poľa s hodnotou alebo hodnota porovnávaná s každou položkou.\n\nExample: Nájdi viacero položiek\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findAll('age', 25).length; // 1\nusers.findAll(user => user.age >= 30).length; // 2\n['a', 'b', 'a'].findAll('a'); // [\"a\",\"a\"]\n```\n\n### arr.findIndex(cb, [value])\n\nType: `method`\n\nVráti index prvej položky, ktorá spĺňa podmienku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Funkcia, názov poľa alebo hľadaná hodnota. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Number` Index alebo `-1`.\n\nPodmienka má rovnaké tvary ako vo [findAll()](#findall).\n\nExample: Nájdi index\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findIndex('id', 2); // 1\nusers.findIndex(user => user.age > 30); // 2\nusers.findIndex('id', 99); // -1\n['a', 'b'].findIndex('b'); // 1\n```\n\n### arr.findItem(cb, [value])\n\nType: `method`\n\nVráti prvú položku, ktorá spĺňa podmienku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Funkcia, názov poľa alebo hľadaná hodnota. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Object` Položka alebo `undefined`.\n\nPodmienka má rovnaké tvary ako vo [findAll()](#findall).\n\nExample: Nájdi položku\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.findItem('id', 2).name; // \"Bob\"\nusers.findItem(user => user.age > 30).name; // \"Cid\"\nusers.findItem('id', 99); // undefined\n```\n\n### arr.findValue(cb, value, path, [def])\n\nType: `method`\n\nNájde položku a vráti jednu z jej hodnôt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String or Function` | yes |  | Názov poľa alebo `function(item, index)`. |\n| `value` | `Object` | yes |  | Hodnota poľa. |\n| `path` | `String` | yes |  | Path hodnoty, ktorá sa má z položky prečítať. |\n| `def` | `Object` | no |  | Hodnota vrátená, keď položka alebo jej hodnota neexistuje. |\n\nReturns: `Object` Prečítaná hodnota alebo `def`.\n\nAk je podmienkou funkcia, vynechaj `value`: `arr.findValue(fn, path, [def])`. `path` môže byť vnorená, napríklad `address.city`.\n\nExample: Prečítaj hodnotu\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', address: { city: 'Rome' } },\n\t{ id: 2, name: 'Bob' }\n];\n\nusers.findValue('id', 1, 'name'); // \"Ann\"\nusers.findValue('id', 1, 'address.city'); // \"Rome\"\nusers.findValue('id', 9, 'name', 'unknown'); // \"unknown\"\nusers.findValue(user => user.id === 2, 'name'); // \"Bob\"\n```\n\n### arr.group(name)\n\nType: `method`\n\nZoskupí objekty podľa hodnoty poľa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov poľa. |\n\nReturns: `Array` Objekty s poľami `name` a `items`.\n\nNázvy skupín sú texty a skupiny sa zoraďujú podľa názvu ako text. Položky bez hodnoty patria do skupiny s prázdnym názvom.\n\nExample: Zoskup používateľov\n```js\nvar users = [{ name: 'Ann', role: 'dev' }, { name: 'Bob', role: 'ops' }, { name: 'Cid', role: 'dev' }, { name: 'Dan' }];\nusers.group('role').map(group => group.name + ':' + group.items.length); // [\":1\",\"dev:2\",\"ops:1\"]\n```\n\n### arr.last([def])\n\nType: `method`\n\nVráti poslednú položku poľa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | Hodnota vrátená, keď je posledná položka `undefined`. |\n\nReturns: `Object` Posledná položka alebo `def`.\n\nExample: Prečítaj poslednú položku\n```js\n[1, 2, 3].last(); // 3\n[].last('empty'); // \"empty\"\n```\n\n### arr.quicksort([sort], [direction])\n\nType: `method`\n\nZoradí pole priamo na mieste podľa jedného alebo viacerých polí.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Polia, podľa ktorých sa má zoradiť. |\n| `direction` | `String, Boolean or Number` | no |  | Ak chceš zoradiť jedno pole zostupne, použi `'desc'`, `false` alebo `2`. |\n\nReturns: `Array` To isté pole.\n\n`sort` obsahuje názvy polí oddelené čiarkami. Každý názov môže končiť na `_asc` alebo `_desc` a môže to byť vnorená path, napríklad `address.city`. Text sa porovnáva podľa miestneho nastavenia. Čísla, logické hodnoty a dátumy sa porovnávajú podľa svojho typu.\n\nBez `sort` sa samotné položky porovnávajú ako text vzostupne, takže čísla sa zoraďujú ako text.\n\nExample: Zoraď podľa polí\n```js\nvar users = [{ name: 'Bob', age: 25 }, { name: 'Ann', age: 30 }, { name: 'Cid', age: 25 }];\nvar names = () => users.map(user => user.name).join();\n\nusers.quicksort('name');\nnames(); // \"Ann,Bob,Cid\"\nusers.quicksort('name_desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('name', 'desc');\nnames(); // \"Cid,Bob,Ann\"\nusers.quicksort('age,name_desc');\nnames(); // \"Cid,Bob,Ann\"\n```\n\nExample: Zoraď hodnoty\n```js\n['b', 'c', 'a'].quicksort(); // [\"a\",\"b\",\"c\"]\n[10, 9, 100].quicksort(); // [10,100,9]\n```\n\n### arr.remove(cb, [value])\n\nType: `method`\n\nVráti nové pole bez položiek, ktoré spĺňajú podmienku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `cb` | `String, Function or Object` | yes |  | Funkcia, názov poľa alebo hodnota na odstránenie. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Array` Nové pole so zostávajúcimi položkami.\n\nPôvodné pole sa nemení. Podmienka má rovnaké tvary ako vo [findAll()](#findall).\n\nExample: Odstráň položky\n```js\nvar users = [\n\t{ id: 1, name: 'Ann', age: 30 },\n\t{ id: 2, name: 'Bob', age: 25 },\n\t{ id: 3, name: 'Cid', age: 35 }\n];\n\nusers.remove('id', 2).length; // 2\nusers.remove(user => user.age > 26).length; // 1\n['a', 'b', 'a'].remove('a'); // [\"b\"]\nusers.length; // 3\n```\n\n### arr.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 |  | Koľko položiek sa má preskočiť. |\n\nReturns: `Array` Nové pole.\n\nExample: Preskoč položky\n```js\n[1, 2, 3, 4].skip(2); // [3,4]\n```\n\n### arr.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 |  | Koľko položiek sa má vziať. |\n\nReturns: `Array` Nové pole.\n\nPočet musí byť 1 alebo viac.\n\nExample: Vezmi položky\n```js\n[1, 2, 3, 4].take(2); // [1,2]\n[1, 2].take(9); // [1,2]\n```\n\n### arr.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 |  | Koľko položiek sa má vrátiť. |\n| `skip` | `Number` | yes |  | Koľko položiek sa má preskočiť. |\n\nReturns: `Array` Nové pole.\n\nHodí sa to na čítanie jednej stránky zoznamu.\n\nExample: Prečítaj stránku\n```js\n[1, 2, 3, 4, 5].takeskip(2, 1); // [2,3]\n```\n\n### arr.trim([empty])\n\nType: `method`\n\nOreže reťazce v poli a odstráni prázdne hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `empty` | `Boolean` | no |  | Ak chceš zachovať prázdne hodnoty, použi `true`. |\n\nReturns: `Array` Nové pole.\n\nReťazce sa orežú aj v pôvodnom poli. Bez `empty` výsledok vynechá každú nepravdivú hodnotu vrátane `0` a `null`.\n\nExample: Vyčisti zoznam\n```js\n[' a ', '', ' b', 0, 1].trim(); // [\"a\",\"b\",1]\n[' a ', '', 0].trim(true); // [\"a\",\"\",0]\n```\n\n### arr.wait(onItem, [callback], [threads])\n\nType: `method`\n\nSpracuje položky jednu po druhej alebo paralelne asynchrónnou funkciou.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Spracuje jednu položku. |\n| `callback` | `Function` | no |  | Zavolá sa, keď sú všetky položky hotové. |\n| `threads` | `Number or Boolean` | no | `1` | Koľko položiek beží súčasne, alebo `true` na odstránenie spracovaných položiek. |\n\nReturns: `Array` To isté pole.\n\n`onItem` sa volá ako `function(item, next, index)` s poľom ako `this` a po dokončení položky musí zavolať `next`. `index` je pozícia položky začínajúca od 1.\n\nKeď je `threads` nastavené na `true`, položky sa počas spracovania odstraňujú z poľa a `index` je vždy `0`.\n\nExample: Spracuj položky postupne\n```js\nvar output = [];\n\n['a', 'b', 'c'].wait(function(item, next, index) {\n\toutput.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(output.join(', '));\n});\n```\n\nExample: Dve položky naraz\n```js\nvar output = [];\n\n[1, 2, 3].wait(function(item, next) {\n\toutput.push('start ' + item);\n\tsetTimeout(function() {\n\t\toutput.push('end ' + item);\n\t\tnext();\n\t}, item === 1 ? 30 : 5);\n}, function() {\n\tconsole.log(output.join(', '));\n}, 2);\n```\n\nExample: Odstráň spracované položky\n```js\nvar items = [1, 2];\n\nitems.wait(function(item, next) {\n\tnext();\n}, function() {\n\tconsole.log(items.length);\n}, true);\n```\n","entries":[{"type":"method","name":"async()","signature":"arr.async([threads], [callback])","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"arr.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"arr.findAll(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"arr.findIndex(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"arr.findItem(cb, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"arr.findValue(cb, value, path, [def])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"arr.group(name)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"arr.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"arr.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"arr.remove(cb, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"arr.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"arr.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"arr.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"arr.trim([empty])","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"arr.wait(onItem, [callback], [threads])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammXd6EM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/date/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"Date","summary":"Methods that jComponent adds to Date.prototype for formatting dates and calculating with them.","markdown":"---\ntitle: Date\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/date/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Date\n\n> Methods that jComponent adds to Date.prototype for formatting dates and calculating with them.\n\njComponent adds these methods to `Date.prototype`. Month and day names come from the global arrays `MONTHS` and `DAYS`, which the [Localization](../../guides/localization/) guide covers, and the default format is set in [DEF](../def/). Text is converted to a date with [parseDate()](../string/#parsedate).\n\n## API\n\n### date.add(type, [value])\n\nType: `method`\n\nReturns a new date moved by an amount of time.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | The unit, or the whole amount as text. |\n| `value` | `Number` | no |  | The amount of the unit. |\n\nReturns: `Date` A new date.\n\nThe original date is not changed. The amount is written as one text, such as `'2 days'`, or as a unit and a number. A negative number moves the date back.\n\n| Unit | Accepted names |\n| --- | --- |\n| Seconds | `s`, `ss`, `sec`, `second`, `seconds` |\n| Minutes | `m`, `mm`, `min`, `minute`, `minutes` |\n| Hours | `h`, `hh`, `hour`, `hours` |\n| Days | `d`, `dd`, `day`, `days` |\n| Weeks | `w`, `ww`, `week`, `weeks` |\n| Months | `M`, `MM`, `month`, `months` |\n| Years | `y`, `yy`, `yyyy`, `year`, `years` |\n\nExample: Move a date\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\nvar f = 'yyyy-MM-dd HH:mm:ss';\n\ndate.add('1 day').format(f); // \"2026-11-19 14:05:09\"\ndate.add('-1 day').format(f); // \"2026-11-17 14:05:09\"\ndate.add('2 hours').format(f); // \"2026-11-18 16:05:09\"\ndate.add('min', 30).format(f); // \"2026-11-18 14:35:09\"\ndate.add('M', 2).format(f); // \"2027-01-18 14:05:09\"\ndate.add('2 weeks').format(f); // \"2026-12-02 14:05:09\"\ndate.format(f); // \"2026-11-18 14:05:09\"\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 format of the output. |\n| `utc` | `Boolean` | no |  | Writes the date in UTC. |\n\nReturns: `String` The formatted date.\n\nWithout `format`, the method uses `DEF.dateformat`, which is `yyyy-MM-dd` by default. A format in the form `[key]` is read from `ENV()`. With `utc`, or when `DEF.dateformatutc` is `true`, the date is written in UTC. Use `date.format('iso', true)` for an ISO 8601 text.\n\n| Token | Output for 18 November 2026, 14:05:09 |\n| --- | --- |\n| `yyyy`, `YYYY` | `2026` |\n| `yy`, `YY` | `26` |\n| `MMMM` | `November` |\n| `MMM` | `Nov` |\n| `MM` | `11` |\n| `M` | `11` |\n| `dddd`, `DDDD` | `Wednesday` |\n| `ddd`, `DDD` | `WE` |\n| `dd`, `DD` | `18` |\n| `d`, `D` | `18` |\n| `HH`, `hh` | `14` |\n| `H`, `h` | `14` |\n| `mm` | `05` |\n| `m` | `5` |\n| `ss` | `09` |\n| `s` | `9` |\n| `ww` | `47` (ISO week, two digits) |\n| `w` | `47` (ISO week) |\n| `a` | `PM` |\n\nEvery token letter is replaced wherever it appears, and a format cannot contain an apostrophe, so write literal words outside the format.\n\nExample: Date formats\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\n\ndate.format(); // \"2026-11-18\"\ndate.format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\ndate.format('dddd, d MMMM yyyy'); // \"Wednesday, 18 November 2026\"\ndate.format('MMM yy'); // \"Nov 26\"\ndate.format('HH:mm a'); // \"14:05 PM\"\ndate.format('yyyy-ww'); // \"2026-47\"\n```\n\nExample: UTC output\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5, 9, 7));\n\ndate.format('HH:mm', true); // \"13:05\"\ndate.format('iso', true); // \"2026-11-18T13:05:09.007Z\"\n```\n\nExample: Default format\n```js\nvar date = new Date(2026, 10, 18);\n\nDEF.dateformat = 'dd/MM/yyyy';\ndate.format(); // \"18/11/2026\"\nDEF.dateformat = 'yyyy-MM-dd';\n\nENV('short', 'dd.MM.');\ndate.format('[short]'); // \"18.11.\"\n```\n\n### date.parseDate()\n\nType: `method`\n\nReturns the same date.\n\nReturns: `Date` The same date object.\n\nStrings, numbers and dates all have a `parseDate()` method, so a value of any of these types can be converted without checking its type.\n\nExample: Convert any value\n```js\nvar date = new Date(2026, 10, 18);\ndate.parseDate() === date; // true\n```\n\n### date.toNumber([format])\n\nType: `method`\n\nWrites the date as a number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `'yyyyMMdd'` | A [format()](#format) layout that contains only digits. |\n\nReturns: `Number` The date as a number.\n\nThe number is useful for comparing dates.\n\nExample: Date as a number\n```js\nvar date = new Date(2026, 10, 18, 14, 5);\n\ndate.toNumber(); // 20261118\ndate.toNumber('yyyyMM'); // 202611\ndate.toNumber('yyyyMMddHHmm'); // 202611181405\n```\n\n### date.toUTC([ticks])\n\nType: `method`\n\nShifts the date by the time zone offset, so its local fields show the UTC time.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no |  | Use `true` to get the milliseconds in place of a `Date`. |\n\nReturns: `Date or Number` The shifted date, or its milliseconds.\n\nExample: Shift to UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5));\n\ndate.toUTC().getHours(); // 13\ndate.toUTC(true) === date.getTime() + date.getTimezoneOffset() * 60000; // true\n```\n","entries":[{"type":"method","name":"add()","signature":"date.add(type, [value])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"date.parseDate()","since":"","deprecated":false},{"type":"method","name":"toNumber()","signature":"date.toNumber([format])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammXd6EM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/date/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"Date","summary":"Methoden, die jComponent zu Date.prototype hinzufügt, um Datumswerte zu formatieren und mit ihnen zu rechnen.","markdown":"---\ntitle: Date\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/date/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Date\n\n> Methoden, die jComponent zu Date.prototype hinzufügt, um Datumswerte zu formatieren und mit ihnen zu rechnen.\n\njComponent fügt diese Methoden zu `Date.prototype` hinzu. Monats- und Tagesnamen stammen aus den globalen Arrays `MONTHS` und `DAYS`, die der Guide [Lokalisierung](../../guides/localization/) behandelt, und das Standardformat wird in [DEF](../def/) festgelegt. Text wird mit [parseDate()](../string/#parsedate) in ein Datum umgewandelt.\n\n## API\n\n### date.add(type, [value])\n\nType: `method`\n\nGibt ein neues, um eine Zeitspanne verschobenes Datum zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Die Einheit oder die gesamte Zeitspanne als Text. |\n| `value` | `Number` | no |  | Die Menge der Einheit. |\n\nReturns: `Date` Ein neues Datum.\n\nDas ursprüngliche Datum wird nicht verändert. Die Zeitspanne wird als ein Text wie `'2 days'` oder als Einheit und Zahl angegeben. Eine negative Zahl verschiebt das Datum zurück.\n\n| Einheit | Akzeptierte Namen |\n| --- | --- |\n| Sekunden | `s`, `ss`, `sec`, `second`, `seconds` |\n| Minuten | `m`, `mm`, `min`, `minute`, `minutes` |\n| Stunden | `h`, `hh`, `hour`, `hours` |\n| Tage | `d`, `dd`, `day`, `days` |\n| Wochen | `w`, `ww`, `week`, `weeks` |\n| Monate | `M`, `MM`, `month`, `months` |\n| Jahre | `y`, `yy`, `yyyy`, `year`, `years` |\n\nExample: Ein Datum verschieben\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\nvar f = 'yyyy-MM-dd HH:mm:ss';\n\ndate.add('1 day').format(f); // \"2026-11-19 14:05:09\"\ndate.add('-1 day').format(f); // \"2026-11-17 14:05:09\"\ndate.add('2 hours').format(f); // \"2026-11-18 16:05:09\"\ndate.add('min', 30).format(f); // \"2026-11-18 14:35:09\"\ndate.add('M', 2).format(f); // \"2027-01-18 14:05:09\"\ndate.add('2 weeks').format(f); // \"2026-12-02 14:05:09\"\ndate.format(f); // \"2026-11-18 14:05:09\"\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 Format der Ausgabe. |\n| `utc` | `Boolean` | no |  | Schreibt das Datum in UTC. |\n\nReturns: `String` Das formatierte Datum.\n\nOhne `format` verwendet die Methode `DEF.dateformat`, standardmäßig `yyyy-MM-dd`. Ein Format in der Form `[key]` wird aus `ENV()` gelesen. Mit `utc` oder wenn `DEF.dateformatutc` den Wert `true` hat, wird das Datum in UTC geschrieben. Verwende `date.format('iso', true)` für einen Text nach ISO 8601.\n\n| Token | Ausgabe für den 18. November 2026, 14:05:09 |\n| --- | --- |\n| `yyyy`, `YYYY` | `2026` |\n| `yy`, `YY` | `26` |\n| `MMMM` | `November` |\n| `MMM` | `Nov` |\n| `MM` | `11` |\n| `M` | `11` |\n| `dddd`, `DDDD` | `Wednesday` |\n| `ddd`, `DDD` | `WE` |\n| `dd`, `DD` | `18` |\n| `d`, `D` | `18` |\n| `HH`, `hh` | `14` |\n| `H`, `h` | `14` |\n| `mm` | `05` |\n| `m` | `5` |\n| `ss` | `09` |\n| `s` | `9` |\n| `ww` | `47` (ISO-Woche, zweistellig) |\n| `w` | `47` (ISO-Woche) |\n| `a` | `PM` |\n\nJeder Token-Buchstabe wird überall ersetzt, wo er vorkommt, und ein Format darf keinen Apostroph enthalten. Schreibe wörtliche Begriffe daher außerhalb des Formats.\n\nExample: Datumsformate\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\n\ndate.format(); // \"2026-11-18\"\ndate.format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\ndate.format('dddd, d MMMM yyyy'); // \"Wednesday, 18 November 2026\"\ndate.format('MMM yy'); // \"Nov 26\"\ndate.format('HH:mm a'); // \"14:05 PM\"\ndate.format('yyyy-ww'); // \"2026-47\"\n```\n\nExample: Ausgabe in UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5, 9, 7));\n\ndate.format('HH:mm', true); // \"13:05\"\ndate.format('iso', true); // \"2026-11-18T13:05:09.007Z\"\n```\n\nExample: Standardformat\n```js\nvar date = new Date(2026, 10, 18);\n\nDEF.dateformat = 'dd/MM/yyyy';\ndate.format(); // \"18/11/2026\"\nDEF.dateformat = 'yyyy-MM-dd';\n\nENV('short', 'dd.MM.');\ndate.format('[short]'); // \"18.11.\"\n```\n\n### date.parseDate()\n\nType: `method`\n\nGibt dasselbe Datum zurück.\n\nReturns: `Date` Dasselbe Datumsobjekt.\n\nStrings, Zahlen und Datumswerte haben alle eine Methode `parseDate()`, sodass sich ein Wert jedes dieser Typen umwandeln lässt, ohne seinen Typ zu prüfen.\n\nExample: Einen beliebigen Wert umwandeln\n```js\nvar date = new Date(2026, 10, 18);\ndate.parseDate() === date; // true\n```\n\n### date.toNumber([format])\n\nType: `method`\n\nSchreibt das Datum als Zahl.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `'yyyyMMdd'` | Ein [format()](#format)-Layout, das nur Ziffern enthält. |\n\nReturns: `Number` Das Datum als Zahl.\n\nDie Zahl ist nützlich, um Datumswerte zu vergleichen.\n\nExample: Datum als Zahl\n```js\nvar date = new Date(2026, 10, 18, 14, 5);\n\ndate.toNumber(); // 20261118\ndate.toNumber('yyyyMM'); // 202611\ndate.toNumber('yyyyMMddHHmm'); // 202611181405\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 |  | Verwende `true`, um statt eines `Date` die Millisekunden zu erhalten. |\n\nReturns: `Date or Number` Das verschobene Datum oder seine Millisekunden.\n\nExample: Nach UTC verschieben\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5));\n\ndate.toUTC().getHours(); // 13\ndate.toUTC(true) === date.getTime() + date.getTimezoneOffset() * 60000; // true\n```\n","entries":[{"type":"method","name":"add()","signature":"date.add(type, [value])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"date.parseDate()","since":"","deprecated":false},{"type":"method","name":"toNumber()","signature":"date.toNumber([format])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammXd6EM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/date/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Date","summary":"Métodos que jComponent añade a Date.prototype para dar formato a fechas y calcular con ellas.","markdown":"---\ntitle: Date\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/date/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Date\n\n> Métodos que jComponent añade a Date.prototype para dar formato a fechas y calcular con ellas.\n\njComponent añade estos métodos a `Date.prototype`. Los nombres de los meses y los días vienen de los arrays globales `MONTHS` y `DAYS`, de los que trata la guía [Localización](../../guides/localization/), y el formato predeterminado se define en [DEF](../def/). El texto se convierte en fecha con [parseDate()](../string/#parsedate).\n\n## API\n\n### date.add(type, [value])\n\nType: `method`\n\nDevuelve una fecha nueva desplazada una cantidad de tiempo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | La unidad, o la cantidad completa como texto. |\n| `value` | `Number` | no |  | La cantidad de la unidad. |\n\nReturns: `Date` Una fecha nueva.\n\nLa fecha original no cambia. La cantidad se escribe como un solo texto, como `'2 days'`, o como una unidad y un número. Un número negativo mueve la fecha hacia atrás.\n\n| Unidad | Nombres admitidos |\n| --- | --- |\n| Segundos | `s`, `ss`, `sec`, `second`, `seconds` |\n| Minutos | `m`, `mm`, `min`, `minute`, `minutes` |\n| Horas | `h`, `hh`, `hour`, `hours` |\n| Días | `d`, `dd`, `day`, `days` |\n| Semanas | `w`, `ww`, `week`, `weeks` |\n| Meses | `M`, `MM`, `month`, `months` |\n| Años | `y`, `yy`, `yyyy`, `year`, `years` |\n\nExample: Mover una fecha\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\nvar f = 'yyyy-MM-dd HH:mm:ss';\n\ndate.add('1 day').format(f); // \"2026-11-19 14:05:09\"\ndate.add('-1 day').format(f); // \"2026-11-17 14:05:09\"\ndate.add('2 hours').format(f); // \"2026-11-18 16:05:09\"\ndate.add('min', 30).format(f); // \"2026-11-18 14:35:09\"\ndate.add('M', 2).format(f); // \"2027-01-18 14:05:09\"\ndate.add('2 weeks').format(f); // \"2026-12-02 14:05:09\"\ndate.format(f); // \"2026-11-18 14:05:09\"\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 formato de la salida. |\n| `utc` | `Boolean` | no |  | Escribe la fecha en UTC. |\n\nReturns: `String` La fecha con formato.\n\nSin `format`, el método usa `DEF.dateformat`, que de forma predeterminada es `yyyy-MM-dd`. Un formato con la forma `[key]` se lee de `ENV()`. Con `utc`, o cuando `DEF.dateformatutc` es `true`, la fecha se escribe en UTC. Usa `date.format('iso', true)` para obtener un texto ISO 8601.\n\n| Token | Salida para el 18 de noviembre de 2026, 14:05:09 |\n| --- | --- |\n| `yyyy`, `YYYY` | `2026` |\n| `yy`, `YY` | `26` |\n| `MMMM` | `November` |\n| `MMM` | `Nov` |\n| `MM` | `11` |\n| `M` | `11` |\n| `dddd`, `DDDD` | `Wednesday` |\n| `ddd`, `DDD` | `WE` |\n| `dd`, `DD` | `18` |\n| `d`, `D` | `18` |\n| `HH`, `hh` | `14` |\n| `H`, `h` | `14` |\n| `mm` | `05` |\n| `m` | `5` |\n| `ss` | `09` |\n| `s` | `9` |\n| `ww` | `47` (semana ISO, dos dígitos) |\n| `w` | `47` (semana ISO) |\n| `a` | `PM` |\n\nCada letra de token se sustituye dondequiera que aparezca y un formato no puede contener un apóstrofo, así que escribe las palabras literales fuera del formato.\n\nExample: Formatos de fecha\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\n\ndate.format(); // \"2026-11-18\"\ndate.format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\ndate.format('dddd, d MMMM yyyy'); // \"Wednesday, 18 November 2026\"\ndate.format('MMM yy'); // \"Nov 26\"\ndate.format('HH:mm a'); // \"14:05 PM\"\ndate.format('yyyy-ww'); // \"2026-47\"\n```\n\nExample: Salida en UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5, 9, 7));\n\ndate.format('HH:mm', true); // \"13:05\"\ndate.format('iso', true); // \"2026-11-18T13:05:09.007Z\"\n```\n\nExample: Formato predeterminado\n```js\nvar date = new Date(2026, 10, 18);\n\nDEF.dateformat = 'dd/MM/yyyy';\ndate.format(); // \"18/11/2026\"\nDEF.dateformat = 'yyyy-MM-dd';\n\nENV('short', 'dd.MM.');\ndate.format('[short]'); // \"18.11.\"\n```\n\n### date.parseDate()\n\nType: `method`\n\nDevuelve la misma fecha.\n\nReturns: `Date` El mismo objeto de fecha.\n\nLas cadenas, los números y las fechas tienen todos un método `parseDate()`, así que puedes convertir un valor de cualquiera de estos tipos sin comprobar su tipo.\n\nExample: Convertir cualquier valor\n```js\nvar date = new Date(2026, 10, 18);\ndate.parseDate() === date; // true\n```\n\n### date.toNumber([format])\n\nType: `method`\n\nEscribe la fecha como número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `'yyyyMMdd'` | Un formato de [format()](#format) que contiene solo dígitos. |\n\nReturns: `Number` La fecha como número.\n\nEl número resulta útil para comparar fechas.\n\nExample: Fecha como número\n```js\nvar date = new Date(2026, 10, 18, 14, 5);\n\ndate.toNumber(); // 20261118\ndate.toNumber('yyyyMM'); // 202611\ndate.toNumber('yyyyMMddHHmm'); // 202611181405\n```\n\n### date.toUTC([ticks])\n\nType: `method`\n\nDesplaza la fecha según el desfase de la zona horaria, de modo que sus campos locales muestran la hora UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no |  | Usa `true` para obtener los milisegundos en lugar de un `Date`. |\n\nReturns: `Date or Number` La fecha desplazada o sus milisegundos.\n\nExample: Desplazar a UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5));\n\ndate.toUTC().getHours(); // 13\ndate.toUTC(true) === date.getTime() + date.getTimezoneOffset() * 60000; // true\n```\n","entries":[{"type":"method","name":"add()","signature":"date.add(type, [value])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"date.parseDate()","since":"","deprecated":false},{"type":"method","name":"toNumber()","signature":"date.toNumber([format])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammXd6EM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/date/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Date","summary":"Les méthodes que jComponent ajoute à Date.prototype pour formater des dates et effectuer des calculs avec elles.","markdown":"---\ntitle: Date\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/date/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Date\n\n> Les méthodes que jComponent ajoute à Date.prototype pour formater des dates et effectuer des calculs avec elles.\n\njComponent ajoute ces méthodes à `Date.prototype`. Les noms des mois et des jours proviennent des tableaux globaux `MONTHS` et `DAYS`, traités dans le guide [Localisation](../../guides/localization/), et le format par défaut est défini dans [DEF](../def/). Le texte est converti en date avec [parseDate()](../string/#parsedate).\n\n## API\n\n### date.add(type, [value])\n\nType: `method`\n\nRenvoie une nouvelle date décalée d'une certaine durée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | L'unité, ou la durée complète sous forme de texte. |\n| `value` | `Number` | no |  | La quantité de l'unité. |\n\nReturns: `Date` Une nouvelle date.\n\nLa date d'origine n'est pas modifiée. La durée s'écrit sous forme d'un seul texte, comme `'2 days'`, ou d'une unité et d'un nombre. Un nombre négatif recule la date.\n\n| Unité | Noms acceptés |\n| --- | --- |\n| Secondes | `s`, `ss`, `sec`, `second`, `seconds` |\n| Minutes | `m`, `mm`, `min`, `minute`, `minutes` |\n| Heures | `h`, `hh`, `hour`, `hours` |\n| Jours | `d`, `dd`, `day`, `days` |\n| Semaines | `w`, `ww`, `week`, `weeks` |\n| Mois | `M`, `MM`, `month`, `months` |\n| Années | `y`, `yy`, `yyyy`, `year`, `years` |\n\nExample: Décaler une date\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\nvar f = 'yyyy-MM-dd HH:mm:ss';\n\ndate.add('1 day').format(f); // \"2026-11-19 14:05:09\"\ndate.add('-1 day').format(f); // \"2026-11-17 14:05:09\"\ndate.add('2 hours').format(f); // \"2026-11-18 16:05:09\"\ndate.add('min', 30).format(f); // \"2026-11-18 14:35:09\"\ndate.add('M', 2).format(f); // \"2027-01-18 14:05:09\"\ndate.add('2 weeks').format(f); // \"2026-12-02 14:05:09\"\ndate.format(f); // \"2026-11-18 14:05:09\"\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` | Le format de la sortie. |\n| `utc` | `Boolean` | no |  | Écrit la date en UTC. |\n\nReturns: `String` La date formatée.\n\nSans `format`, la méthode utilise `DEF.dateformat`, qui vaut `yyyy-MM-dd` par défaut. Un format de la forme `[key]` est lu depuis `ENV()`. Avec `utc`, ou quand `DEF.dateformatutc` vaut `true`, la date est écrite en UTC. Utilise `date.format('iso', true)` pour obtenir un texte ISO 8601.\n\n| Jeton | Sortie pour le 18 novembre 2026, 14:05:09 |\n| --- | --- |\n| `yyyy`, `YYYY` | `2026` |\n| `yy`, `YY` | `26` |\n| `MMMM` | `November` |\n| `MMM` | `Nov` |\n| `MM` | `11` |\n| `M` | `11` |\n| `dddd`, `DDDD` | `Wednesday` |\n| `ddd`, `DDD` | `WE` |\n| `dd`, `DD` | `18` |\n| `d`, `D` | `18` |\n| `HH`, `hh` | `14` |\n| `H`, `h` | `14` |\n| `mm` | `05` |\n| `m` | `5` |\n| `ss` | `09` |\n| `s` | `9` |\n| `ww` | `47` (semaine ISO, deux chiffres) |\n| `w` | `47` (semaine ISO) |\n| `a` | `PM` |\n\nChaque lettre de jeton est remplacée partout où elle apparaît, et un format ne peut pas contenir d'apostrophe : écris donc les mots littéraux en dehors du format.\n\nExample: Formats de date\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\n\ndate.format(); // \"2026-11-18\"\ndate.format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\ndate.format('dddd, d MMMM yyyy'); // \"Wednesday, 18 November 2026\"\ndate.format('MMM yy'); // \"Nov 26\"\ndate.format('HH:mm a'); // \"14:05 PM\"\ndate.format('yyyy-ww'); // \"2026-47\"\n```\n\nExample: Sortie en UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5, 9, 7));\n\ndate.format('HH:mm', true); // \"13:05\"\ndate.format('iso', true); // \"2026-11-18T13:05:09.007Z\"\n```\n\nExample: Format par défaut\n```js\nvar date = new Date(2026, 10, 18);\n\nDEF.dateformat = 'dd/MM/yyyy';\ndate.format(); // \"18/11/2026\"\nDEF.dateformat = 'yyyy-MM-dd';\n\nENV('short', 'dd.MM.');\ndate.format('[short]'); // \"18.11.\"\n```\n\n### date.parseDate()\n\nType: `method`\n\nRenvoie la même date.\n\nReturns: `Date` Le même objet date.\n\nLes chaînes, les nombres et les dates ont tous une méthode `parseDate()`, tu peux donc convertir une valeur de n'importe lequel de ces types sans vérifier son type.\n\nExample: Convertir n'importe quelle valeur\n```js\nvar date = new Date(2026, 10, 18);\ndate.parseDate() === date; // true\n```\n\n### date.toNumber([format])\n\nType: `method`\n\nÉcrit la date sous forme de nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `'yyyyMMdd'` | Une disposition de [format()](#format) qui ne contient que des chiffres. |\n\nReturns: `Number` La date sous forme de nombre.\n\nCe nombre est utile pour comparer des dates.\n\nExample: Date sous forme de nombre\n```js\nvar date = new Date(2026, 10, 18, 14, 5);\n\ndate.toNumber(); // 20261118\ndate.toNumber('yyyyMM'); // 202611\ndate.toNumber('yyyyMMddHHmm'); // 202611181405\n```\n\n### date.toUTC([ticks])\n\nType: `method`\n\nDécale la date du fuseau horaire, de sorte que ses champs locaux affichent l'heure UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no |  | Utilise `true` pour obtenir les millisecondes au lieu d'une `Date`. |\n\nReturns: `Date or Number` La date décalée, ou ses millisecondes.\n\nExample: Décaler vers UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5));\n\ndate.toUTC().getHours(); // 13\ndate.toUTC(true) === date.getTime() + date.getTimezoneOffset() * 60000; // true\n```\n","entries":[{"type":"method","name":"add()","signature":"date.add(type, [value])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"date.parseDate()","since":"","deprecated":false},{"type":"method","name":"toNumber()","signature":"date.toNumber([format])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammXd6EM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/date/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Date","summary":"Metodi che jComponent aggiunge a Date.prototype per formattare le date e fare calcoli con esse.","markdown":"---\ntitle: Date\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/date/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Date\n\n> Metodi che jComponent aggiunge a Date.prototype per formattare le date e fare calcoli con esse.\n\njComponent aggiunge questi metodi a `Date.prototype`. I nomi di mesi e giorni provengono dagli array globali `MONTHS` e `DAYS`, trattati nella guida [Localizzazione](../../guides/localization/), e il formato predefinito si imposta in [DEF](../def/). Il testo viene convertito in data con [parseDate()](../string/#parsedate).\n\n## API\n\n### date.add(type, [value])\n\nType: `method`\n\nRestituisce una nuova data spostata di una certa quantità di tempo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | L'unità, oppure l'intera quantità come testo. |\n| `value` | `Number` | no |  | La quantità dell'unità. |\n\nReturns: `Date` Una nuova data.\n\nLa data originale non viene modificata. La quantità si scrive come un unico testo, ad esempio `'2 days'`, oppure come unità e numero. Un numero negativo sposta la data indietro.\n\n| Unità | Nomi accettati |\n| --- | --- |\n| Secondi | `s`, `ss`, `sec`, `second`, `seconds` |\n| Minuti | `m`, `mm`, `min`, `minute`, `minutes` |\n| Ore | `h`, `hh`, `hour`, `hours` |\n| Giorni | `d`, `dd`, `day`, `days` |\n| Settimane | `w`, `ww`, `week`, `weeks` |\n| Mesi | `M`, `MM`, `month`, `months` |\n| Anni | `y`, `yy`, `yyyy`, `year`, `years` |\n\nExample: Sposta una data\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\nvar f = 'yyyy-MM-dd HH:mm:ss';\n\ndate.add('1 day').format(f); // \"2026-11-19 14:05:09\"\ndate.add('-1 day').format(f); // \"2026-11-17 14:05:09\"\ndate.add('2 hours').format(f); // \"2026-11-18 16:05:09\"\ndate.add('min', 30).format(f); // \"2026-11-18 14:35:09\"\ndate.add('M', 2).format(f); // \"2027-01-18 14:05:09\"\ndate.add('2 weeks').format(f); // \"2026-12-02 14:05:09\"\ndate.format(f); // \"2026-11-18 14:05:09\"\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 formato dell'output. |\n| `utc` | `Boolean` | no |  | Scrive la data in UTC. |\n\nReturns: `String` La data formattata.\n\nSenza `format`, il metodo usa `DEF.dateformat`, che per impostazione predefinita è `yyyy-MM-dd`. Un formato nella forma `[key]` viene letto da `ENV()`. Con `utc`, oppure quando `DEF.dateformatutc` è `true`, la data viene scritta in UTC. Usa `date.format('iso', true)` per ottenere un testo ISO 8601.\n\n| Token | Output per il 18 novembre 2026, 14:05:09 |\n| --- | --- |\n| `yyyy`, `YYYY` | `2026` |\n| `yy`, `YY` | `26` |\n| `MMMM` | `November` |\n| `MMM` | `Nov` |\n| `MM` | `11` |\n| `M` | `11` |\n| `dddd`, `DDDD` | `Wednesday` |\n| `ddd`, `DDD` | `WE` |\n| `dd`, `DD` | `18` |\n| `d`, `D` | `18` |\n| `HH`, `hh` | `14` |\n| `H`, `h` | `14` |\n| `mm` | `05` |\n| `m` | `5` |\n| `ss` | `09` |\n| `s` | `9` |\n| `ww` | `47` (settimana ISO, due cifre) |\n| `w` | `47` (settimana ISO) |\n| `a` | `PM` |\n\nOgni lettera di un token viene sostituita ovunque compaia e un formato non può contenere un apostrofo, quindi scrivi le parole letterali fuori dal formato.\n\nExample: Formati di data\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\n\ndate.format(); // \"2026-11-18\"\ndate.format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\ndate.format('dddd, d MMMM yyyy'); // \"Wednesday, 18 November 2026\"\ndate.format('MMM yy'); // \"Nov 26\"\ndate.format('HH:mm a'); // \"14:05 PM\"\ndate.format('yyyy-ww'); // \"2026-47\"\n```\n\nExample: Output in UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5, 9, 7));\n\ndate.format('HH:mm', true); // \"13:05\"\ndate.format('iso', true); // \"2026-11-18T13:05:09.007Z\"\n```\n\nExample: Formato predefinito\n```js\nvar date = new Date(2026, 10, 18);\n\nDEF.dateformat = 'dd/MM/yyyy';\ndate.format(); // \"18/11/2026\"\nDEF.dateformat = 'yyyy-MM-dd';\n\nENV('short', 'dd.MM.');\ndate.format('[short]'); // \"18.11.\"\n```\n\n### date.parseDate()\n\nType: `method`\n\nRestituisce la stessa data.\n\nReturns: `Date` Lo stesso oggetto data.\n\nStringhe, numeri e date hanno tutti un metodo `parseDate()`, quindi puoi convertire un valore di uno qualsiasi di questi tipi senza controllarne il tipo.\n\nExample: Converti un valore qualsiasi\n```js\nvar date = new Date(2026, 10, 18);\ndate.parseDate() === date; // true\n```\n\n### date.toNumber([format])\n\nType: `method`\n\nScrive la data come numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `'yyyyMMdd'` | Un layout di [format()](#format) che contiene solo cifre. |\n\nReturns: `Number` La data come numero.\n\nIl numero è utile per confrontare le date.\n\nExample: Data come numero\n```js\nvar date = new Date(2026, 10, 18, 14, 5);\n\ndate.toNumber(); // 20261118\ndate.toNumber('yyyyMM'); // 202611\ndate.toNumber('yyyyMMddHHmm'); // 202611181405\n```\n\n### date.toUTC([ticks])\n\nType: `method`\n\nSposta la data del valore del fuso orario, così i suoi campi locali mostrano l'ora UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no |  | Usa `true` per ottenere i millisecondi al posto di un `Date`. |\n\nReturns: `Date or Number` La data spostata o i relativi millisecondi.\n\nExample: Sposta in UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5));\n\ndate.toUTC().getHours(); // 13\ndate.toUTC(true) === date.getTime() + date.getTimezoneOffset() * 60000; // true\n```\n","entries":[{"type":"method","name":"add()","signature":"date.add(type, [value])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"date.parseDate()","since":"","deprecated":false},{"type":"method","name":"toNumber()","signature":"date.toNumber([format])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammXd6EM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/date/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Date","summary":"Metódy, ktoré jComponent pridáva do Date.prototype na formátovanie dátumov a počítanie s nimi.","markdown":"---\ntitle: Date\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/date/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Date\n\n> Metódy, ktoré jComponent pridáva do Date.prototype na formátovanie dátumov a počítanie s nimi.\n\njComponent pridáva tieto metódy do `Date.prototype`. Názvy mesiacov a dní pochádzajú z globálnych polí `MONTHS` a `DAYS`, ktorým sa venuje príručka [Lokalizácia](../../guides/localization/), a predvolený formát sa nastavuje v [DEF](../def/). Text sa na dátum prevádza pomocou [parseDate()](../string/#parsedate).\n\n## API\n\n### date.add(type, [value])\n\nType: `method`\n\nVráti nový dátum posunutý o zadaný čas.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Jednotka alebo celé množstvo ako text. |\n| `value` | `Number` | no |  | Množstvo jednotky. |\n\nReturns: `Date` Nový dátum.\n\nPôvodný dátum sa nemení. Množstvo sa zapisuje ako jeden text, napríklad `'2 days'`, alebo ako jednotka a číslo. Záporné číslo posunie dátum späť.\n\n| Jednotka | Akceptované názvy |\n| --- | --- |\n| Sekundy | `s`, `ss`, `sec`, `second`, `seconds` |\n| Minúty | `m`, `mm`, `min`, `minute`, `minutes` |\n| Hodiny | `h`, `hh`, `hour`, `hours` |\n| Dni | `d`, `dd`, `day`, `days` |\n| Týždne | `w`, `ww`, `week`, `weeks` |\n| Mesiace | `M`, `MM`, `month`, `months` |\n| Roky | `y`, `yy`, `yyyy`, `year`, `years` |\n\nExample: Posuň dátum\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\nvar f = 'yyyy-MM-dd HH:mm:ss';\n\ndate.add('1 day').format(f); // \"2026-11-19 14:05:09\"\ndate.add('-1 day').format(f); // \"2026-11-17 14:05:09\"\ndate.add('2 hours').format(f); // \"2026-11-18 16:05:09\"\ndate.add('min', 30).format(f); // \"2026-11-18 14:35:09\"\ndate.add('M', 2).format(f); // \"2027-01-18 14:05:09\"\ndate.add('2 weeks').format(f); // \"2026-12-02 14:05:09\"\ndate.format(f); // \"2026-11-18 14:05:09\"\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` | Formát výstupu. |\n| `utc` | `Boolean` | no |  | Zapíše dátum v UTC. |\n\nReturns: `String` Naformátovaný dátum.\n\nBez `format` metóda použije `DEF.dateformat`, čo je predvolene `yyyy-MM-dd`. Formát v tvare `[key]` sa prečíta z `ENV()`. S `utc`, alebo keď je `DEF.dateformatutc` nastavené na `true`, sa dátum zapíše v UTC. Pre text ISO 8601 použi `date.format('iso', true)`.\n\n| Token | Výstup pre 18. november 2026, 14:05:09 |\n| --- | --- |\n| `yyyy`, `YYYY` | `2026` |\n| `yy`, `YY` | `26` |\n| `MMMM` | `November` |\n| `MMM` | `Nov` |\n| `MM` | `11` |\n| `M` | `11` |\n| `dddd`, `DDDD` | `Wednesday` |\n| `ddd`, `DDD` | `WE` |\n| `dd`, `DD` | `18` |\n| `d`, `D` | `18` |\n| `HH`, `hh` | `14` |\n| `H`, `h` | `14` |\n| `mm` | `05` |\n| `m` | `5` |\n| `ss` | `09` |\n| `s` | `9` |\n| `ww` | `47` (týždeň ISO, dve číslice) |\n| `w` | `47` (týždeň ISO) |\n| `a` | `PM` |\n\nKaždé písmeno tokenu sa nahradí všade, kde sa vyskytne, a formát nemôže obsahovať apostrof, preto doslovné slová píš mimo formátu.\n\nExample: Formáty dátumu\n```js\nvar date = new Date(2026, 10, 18, 14, 5, 9);\n\ndate.format(); // \"2026-11-18\"\ndate.format('dd.MM.yyyy HH:mm:ss'); // \"18.11.2026 14:05:09\"\ndate.format('dddd, d MMMM yyyy'); // \"Wednesday, 18 November 2026\"\ndate.format('MMM yy'); // \"Nov 26\"\ndate.format('HH:mm a'); // \"14:05 PM\"\ndate.format('yyyy-ww'); // \"2026-47\"\n```\n\nExample: Výstup v UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5, 9, 7));\n\ndate.format('HH:mm', true); // \"13:05\"\ndate.format('iso', true); // \"2026-11-18T13:05:09.007Z\"\n```\n\nExample: Predvolený formát\n```js\nvar date = new Date(2026, 10, 18);\n\nDEF.dateformat = 'dd/MM/yyyy';\ndate.format(); // \"18/11/2026\"\nDEF.dateformat = 'yyyy-MM-dd';\n\nENV('short', 'dd.MM.');\ndate.format('[short]'); // \"18.11.\"\n```\n\n### date.parseDate()\n\nType: `method`\n\nVráti ten istý dátum.\n\nReturns: `Date` Ten istý objekt dátumu.\n\nReťazce, čísla aj dátumy majú metódu `parseDate()`, takže hodnotu ktoréhokoľvek z týchto typov môžeš previesť bez kontroly jej typu.\n\nExample: Preveď ľubovoľnú hodnotu\n```js\nvar date = new Date(2026, 10, 18);\ndate.parseDate() === date; // true\n```\n\n### date.toNumber([format])\n\nType: `method`\n\nZapíše dátum ako číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `'yyyyMMdd'` | Rozloženie pre [format()](#format), ktoré obsahuje iba číslice. |\n\nReturns: `Number` Dátum ako číslo.\n\nČíslo sa hodí na porovnávanie dátumov.\n\nExample: Dátum ako číslo\n```js\nvar date = new Date(2026, 10, 18, 14, 5);\n\ndate.toNumber(); // 20261118\ndate.toNumber('yyyyMM'); // 202611\ndate.toNumber('yyyyMMddHHmm'); // 202611181405\n```\n\n### date.toUTC([ticks])\n\nType: `method`\n\nPosunie dátum o odchýlku časového pásma, takže jeho lokálne polia zobrazujú čas UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no |  | Ak chceš namiesto `Date` získať milisekundy, použi `true`. |\n\nReturns: `Date or Number` Posunutý dátum alebo jeho milisekundy.\n\nExample: Posuň na UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 18, 13, 5));\n\ndate.toUTC().getHours(); // 13\ndate.toUTC(true) === date.getTime() + date.getTimezoneOffset() * 60000; // true\n```\n","entries":[{"type":"method","name":"add()","signature":"date.add(type, [value])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"date.parseDate()","since":"","deprecated":false},{"type":"method","name":"toNumber()","signature":"date.toNumber([format])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammeB4wj61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/reference/jquery/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"en","title":"jQuery extensions","summary":"Methods that jComponent adds to jQuery for working with classes, attributes, SVG, components and scopes.","markdown":"---\ntitle: jQuery extensions\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/reference/jquery/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# jQuery extensions\n\n> Methods that jComponent adds to jQuery for working with classes, attributes, SVG, components and scopes.\n\njComponent includes jQuery and adds these methods to `$.fn`, so they work on every jQuery object. The [Component](../component/) page describes the objects returned by the component methods, and [Using components](../../guides/using-components/) explains how components are declared.\n\n## API\n\n### el.aclass(name, [delay])\n\nType: `method`\n\nAdds one or more classes, immediately or after a delay.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class names, separated by spaces. |\n| `delay` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `jQuery` The same element.\n\nDelayed calls share one timer per element, so a new delayed `aclass()`, `rclass()` or `rclass2()` call cancels the one still waiting.\n\nExample: Add a class\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\nel.aclass('active');\nel.hclass('active'); // true\n\nel.aclass('later', 50);\nel.hclass('later'); // false\n\nsetTimeout(function() {\n\tconsole.log(el.hclass('later'));\n}, 100);\n</script>\n```\n\n### el.asvg(tag)\n\nType: `method`\n\nAppends an SVG element to the 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\nA tag name creates one element in the SVG namespace and returns it. A text with markup appends all of its elements; use a tag name when you need the new element afterwards.\n\nExample: Append SVG elements\n```html\n<svg id=\"chart\"></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.asvg('circle').attr('r', 5);\nsvg.asvg('<rect width=\"3\"/><line/>');\n\nsvg.children().length; // 3\nsvg.children()[0].namespaceURI; // \"http://www.w3.org/2000/svg\"\n</script>\n```\n\n### el.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 the `data-` prefix. |\n| `value` | `Object` | no |  | The new value. |\n\nReturns: `String or jQuery` The value when reading, the same element when writing.\n\nExample: Data attributes\n```html\n<div id=\"box\" data-id=\"7\"></div>\n\n<script>\nvar el = $('#box');\n\nel.attrd('id'); // \"7\"\nel.attrd('name', 'Ann');\nel.attr('data-name'); // \"Ann\"\n</script>\n```\n\n### el.attrd2(name)\n\nType: `method`\n\nReads a `data-` attribute from the element or its nearest parent that has it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute name without the `data-` prefix. |\n\nReturns: `String` The value, or `undefined`.\n\nExample: Inherit a value\n```html\n<div data-id=\"7\"><span id=\"child\"></span></div>\n\n<script>\n$('#child').attrd2('id'); // \"7\"\n$('#child').attrd2('missing'); // undefined\n</script>\n```\n\n### el.autofocus([selector])\n\nType: `method`\n\nMoves the focus to the first visible field inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `'input,select,textarea'` | The fields to look for. |\n\nReturns: `jQuery` The same element.\n\nWhen no field can take the focus, the method retries every 200 milliseconds, up to 15 times. It does nothing on mobile devices.\n\nExample: Focus a form\n```html\n<div id=\"form\">\n\t<input id=\"hidden\" style=\"display:none\">\n\t<input id=\"name\">\n\t<textarea id=\"note\"></textarea>\n</div>\n\n<script>\n$('#form').autofocus();\ndocument.activeElement.id; // \"name\"\n\n$('#form').autofocus('textarea');\ndocument.activeElement.id; // \"note\"\n</script>\n```\n\n### el.binder()\n\nType: `method`\n\nReturns the binder of the element or its nearest parent.\n\nReturns: `Object` The binder, or `null`.\n\nSee [ui-bind](../ui-bind/).\n\nExample: Read a binder\n```html\n<ui-bind path=\"user.name\" config=\"show\"><span id=\"label\"></span></ui-bind>\n\n<script>\nsetTimeout(function() {\n\tconsole.log($('#label').binder().path);\n}, 500);\n</script>\n```\n\n### el.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuns a command in all components inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command name. |\n| `a` | `Object` | no |  | The first of up to five arguments for the command. |\n\nComponents register commands with `self.command()`. See [Component](../component/).\n\nExample: Run a command\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.make = function() {\n\t\tself.command('reset', function(value) {\n\t\t\tconsole.log(self.path, value);\n\t\t});\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').CMD('reset', 0);\n});\n</script>\n```\n\n### el.component()\n\nType: `method`\n\nReturns the component of the element or its nearest parent.\n\nReturns: `Component` The component, or `null`.\n\nExample: Find the parent component\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#inner').component().path);\n});\n</script>\n```\n\n### el.components([fn])\n\nType: `method`\n\nLists or walks the ready components inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | no |  | Called for each component. |\n\nReturns: `Array or jQuery` Without `fn`, an array of components, or `null` when there are none. With `fn`, the component elements.\n\nWith `fn`, the function is called with the component as `this` and the position of its element as the argument.\n\nExample: Walk components\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#panel').components().length);\n\t$('#panel').components(function(index) {\n\t\tconsole.log(index, this.path);\n\t});\n});\n</script>\n```\n\n### el.EXEC(name, [args...])\n\nType: `method`\n\nCalls a method on the components inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The method name, optionally with the prefix `^`. |\n| `args` | `Object` | no |  | The arguments of the method. |\n\nReturns: `jQuery` The same element.\n\nWith the prefix `^`, the method is called on the components in the parent elements. Components without the method are skipped.\n\nExample: Call a method\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').EXEC('hello', 'Ann');\n});\n</script>\n```\n\nExample: Call a method on the parents\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#inner').EXEC('^hello', 'Bob');\n});\n</script>\n```\n\n### el.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nFinds components inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The component selector. |\n| `many` | `Boolean` | no |  | Use `true` to get all matching components. |\n| `callback` | `Function` | no |  | Receives the result when it is available. |\n| `timeout` | `Number` | no |  | The maximum waiting time in milliseconds. |\n\nReturns: `Component, Array or jQuery` The first component, or an array with `many`. With `callback`, the same element.\n\nThe selector can be a component name, `name[path]`, `.path`, `#id` or `*`.\n\nWith `callback`, the method waits until a component exists and then calls `callback(component)`, with the component also as `this`. When `timeout` runs out first, the callback is not called. `many` can be left out when you pass a callback.\n\nExample: Find components\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tconsole.log(panel.FIND('counter').path);\n\tconsole.log(panel.FIND('counter', true).length);\n\tconsole.log(panel.FIND('.data.b').path);\n\tconsole.log(panel.FIND('counter[data.b]').path);\n});\n</script>\n```\n\nExample: Wait for a component\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').FIND('late', function(component) {\n\tconsole.log('found', component.path);\n}, 3000);\n\nCOMPONENT('late', function(self) {});\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.hclass(name)\n\nType: `method`\n\nChecks whether the element has a 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: Check a class\n```html\n<div id=\"box\" class=\"active\"></div>\n\n<script>\n$('#box').hclass('active'); // true\n$('#box').hclass('missing'); // false\n</script>\n```\n\n### el.multiple(selectors)\n\nType: `method`\n\nRuns several `find()` calls and returns the results under their names.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Names and selectors. |\n\nReturns: `Object` jQuery objects under the same names.\n\nExample: Find several elements\n```html\n<div id=\"form\"><input id=\"name\"><button>Save</button></div>\n\n<script>\nvar ui = $('#form').multiple({ name: 'input', save: 'button' });\n\nui.name.attr('id'); // \"name\"\nui.save.text(); // \"Save\"\n</script>\n```\n\n### el.plugin()\n\nType: `method`\n\nReturns the plugin that contains the element.\n\nReturns: `Plugin` The plugin, or `undefined`.\n\nSee [Plugin](../plugin/).\n\nExample: Reach a plugin\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n\texports.total = function() {\n\t\treturn 3;\n\t};\n});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').plugin().total());\n}, 500);\n</script>\n```\n\n### el.psvg(tag)\n\nType: `method`\n\nPrepends an SVG element to the 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\nIt works like [asvg()](#asvg), and the new content goes first.\n\nExample: Prepend an SVG element\n```html\n<svg id=\"chart\"><circle r=\"5\"></circle></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.psvg('text').attr('x', 1);\nsvg.children()[0].nodeName; // \"text\"\n</script>\n```\n\n### el.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 element.\n\nExample: Remove an attribute\n```html\n<div id=\"box\" title=\"Hello\"></div>\n\n<script>\n$('#box').rattr('title').attr('title'); // undefined\n</script>\n```\n\n### el.rattrd(name, [name2], ...)\n\nType: `method`\n\nRemoves one or more `data-` attributes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute names without the `data-` prefix. |\n\nReturns: `jQuery` The same element.\n\nExample: Remove data attributes\n```html\n<div id=\"box\" data-a=\"1\" data-b=\"2\" data-c=\"3\"></div>\n\n<script>\nvar el = $('#box').rattrd('a', 'b');\n\nel.attr('data-a'); // undefined\nel.attr('data-b'); // undefined\nel.attr('data-c'); // \"3\"\n</script>\n```\n\n### el.rclass([name], [delay])\n\nType: `method`\n\nRemoves classes, immediately or after a delay.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | The class names, separated by spaces. |\n| `delay` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `jQuery` The same element.\n\nWithout a name, all classes are removed. Delayed calls share one timer per element, so a new delayed `aclass()`, `rclass()` or `rclass2()` call cancels the one still waiting.\n\nExample: Remove classes\n```html\n<div id=\"box\" class=\"a b c\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass('a').attr('class'); // \"b c\"\nel.rclass().attr('class'); // \"\"\n</script>\n```\n\n### el.rclass2(search, [delay])\n\nType: `method`\n\nRemoves the classes that contain a text or match a regular expression.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | The text to look for, or a regular expression. |\n| `delay` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `jQuery` The same element.\n\nDelayed calls share one timer per element, so a new delayed `aclass()`, `rclass()` or `rclass2()` call cancels the one still waiting.\n\nExample: Remove by pattern\n```html\n<div id=\"box\" class=\"size-1 size-2 color-red ok\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass2('size-').attr('class'); // \"color-red ok\"\nel.rclass2(/^color/).attr('class'); // \"ok\"\n</script>\n```\n\n### el.RECONFIGURE(selector, value)\n\nType: `method`\n\nChanges the configuration of components inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The component selector. |\n| `value` | `String or Object` | yes |  | The new configuration. |\n\nReturns: `jQuery` The same element.\n\nThe selector has the same forms as in [FIND()](#find).\n\nExample: Reconfigure components\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', 'step:1', function(self) {});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tpanel.RECONFIGURE('counter', 'step:5');\n\tconsole.log(panel.FIND('counter').config.step);\n\tpanel.RECONFIGURE('counter', { step: 9 });\n\tconsole.log(panel.FIND('counter').config.step);\n});\n</script>\n```\n\n### el.scope()\n\nType: `method`\n\nReturns the scope that contains the element.\n\nReturns: `Scope` The scope. Outside a scope, the result is empty.\n\nSee [Scope](../scope/).\n\nExample: Read the scope path\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').scope().path);\n}, 500);\n</script>\n```\n\n### el.SETTER([wait], selector, method, [args...])\n\nType: `method`\n\nCalls a method on the components inside the element that match a selector.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Use `true` to wait for the component. |\n| `selector` | `String` | yes |  | The component selector. |\n| `method` | `String` | yes |  | The method name. |\n| `args` | `Object` | no |  | The arguments of the method. |\n\nReturns: `jQuery` The same element.\n\nThe selector has the same forms as in [FIND()](#find). The method can be a nested name such as `nested.run`, and it can also be part of the selector as `selector/method`. With `true` as the first argument, the call waits until a matching component exists.\n\nExample: Call matching components\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').SETTER('counter', 'hello', 'Ann');\n\t$('#panel').SETTER('.data.b/hello', 'Bob');\n});\n</script>\n```\n\nExample: Wait for a component\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').SETTER(true, 'late', 'hello', 'Ann');\n\nCOMPONENT('late', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('hello', name);\n\t};\n});\n\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.tclass(name, [state])\n\nType: `method`\n\nToggles a class.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class name. |\n| `state` | `Boolean` | no |  | `true` adds the class and `false` removes it. |\n\nReturns: `jQuery` The same element.\n\nExample: Toggle a class\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\n\nel.tclass('open').hclass('open'); // true\nel.tclass('open').hclass('open'); // false\nel.tclass('open', true).hclass('open'); // true\n</script>\n```\n\n### el.vbind()\n\nType: `method`\n\nReturns the virtual binder of an item created by `VBINDARRAY()`.\n\nReturns: `Object` The binder of the item, or `null`.\n\nThe element can be the item or an element inside it. See [Virtual binder](../vbinder/).\n\nExample: Read the item binder\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }, { name: 'Bob' }]);\n\n$('#list b').last().vbind().index; // 1\n</script>\n```\n\n### el.vbindarray()\n\nType: `method`\n\nReturns the object created by `VBINDARRAY()` for the element or its nearest parent.\n\nReturns: `Object` The virtual binder array, or `null`.\n\nSee [Virtual binder](../vbinder/).\n\nExample: Read the array binder\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }]);\n\n$('#list b').vbindarray() === list; // true\n</script>\n```\n\n### $.components\n\nType: `property`\n\nA reference to the global object `M`.\n\nSee [M](../m/).\n\nExample: The same object\n```js\n$.components === M; // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"el.aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"el.asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"el.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"el.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"el.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"el.binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"el.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"el.component()","since":"","deprecated":false},{"type":"method","name":"components()","signature":"el.components([fn])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"el.EXEC(name, [args...])","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"el.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"el.hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"el.multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"el.plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"el.psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"el.rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"el.rattrd(name, [name2], ...)","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"el.rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"el.rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"el.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"el.scope()","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"el.SETTER([wait], selector, method, [args...])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"el.tclass(name, [state])","since":"","deprecated":false},{"type":"method","name":"vbind()","signature":"el.vbind()","since":"","deprecated":false},{"type":"method","name":"vbindarray()","signature":"el.vbindarray()","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammeB4wj61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/jquery/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"de","title":"jQuery-Erweiterungen","summary":"Methoden, die jComponent zu jQuery hinzufügt, um mit Klassen, Attributen, SVG, Komponenten und Scopes zu arbeiten.","markdown":"---\ntitle: jQuery-Erweiterungen\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/reference/jquery/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# jQuery-Erweiterungen\n\n> Methoden, die jComponent zu jQuery hinzufügt, um mit Klassen, Attributen, SVG, Komponenten und Scopes zu arbeiten.\n\njComponent enthält jQuery und fügt diese Methoden zu `$.fn` hinzu, sodass sie auf jedem jQuery-Objekt funktionieren. Die Seite [Komponente](../component/) beschreibt die Objekte, die die Komponentenmethoden zurückgeben, und [Komponenten verwenden](../../guides/using-components/) erklärt, wie Komponenten deklariert werden.\n\n## API\n\n### el.aclass(name, [delay])\n\nType: `method`\n\nFügt eine oder mehrere Klassen hinzu, sofort oder nach einer Verzögerung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Klassennamen, getrennt durch Leerzeichen. |\n| `delay` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `jQuery` Dasselbe Element.\n\nVerzögerte Aufrufe teilen sich einen Timer pro Element, daher bricht ein neuer verzögerter Aufruf von `aclass()`, `rclass()` oder `rclass2()` den noch wartenden ab.\n\nExample: Eine Klasse hinzufügen\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\nel.aclass('active');\nel.hclass('active'); // true\n\nel.aclass('later', 50);\nel.hclass('later'); // false\n\nsetTimeout(function() {\n\tconsole.log(el.hclass('later'));\n}, 100);\n</script>\n```\n\n### el.asvg(tag)\n\nType: `method`\n\nHängt ein SVG-Element an das 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\nEin Tag-Name erstellt ein Element im SVG-Namensraum und gibt es zurück. Ein Text mit Markup hängt alle seine Elemente an; verwende einen Tag-Namen, wenn du das neue Element danach noch brauchst.\n\nExample: SVG-Elemente anhängen\n```html\n<svg id=\"chart\"></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.asvg('circle').attr('r', 5);\nsvg.asvg('<rect width=\"3\"/><line/>');\n\nsvg.children().length; // 3\nsvg.children()[0].namespaceURI; // \"http://www.w3.org/2000/svg\"\n</script>\n```\n\n### el.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 das Präfix `data-`. |\n| `value` | `Object` | no |  | Der neue Wert. |\n\nReturns: `String or jQuery` Beim Lesen der Wert, beim Schreiben dasselbe Element.\n\nExample: Data-Attribute\n```html\n<div id=\"box\" data-id=\"7\"></div>\n\n<script>\nvar el = $('#box');\n\nel.attrd('id'); // \"7\"\nel.attrd('name', 'Ann');\nel.attr('data-name'); // \"Ann\"\n</script>\n```\n\n### el.attrd2(name)\n\nType: `method`\n\nLiest ein `data-`-Attribut vom Element oder von seinem nächstgelegenen Elternelement, das es besitzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Attributname ohne das Präfix `data-`. |\n\nReturns: `String` Der Wert oder `undefined`.\n\nExample: Einen Wert erben\n```html\n<div data-id=\"7\"><span id=\"child\"></span></div>\n\n<script>\n$('#child').attrd2('id'); // \"7\"\n$('#child').attrd2('missing'); // undefined\n</script>\n```\n\n### el.autofocus([selector])\n\nType: `method`\n\nSetzt den Fokus auf das erste sichtbare Feld innerhalb des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `'input,select,textarea'` | Die zu suchenden Felder. |\n\nReturns: `jQuery` Dasselbe Element.\n\nKann kein Feld den Fokus erhalten, versucht es die Methode alle 200 Millisekunden erneut, bis zu 15 Mal. Auf Mobilgeräten macht sie nichts.\n\nExample: Ein Formular fokussieren\n```html\n<div id=\"form\">\n\t<input id=\"hidden\" style=\"display:none\">\n\t<input id=\"name\">\n\t<textarea id=\"note\"></textarea>\n</div>\n\n<script>\n$('#form').autofocus();\ndocument.activeElement.id; // \"name\"\n\n$('#form').autofocus('textarea');\ndocument.activeElement.id; // \"note\"\n</script>\n```\n\n### el.binder()\n\nType: `method`\n\nGibt den Binder des Elements oder seines nächstgelegenen Elternelements zurück.\n\nReturns: `Object` Der Binder oder `null`.\n\nSiehe [ui-bind](../ui-bind/).\n\nExample: Einen Binder lesen\n```html\n<ui-bind path=\"user.name\" config=\"show\"><span id=\"label\"></span></ui-bind>\n\n<script>\nsetTimeout(function() {\n\tconsole.log($('#label').binder().path);\n}, 500);\n</script>\n```\n\n### el.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nFührt einen Befehl in allen Komponenten innerhalb des Elements aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehlsname. |\n| `a` | `Object` | no |  | Das erste von bis zu fünf Argumenten für den Befehl. |\n\nKomponenten registrieren Befehle mit `self.command()`. Siehe [Komponente](../component/).\n\nExample: Einen Befehl ausführen\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.make = function() {\n\t\tself.command('reset', function(value) {\n\t\t\tconsole.log(self.path, value);\n\t\t});\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').CMD('reset', 0);\n});\n</script>\n```\n\n### el.component()\n\nType: `method`\n\nGibt die Komponente des Elements oder seines nächstgelegenen Elternelements zurück.\n\nReturns: `Component` Die Komponente oder `null`.\n\nExample: Die übergeordnete Komponente finden\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#inner').component().path);\n});\n</script>\n```\n\n### el.components([fn])\n\nType: `method`\n\nListet die bereiten Komponenten innerhalb des Elements auf oder durchläuft sie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | no |  | Wird für jede Komponente aufgerufen. |\n\nReturns: `Array or jQuery` Ohne `fn` ein Array von Komponenten oder, wenn keine vorhanden sind, `null`. Mit `fn` die Komponentenelemente.\n\nMit `fn` wird die Funktion mit der Komponente als `this` und der Position ihres Elements als Argument aufgerufen.\n\nExample: Komponenten durchlaufen\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#panel').components().length);\n\t$('#panel').components(function(index) {\n\t\tconsole.log(index, this.path);\n\t});\n});\n</script>\n```\n\n### el.EXEC(name, [args...])\n\nType: `method`\n\nRuft eine Methode der Komponenten innerhalb des Elements auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Methodenname, optional mit dem Präfix `^`. |\n| `args` | `Object` | no |  | Die Argumente der Methode. |\n\nReturns: `jQuery` Dasselbe Element.\n\nMit dem Präfix `^` wird die Methode auf den Komponenten in den Elternelementen aufgerufen. Komponenten ohne die Methode werden übersprungen.\n\nExample: Methode aufrufen\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').EXEC('hello', 'Ann');\n});\n</script>\n```\n\nExample: Eine Methode auf den Elternelementen aufrufen\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#inner').EXEC('^hello', 'Bob');\n});\n</script>\n```\n\n### el.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nFindet Komponenten innerhalb des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Komponentenselektor. |\n| `many` | `Boolean` | no |  | Verwende `true`, um alle passenden Komponenten zu erhalten. |\n| `callback` | `Function` | no |  | Erhält das Ergebnis, sobald es verfügbar ist. |\n| `timeout` | `Number` | no |  | Die maximale Wartezeit in Millisekunden. |\n\nReturns: `Component, Array or jQuery` Die erste Komponente oder, mit `many`, ein Array. Mit `callback` dasselbe Element.\n\nDer Selektor kann ein Komponentenname, `name[path]`, `.path`, `#id` oder `*` sein.\n\nMit `callback` wartet die Methode, bis eine Komponente existiert, und ruft dann `callback(component)` auf, wobei die Komponente auch `this` ist. Läuft `timeout` vorher ab, wird der Callback nicht aufgerufen. `many` kannst du weglassen, wenn du einen Callback übergibst.\n\nExample: Komponenten finden\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tconsole.log(panel.FIND('counter').path);\n\tconsole.log(panel.FIND('counter', true).length);\n\tconsole.log(panel.FIND('.data.b').path);\n\tconsole.log(panel.FIND('counter[data.b]').path);\n});\n</script>\n```\n\nExample: Auf eine Komponente warten\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').FIND('late', function(component) {\n\tconsole.log('found', component.path);\n}, 3000);\n\nCOMPONENT('late', function(self) {});\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.hclass(name)\n\nType: `method`\n\nPrüft, ob das Element eine 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: Eine Klasse prüfen\n```html\n<div id=\"box\" class=\"active\"></div>\n\n<script>\n$('#box').hclass('active'); // true\n$('#box').hclass('missing'); // false\n</script>\n```\n\n### el.multiple(selectors)\n\nType: `method`\n\nFührt mehrere `find()`-Aufrufe aus und gibt die Ergebnisse unter ihren Namen zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Namen und Selektoren. |\n\nReturns: `Object` jQuery-Objekte unter denselben Namen.\n\nExample: Mehrere Elemente finden\n```html\n<div id=\"form\"><input id=\"name\"><button>Save</button></div>\n\n<script>\nvar ui = $('#form').multiple({ name: 'input', save: 'button' });\n\nui.name.attr('id'); // \"name\"\nui.save.text(); // \"Save\"\n</script>\n```\n\n### el.plugin()\n\nType: `method`\n\nGibt das Plugin zurück, das das Element enthält.\n\nReturns: `Plugin` Das Plugin oder `undefined`.\n\nSiehe [Plugin](../plugin/).\n\nExample: Ein Plugin erreichen\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n\texports.total = function() {\n\t\treturn 3;\n\t};\n});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').plugin().total());\n}, 500);\n</script>\n```\n\n### el.psvg(tag)\n\nType: `method`\n\nStellt dem Element ein SVG-Element voran.\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\nDas funktioniert wie [asvg()](#asvg), wobei der neue Inhalt an den Anfang kommt.\n\nExample: Ein SVG-Element voranstellen\n```html\n<svg id=\"chart\"><circle r=\"5\"></circle></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.psvg('text').attr('x', 1);\nsvg.children()[0].nodeName; // \"text\"\n</script>\n```\n\n### el.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` Dasselbe Element.\n\nExample: Ein Attribut entfernen\n```html\n<div id=\"box\" title=\"Hello\"></div>\n\n<script>\n$('#box').rattr('title').attr('title'); // undefined\n</script>\n```\n\n### el.rattrd(name, [name2], ...)\n\nType: `method`\n\nEntfernt ein oder mehrere `data-`-Attribute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Attributnamen ohne das Präfix `data-`. |\n\nReturns: `jQuery` Dasselbe Element.\n\nExample: Data-Attribute entfernen\n```html\n<div id=\"box\" data-a=\"1\" data-b=\"2\" data-c=\"3\"></div>\n\n<script>\nvar el = $('#box').rattrd('a', 'b');\n\nel.attr('data-a'); // undefined\nel.attr('data-b'); // undefined\nel.attr('data-c'); // \"3\"\n</script>\n```\n\n### el.rclass([name], [delay])\n\nType: `method`\n\nEntfernt Klassen, sofort oder nach einer Verzögerung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Die Klassennamen, getrennt durch Leerzeichen. |\n| `delay` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `jQuery` Dasselbe Element.\n\nOhne Namen werden alle Klassen entfernt. Verzögerte Aufrufe teilen sich einen Timer pro Element, daher bricht ein neuer verzögerter Aufruf von `aclass()`, `rclass()` oder `rclass2()` den noch wartenden ab.\n\nExample: Klassen entfernen\n```html\n<div id=\"box\" class=\"a b c\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass('a').attr('class'); // \"b c\"\nel.rclass().attr('class'); // \"\"\n</script>\n```\n\n### el.rclass2(search, [delay])\n\nType: `method`\n\nEntfernt die Klassen, die einen Text enthalten oder zu einem regulären Ausdruck passen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Der zu suchende Text oder ein regulärer Ausdruck. |\n| `delay` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `jQuery` Dasselbe Element.\n\nVerzögerte Aufrufe teilen sich einen Timer pro Element, daher bricht ein neuer verzögerter Aufruf von `aclass()`, `rclass()` oder `rclass2()` den noch wartenden ab.\n\nExample: Nach Muster entfernen\n```html\n<div id=\"box\" class=\"size-1 size-2 color-red ok\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass2('size-').attr('class'); // \"color-red ok\"\nel.rclass2(/^color/).attr('class'); // \"ok\"\n</script>\n```\n\n### el.RECONFIGURE(selector, value)\n\nType: `method`\n\nÄndert die Konfiguration der Komponenten innerhalb des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Komponentenselektor. |\n| `value` | `String or Object` | yes |  | Die neue Konfiguration. |\n\nReturns: `jQuery` Dasselbe Element.\n\nDer Selektor hat dieselben Formen wie bei [FIND()](#find).\n\nExample: Komponenten neu konfigurieren\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', 'step:1', function(self) {});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tpanel.RECONFIGURE('counter', 'step:5');\n\tconsole.log(panel.FIND('counter').config.step);\n\tpanel.RECONFIGURE('counter', { step: 9 });\n\tconsole.log(panel.FIND('counter').config.step);\n});\n</script>\n```\n\n### el.scope()\n\nType: `method`\n\nGibt den Scope zurück, der das Element enthält.\n\nReturns: `Scope` Der Scope. Außerhalb eines Scopes ist das Ergebnis leer.\n\nSiehe [Scope](../scope/).\n\nExample: Den Path des Scopes lesen\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').scope().path);\n}, 500);\n</script>\n```\n\n### el.SETTER([wait], selector, method, [args...])\n\nType: `method`\n\nRuft eine Methode der Komponenten innerhalb des Elements auf, die zu einem Selektor passen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Verwende `true`, um auf die Komponente zu warten. |\n| `selector` | `String` | yes |  | Der Komponentenselektor. |\n| `method` | `String` | yes |  | Der Methodenname. |\n| `args` | `Object` | no |  | Die Argumente der Methode. |\n\nReturns: `jQuery` Dasselbe Element.\n\nDer Selektor hat dieselben Formen wie bei [FIND()](#find). Die Methode kann ein verschachtelter Name wie `nested.run` sein und auch als `selector/method` Teil des Selektors sein. Mit `true` als erstem Argument wartet der Aufruf, bis eine passende Komponente existiert.\n\nExample: Passende Komponenten aufrufen\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').SETTER('counter', 'hello', 'Ann');\n\t$('#panel').SETTER('.data.b/hello', 'Bob');\n});\n</script>\n```\n\nExample: Auf eine Komponente warten\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').SETTER(true, 'late', 'hello', 'Ann');\n\nCOMPONENT('late', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('hello', name);\n\t};\n});\n\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.tclass(name, [state])\n\nType: `method`\n\nSchaltet eine Klasse um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Klassenname. |\n| `state` | `Boolean` | no |  | `true` fügt die Klasse hinzu und `false` entfernt sie. |\n\nReturns: `jQuery` Dasselbe Element.\n\nExample: Eine Klasse umschalten\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\n\nel.tclass('open').hclass('open'); // true\nel.tclass('open').hclass('open'); // false\nel.tclass('open', true).hclass('open'); // true\n</script>\n```\n\n### el.vbind()\n\nType: `method`\n\nGibt den virtuellen Binder eines von `VBINDARRAY()` erstellten Eintrags zurück.\n\nReturns: `Object` Der Binder des Eintrags oder `null`.\n\nDas Element kann der Eintrag oder ein Element darin sein. Siehe [Virtueller Binder](../vbinder/).\n\nExample: Den Binder des Eintrags lesen\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }, { name: 'Bob' }]);\n\n$('#list b').last().vbind().index; // 1\n</script>\n```\n\n### el.vbindarray()\n\nType: `method`\n\nGibt das von `VBINDARRAY()` erstellte Objekt für das Element oder sein nächstgelegenes Elternelement zurück.\n\nReturns: `Object` Das virtuelle Binder-Array oder `null`.\n\nSiehe [Virtueller Binder](../vbinder/).\n\nExample: Den Array-Binder lesen\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }]);\n\n$('#list b').vbindarray() === list; // true\n</script>\n```\n\n### $.components\n\nType: `property`\n\nEine Referenz auf das globale Objekt `M`.\n\nSiehe [M](../m/).\n\nExample: Dasselbe Objekt\n```js\n$.components === M; // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"el.aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"el.asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"el.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"el.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"el.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"el.binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"el.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"el.component()","since":"","deprecated":false},{"type":"method","name":"components()","signature":"el.components([fn])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"el.EXEC(name, [args...])","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"el.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"el.hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"el.multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"el.plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"el.psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"el.rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"el.rattrd(name, [name2], ...)","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"el.rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"el.rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"el.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"el.scope()","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"el.SETTER([wait], selector, method, [args...])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"el.tclass(name, [state])","since":"","deprecated":false},{"type":"method","name":"vbind()","signature":"el.vbind()","since":"","deprecated":false},{"type":"method","name":"vbindarray()","signature":"el.vbindarray()","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammeB4wj61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/jquery/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"es","title":"Extensiones de jQuery","summary":"Métodos que jComponent añade a jQuery para trabajar con clases, atributos, SVG, componentes y scopes.","markdown":"---\ntitle: Extensiones de jQuery\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/reference/jquery/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Extensiones de jQuery\n\n> Métodos que jComponent añade a jQuery para trabajar con clases, atributos, SVG, componentes y scopes.\n\njComponent incluye jQuery y añade estos métodos a `$.fn`, así que funcionan en cualquier objeto de jQuery. En la página [Componente](../component/) se describen los objetos que devuelven los métodos de componentes, y en [Usar componentes](../../guides/using-components/) se explica cómo se declaran los componentes.\n\n## API\n\n### el.aclass(name, [delay])\n\nType: `method`\n\nAñade una o varias clases, de inmediato o después de un retardo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Los nombres de las clases, separados por espacios. |\n| `delay` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `jQuery` El mismo elemento.\n\nLas llamadas retrasadas comparten un temporizador por elemento, así que una nueva llamada retrasada a `aclass()`, `rclass()` o `rclass2()` cancela la que aún está en espera.\n\nExample: Añadir una clase\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\nel.aclass('active');\nel.hclass('active'); // true\n\nel.aclass('later', 50);\nel.hclass('later'); // false\n\nsetTimeout(function() {\n\tconsole.log(el.hclass('later'));\n}, 100);\n</script>\n```\n\n### el.asvg(tag)\n\nType: `method`\n\nAñade un elemento SVG al final del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nombre de etiqueta o marcado SVG. |\n\nReturns: `jQuery` El elemento nuevo, cuando `tag` es un nombre de etiqueta.\n\nUn nombre de etiqueta crea un elemento en el espacio de nombres SVG y lo devuelve. Un texto con marcado añade todos sus elementos; usa un nombre de etiqueta cuando necesites el elemento nuevo después.\n\nExample: Añadir elementos SVG\n```html\n<svg id=\"chart\"></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.asvg('circle').attr('r', 5);\nsvg.asvg('<rect width=\"3\"/><line/>');\n\nsvg.children().length; // 3\nsvg.children()[0].namespaceURI; // \"http://www.w3.org/2000/svg\"\n</script>\n```\n\n### el.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 el prefijo `data-`. |\n| `value` | `Object` | no |  | El nuevo valor. |\n\nReturns: `String or jQuery` El valor al leer, el mismo elemento al escribir.\n\nExample: Atributos data\n```html\n<div id=\"box\" data-id=\"7\"></div>\n\n<script>\nvar el = $('#box');\n\nel.attrd('id'); // \"7\"\nel.attrd('name', 'Ann');\nel.attr('data-name'); // \"Ann\"\n</script>\n```\n\n### el.attrd2(name)\n\nType: `method`\n\nLee un atributo `data-` del elemento o del padre más cercano que lo tenga.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del atributo sin el prefijo `data-`. |\n\nReturns: `String` El valor, o `undefined`.\n\nExample: Heredar un valor\n```html\n<div data-id=\"7\"><span id=\"child\"></span></div>\n\n<script>\n$('#child').attrd2('id'); // \"7\"\n$('#child').attrd2('missing'); // undefined\n</script>\n```\n\n### el.autofocus([selector])\n\nType: `method`\n\nMueve el foco al primer campo visible dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `'input,select,textarea'` | Los campos que se buscan. |\n\nReturns: `jQuery` El mismo elemento.\n\nCuando ningún campo puede recibir el foco, el método lo reintenta cada 200 milisegundos, hasta 15 veces. No hace nada en dispositivos móviles.\n\nExample: Dar el foco a un formulario\n```html\n<div id=\"form\">\n\t<input id=\"hidden\" style=\"display:none\">\n\t<input id=\"name\">\n\t<textarea id=\"note\"></textarea>\n</div>\n\n<script>\n$('#form').autofocus();\ndocument.activeElement.id; // \"name\"\n\n$('#form').autofocus('textarea');\ndocument.activeElement.id; // \"note\"\n</script>\n```\n\n### el.binder()\n\nType: `method`\n\nDevuelve el binder del elemento o de su padre más cercano.\n\nReturns: `Object` El binder, o `null`.\n\nConsulta [ui-bind](../ui-bind/).\n\nExample: Leer un binder\n```html\n<ui-bind path=\"user.name\" config=\"show\"><span id=\"label\"></span></ui-bind>\n\n<script>\nsetTimeout(function() {\n\tconsole.log($('#label').binder().path);\n}, 500);\n</script>\n```\n\n### el.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nEjecuta un comando en todos los componentes dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n| `a` | `Object` | no |  | El primero de hasta cinco argumentos del comando. |\n\nLos componentes registran comandos con `self.command()`. Consulta [Componente](../component/).\n\nExample: Ejecutar un comando\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.make = function() {\n\t\tself.command('reset', function(value) {\n\t\t\tconsole.log(self.path, value);\n\t\t});\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').CMD('reset', 0);\n});\n</script>\n```\n\n### el.component()\n\nType: `method`\n\nDevuelve el componente del elemento o de su padre más cercano.\n\nReturns: `Component` El componente, o `null`.\n\nExample: Buscar el componente padre\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#inner').component().path);\n});\n</script>\n```\n\n### el.components([fn])\n\nType: `method`\n\nLista o recorre los componentes listos dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | no |  | Se llama para cada componente. |\n\nReturns: `Array or jQuery` Sin `fn`, un array de componentes, o `null` si no hay ninguno. Con `fn`, los elementos de los componentes.\n\nCon `fn`, se llama a la función con el componente como `this` y la posición de su elemento como argumento.\n\nExample: Recorrer los componentes\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#panel').components().length);\n\t$('#panel').components(function(index) {\n\t\tconsole.log(index, this.path);\n\t});\n});\n</script>\n```\n\n### el.EXEC(name, [args...])\n\nType: `method`\n\nLlama a un método de los componentes dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del método, opcionalmente con el prefijo `^`. |\n| `args` | `Object` | no |  | Los argumentos del método. |\n\nReturns: `jQuery` El mismo elemento.\n\nCon el prefijo `^`, se llama al método de los componentes de los elementos padre. Los componentes que no tienen el método se omiten.\n\nExample: Llamar a un método\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').EXEC('hello', 'Ann');\n});\n</script>\n```\n\nExample: Llamar a un método de los padres\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#inner').EXEC('^hello', 'Bob');\n});\n</script>\n```\n\n### el.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nBusca componentes dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector del componente. |\n| `many` | `Boolean` | no |  | Usa `true` para obtener todos los componentes coincidentes. |\n| `callback` | `Function` | no |  | Recibe el resultado cuando está disponible. |\n| `timeout` | `Number` | no |  | El tiempo máximo de espera en milisegundos. |\n\nReturns: `Component, Array or jQuery` El primer componente, o un array con `many`. Con `callback`, el mismo elemento.\n\nEl selector puede ser un nombre de componente, `name[path]`, `.path`, `#id` o `*`.\n\nCon `callback`, el método espera hasta que exista un componente y entonces llama a `callback(component)`, con el componente también como `this`. Si `timeout` se agota antes, no se llama al callback. Puedes omitir `many` cuando pasas un callback.\n\nExample: Buscar componentes\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tconsole.log(panel.FIND('counter').path);\n\tconsole.log(panel.FIND('counter', true).length);\n\tconsole.log(panel.FIND('.data.b').path);\n\tconsole.log(panel.FIND('counter[data.b]').path);\n});\n</script>\n```\n\nExample: Esperar a un componente\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').FIND('late', function(component) {\n\tconsole.log('found', component.path);\n}, 3000);\n\nCOMPONENT('late', function(self) {});\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.hclass(name)\n\nType: `method`\n\nComprueba si el elemento tiene una clase.\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```html\n<div id=\"box\" class=\"active\"></div>\n\n<script>\n$('#box').hclass('active'); // true\n$('#box').hclass('missing'); // false\n</script>\n```\n\n### el.multiple(selectors)\n\nType: `method`\n\nEjecuta varias llamadas a `find()` y devuelve los resultados bajo sus nombres.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Nombres y selectores. |\n\nReturns: `Object` Objetos de jQuery bajo los mismos nombres.\n\nExample: Buscar varios elementos\n```html\n<div id=\"form\"><input id=\"name\"><button>Save</button></div>\n\n<script>\nvar ui = $('#form').multiple({ name: 'input', save: 'button' });\n\nui.name.attr('id'); // \"name\"\nui.save.text(); // \"Save\"\n</script>\n```\n\n### el.plugin()\n\nType: `method`\n\nDevuelve el plugin que contiene el elemento.\n\nReturns: `Plugin` El plugin, o `undefined`.\n\nConsulta [Plugin](../plugin/).\n\nExample: Acceder a un plugin\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n\texports.total = function() {\n\t\treturn 3;\n\t};\n});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').plugin().total());\n}, 500);\n</script>\n```\n\n### el.psvg(tag)\n\nType: `method`\n\nAñade un elemento SVG al principio del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nombre de etiqueta o marcado SVG. |\n\nReturns: `jQuery` El elemento nuevo, cuando `tag` es un nombre de etiqueta.\n\nFunciona como [asvg()](#asvg), y el contenido nuevo va primero.\n\nExample: Añadir un elemento SVG al principio\n```html\n<svg id=\"chart\"><circle r=\"5\"></circle></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.psvg('text').attr('x', 1);\nsvg.children()[0].nodeName; // \"text\"\n</script>\n```\n\n### el.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` El mismo elemento.\n\nExample: Eliminar un atributo\n```html\n<div id=\"box\" title=\"Hello\"></div>\n\n<script>\n$('#box').rattr('title').attr('title'); // undefined\n</script>\n```\n\n### el.rattrd(name, [name2], ...)\n\nType: `method`\n\nElimina uno o varios atributos `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Los nombres de los atributos sin el prefijo `data-`. |\n\nReturns: `jQuery` El mismo elemento.\n\nExample: Eliminar atributos data\n```html\n<div id=\"box\" data-a=\"1\" data-b=\"2\" data-c=\"3\"></div>\n\n<script>\nvar el = $('#box').rattrd('a', 'b');\n\nel.attr('data-a'); // undefined\nel.attr('data-b'); // undefined\nel.attr('data-c'); // \"3\"\n</script>\n```\n\n### el.rclass([name], [delay])\n\nType: `method`\n\nElimina clases, de inmediato o después de un retardo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Los nombres de las clases, separados por espacios. |\n| `delay` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `jQuery` El mismo elemento.\n\nSin nombre, se eliminan todas las clases. Las llamadas retrasadas comparten un temporizador por elemento, así que una nueva llamada retrasada a `aclass()`, `rclass()` o `rclass2()` cancela la que aún está en espera.\n\nExample: Eliminar clases\n```html\n<div id=\"box\" class=\"a b c\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass('a').attr('class'); // \"b c\"\nel.rclass().attr('class'); // \"\"\n</script>\n```\n\n### el.rclass2(search, [delay])\n\nType: `method`\n\nElimina las clases que contienen un texto o coinciden con una expresión regular.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | El texto que se busca o una expresión regular. |\n| `delay` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `jQuery` El mismo elemento.\n\nLas llamadas retrasadas comparten un temporizador por elemento, así que una nueva llamada retrasada a `aclass()`, `rclass()` o `rclass2()` cancela la que aún está en espera.\n\nExample: Eliminar por patrón\n```html\n<div id=\"box\" class=\"size-1 size-2 color-red ok\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass2('size-').attr('class'); // \"color-red ok\"\nel.rclass2(/^color/).attr('class'); // \"ok\"\n</script>\n```\n\n### el.RECONFIGURE(selector, value)\n\nType: `method`\n\nCambia la configuración de los componentes dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El selector del componente. |\n| `value` | `String or Object` | yes |  | La configuración nueva. |\n\nReturns: `jQuery` El mismo elemento.\n\nEl selector tiene las mismas formas que en [FIND()](#find).\n\nExample: Reconfigurar componentes\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', 'step:1', function(self) {});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tpanel.RECONFIGURE('counter', 'step:5');\n\tconsole.log(panel.FIND('counter').config.step);\n\tpanel.RECONFIGURE('counter', { step: 9 });\n\tconsole.log(panel.FIND('counter').config.step);\n});\n</script>\n```\n\n### el.scope()\n\nType: `method`\n\nDevuelve el scope que contiene el elemento.\n\nReturns: `Scope` El scope. Fuera de un scope, el resultado está vacío.\n\nConsulta [Scope](../scope/).\n\nExample: Leer el path del scope\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').scope().path);\n}, 500);\n</script>\n```\n\n### el.SETTER([wait], selector, method, [args...])\n\nType: `method`\n\nLlama a un método de los componentes dentro del elemento que coinciden con un selector.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Usa `true` para esperar al componente. |\n| `selector` | `String` | yes |  | El selector del componente. |\n| `method` | `String` | yes |  | El nombre del método. |\n| `args` | `Object` | no |  | Los argumentos del método. |\n\nReturns: `jQuery` El mismo elemento.\n\nEl selector tiene las mismas formas que en [FIND()](#find). El método puede ser un nombre anidado como `nested.run`, y también puede formar parte del selector como `selector/method`. Con `true` como primer argumento, la llamada espera hasta que exista un componente coincidente.\n\nExample: Llamar a los componentes coincidentes\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').SETTER('counter', 'hello', 'Ann');\n\t$('#panel').SETTER('.data.b/hello', 'Bob');\n});\n</script>\n```\n\nExample: Esperar a un componente\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').SETTER(true, 'late', 'hello', 'Ann');\n\nCOMPONENT('late', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('hello', name);\n\t};\n});\n\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.tclass(name, [state])\n\nType: `method`\n\nAlterna una clase.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la clase. |\n| `state` | `Boolean` | no |  | `true` añade la clase y `false` la quita. |\n\nReturns: `jQuery` El mismo elemento.\n\nExample: Alternar una clase\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\n\nel.tclass('open').hclass('open'); // true\nel.tclass('open').hclass('open'); // false\nel.tclass('open', true).hclass('open'); // true\n</script>\n```\n\n### el.vbind()\n\nType: `method`\n\nDevuelve el binder virtual de un ítem creado por `VBINDARRAY()`.\n\nReturns: `Object` El binder del ítem, o `null`.\n\nEl elemento puede ser el ítem o un elemento dentro de él. Consulta [Binder virtual](../vbinder/).\n\nExample: Leer el binder del ítem\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }, { name: 'Bob' }]);\n\n$('#list b').last().vbind().index; // 1\n</script>\n```\n\n### el.vbindarray()\n\nType: `method`\n\nDevuelve el objeto creado por `VBINDARRAY()` para el elemento o su padre más cercano.\n\nReturns: `Object` El array de binders virtuales, o `null`.\n\nConsulta [Binder virtual](../vbinder/).\n\nExample: Leer el binder del array\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }]);\n\n$('#list b').vbindarray() === list; // true\n</script>\n```\n\n### $.components\n\nType: `property`\n\nUna referencia al objeto global `M`.\n\nConsulta [M](../m/).\n\nExample: El mismo objeto\n```js\n$.components === M; // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"el.aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"el.asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"el.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"el.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"el.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"el.binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"el.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"el.component()","since":"","deprecated":false},{"type":"method","name":"components()","signature":"el.components([fn])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"el.EXEC(name, [args...])","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"el.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"el.hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"el.multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"el.plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"el.psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"el.rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"el.rattrd(name, [name2], ...)","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"el.rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"el.rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"el.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"el.scope()","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"el.SETTER([wait], selector, method, [args...])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"el.tclass(name, [state])","since":"","deprecated":false},{"type":"method","name":"vbind()","signature":"el.vbind()","since":"","deprecated":false},{"type":"method","name":"vbindarray()","signature":"el.vbindarray()","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammeB4wj61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/jquery/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"fr","title":"Extensions jQuery","summary":"Les méthodes que jComponent ajoute à jQuery pour travailler avec les classes, les attributs, le SVG, les composants et les scopes.","markdown":"---\ntitle: Extensions jQuery\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/reference/jquery/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Extensions jQuery\n\n> Les méthodes que jComponent ajoute à jQuery pour travailler avec les classes, les attributs, le SVG, les composants et les scopes.\n\njComponent inclut jQuery et ajoute ces méthodes à `$.fn`, elles fonctionnent donc sur chaque objet jQuery. La page [Composant](../component/) décrit les objets renvoyés par les méthodes de composant, et [Utiliser les composants](../../guides/using-components/) explique comment déclarer des composants.\n\n## API\n\n### el.aclass(name, [delay])\n\nType: `method`\n\nAjoute une ou plusieurs classes, immédiatement ou après un délai.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Les noms de classes, séparés par des espaces. |\n| `delay` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `jQuery` Le même élément.\n\nLes appels retardés partagent un seul minuteur par élément : un nouvel appel retardé à `aclass()`, `rclass()` ou `rclass2()` annule donc celui qui est encore en attente.\n\nExample: Ajouter une classe\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\nel.aclass('active');\nel.hclass('active'); // true\n\nel.aclass('later', 50);\nel.hclass('later'); // false\n\nsetTimeout(function() {\n\tconsole.log(el.hclass('later'));\n}, 100);\n</script>\n```\n\n### el.asvg(tag)\n\nType: `method`\n\nAjoute un élément SVG à la fin de l'élément.\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\nUn nom de balise crée un élément dans l'espace de noms SVG et le renvoie. Un texte contenant du balisage ajoute tous ses éléments ; utilise un nom de balise quand tu as besoin du nouvel élément par la suite.\n\nExample: Ajouter des éléments SVG\n```html\n<svg id=\"chart\"></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.asvg('circle').attr('r', 5);\nsvg.asvg('<rect width=\"3\"/><line/>');\n\nsvg.children().length; // 3\nsvg.children()[0].namespaceURI; // \"http://www.w3.org/2000/svg\"\n</script>\n```\n\n### el.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 le préfixe `data-`. |\n| `value` | `Object` | no |  | La nouvelle valeur. |\n\nReturns: `String or jQuery` La valeur en lecture, le même élément en écriture.\n\nExample: Attributs de données\n```html\n<div id=\"box\" data-id=\"7\"></div>\n\n<script>\nvar el = $('#box');\n\nel.attrd('id'); // \"7\"\nel.attrd('name', 'Ann');\nel.attr('data-name'); // \"Ann\"\n</script>\n```\n\n### el.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 le préfixe `data-`. |\n\nReturns: `String` La valeur, ou `undefined`.\n\nExample: Hériter d'une valeur\n```html\n<div data-id=\"7\"><span id=\"child\"></span></div>\n\n<script>\n$('#child').attrd2('id'); // \"7\"\n$('#child').attrd2('missing'); // undefined\n</script>\n```\n\n### el.autofocus([selector])\n\nType: `method`\n\nDéplace le focus vers le premier champ visible à l'intérieur de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `'input,select,textarea'` | Les champs à rechercher. |\n\nReturns: `jQuery` Le même élément.\n\nQuand aucun champ ne peut recevoir le focus, la méthode réessaie toutes les 200 millisecondes, jusqu'à 15 fois. Elle ne fait rien sur les appareils mobiles.\n\nExample: Donner le focus à un formulaire\n```html\n<div id=\"form\">\n\t<input id=\"hidden\" style=\"display:none\">\n\t<input id=\"name\">\n\t<textarea id=\"note\"></textarea>\n</div>\n\n<script>\n$('#form').autofocus();\ndocument.activeElement.id; // \"name\"\n\n$('#form').autofocus('textarea');\ndocument.activeElement.id; // \"note\"\n</script>\n```\n\n### el.binder()\n\nType: `method`\n\nRenvoie le binder de l'élément ou de son parent le plus proche.\n\nReturns: `Object` Le binder, ou `null`.\n\nVoir [ui-bind](../ui-bind/).\n\nExample: Lire un binder\n```html\n<ui-bind path=\"user.name\" config=\"show\"><span id=\"label\"></span></ui-bind>\n\n<script>\nsetTimeout(function() {\n\tconsole.log($('#label').binder().path);\n}, 500);\n</script>\n```\n\n### el.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nExécute une commande dans tous les composants à l'intérieur de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la commande. |\n| `a` | `Object` | no |  | Le premier des cinq arguments maximum de la commande. |\n\nLes composants enregistrent des commandes avec `self.command()`. Consulte [Composant](../component/).\n\nExample: Exécuter une commande\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.make = function() {\n\t\tself.command('reset', function(value) {\n\t\t\tconsole.log(self.path, value);\n\t\t});\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').CMD('reset', 0);\n});\n</script>\n```\n\n### el.component()\n\nType: `method`\n\nRenvoie le composant de l'élément ou de son parent le plus proche.\n\nReturns: `Component` Le composant, ou `null`.\n\nExample: Trouver le composant parent\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#inner').component().path);\n});\n</script>\n```\n\n### el.components([fn])\n\nType: `method`\n\nListe ou parcourt les composants prêts à l'intérieur de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | no |  | Appelée pour chaque composant. |\n\nReturns: `Array or jQuery` Sans `fn`, un tableau de composants, ou `null` s'il n'y en a aucun. Avec `fn`, les éléments des composants.\n\nAvec `fn`, la fonction est appelée avec le composant comme `this` et la position de son élément comme argument.\n\nExample: Parcourir les composants\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#panel').components().length);\n\t$('#panel').components(function(index) {\n\t\tconsole.log(index, this.path);\n\t});\n});\n</script>\n```\n\n### el.EXEC(name, [args...])\n\nType: `method`\n\nAppelle une méthode sur les composants à l'intérieur de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la méthode, éventuellement avec le préfixe `^`. |\n| `args` | `Object` | no |  | Les arguments de la méthode. |\n\nReturns: `jQuery` Le même élément.\n\nAvec le préfixe `^`, la méthode est appelée sur les composants des éléments parents. Les composants qui n'ont pas cette méthode sont ignorés.\n\nExample: Appeler une méthode\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').EXEC('hello', 'Ann');\n});\n</script>\n```\n\nExample: Appeler une méthode sur les parents\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#inner').EXEC('^hello', 'Bob');\n});\n</script>\n```\n\n### el.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nTrouve des composants à l'intérieur de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur du composant. |\n| `many` | `Boolean` | no |  | Utilise `true` pour obtenir tous les composants correspondants. |\n| `callback` | `Function` | no |  | Reçoit le résultat dès qu'il est disponible. |\n| `timeout` | `Number` | no |  | Le temps d'attente maximal en millisecondes. |\n\nReturns: `Component, Array or jQuery` Le premier composant, ou un tableau avec `many`. Avec `callback`, le même élément.\n\nLe sélecteur peut être un nom de composant, `name[path]`, `.path`, `#id` ou `*`.\n\nAvec `callback`, la méthode attend qu'un composant existe, puis appelle `callback(component)`, le composant étant aussi `this`. Si `timeout` expire avant, le callback n'est pas appelé. Tu peux omettre `many` quand tu passes un callback.\n\nExample: Trouver des composants\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tconsole.log(panel.FIND('counter').path);\n\tconsole.log(panel.FIND('counter', true).length);\n\tconsole.log(panel.FIND('.data.b').path);\n\tconsole.log(panel.FIND('counter[data.b]').path);\n});\n</script>\n```\n\nExample: Attendre un composant\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').FIND('late', function(component) {\n\tconsole.log('found', component.path);\n}, 3000);\n\nCOMPONENT('late', function(self) {});\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.hclass(name)\n\nType: `method`\n\nVérifie si l'élément a une classe.\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```html\n<div id=\"box\" class=\"active\"></div>\n\n<script>\n$('#box').hclass('active'); // true\n$('#box').hclass('missing'); // false\n</script>\n```\n\n### el.multiple(selectors)\n\nType: `method`\n\nExécute plusieurs appels à `find()` et renvoie les résultats sous leurs noms.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Les noms et les sélecteurs. |\n\nReturns: `Object` Des objets jQuery sous les mêmes noms.\n\nExample: Trouver plusieurs éléments\n```html\n<div id=\"form\"><input id=\"name\"><button>Save</button></div>\n\n<script>\nvar ui = $('#form').multiple({ name: 'input', save: 'button' });\n\nui.name.attr('id'); // \"name\"\nui.save.text(); // \"Save\"\n</script>\n```\n\n### el.plugin()\n\nType: `method`\n\nRenvoie le plugin qui contient l'élément.\n\nReturns: `Plugin` Le plugin, ou `undefined`.\n\nVoir [Plugin](../plugin/).\n\nExample: Accéder à un plugin\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n\texports.total = function() {\n\t\treturn 3;\n\t};\n});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').plugin().total());\n}, 500);\n</script>\n```\n\n### el.psvg(tag)\n\nType: `method`\n\nAjoute un élément SVG au début de l'élément.\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\nElle fonctionne comme [asvg()](#asvg), et le nouveau contenu est placé en premier.\n\nExample: Ajouter un élément SVG au début\n```html\n<svg id=\"chart\"><circle r=\"5\"></circle></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.psvg('text').attr('x', 1);\nsvg.children()[0].nodeName; // \"text\"\n</script>\n```\n\n### el.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` Le même élément.\n\nExample: Supprimer un attribut\n```html\n<div id=\"box\" title=\"Hello\"></div>\n\n<script>\n$('#box').rattr('title').attr('title'); // undefined\n</script>\n```\n\n### el.rattrd(name, [name2], ...)\n\nType: `method`\n\nSupprime un ou plusieurs attributs `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Les noms des attributs sans le préfixe `data-`. |\n\nReturns: `jQuery` Le même élément.\n\nExample: Supprimer des attributs de données\n```html\n<div id=\"box\" data-a=\"1\" data-b=\"2\" data-c=\"3\"></div>\n\n<script>\nvar el = $('#box').rattrd('a', 'b');\n\nel.attr('data-a'); // undefined\nel.attr('data-b'); // undefined\nel.attr('data-c'); // \"3\"\n</script>\n```\n\n### el.rclass([name], [delay])\n\nType: `method`\n\nSupprime des classes, immédiatement ou après un délai.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Les noms de classes, séparés par des espaces. |\n| `delay` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `jQuery` Le même élément.\n\nSans nom, toutes les classes sont supprimées. Les appels retardés partagent un seul minuteur par élément : un nouvel appel retardé à `aclass()`, `rclass()` ou `rclass2()` annule donc celui qui est encore en attente.\n\nExample: Supprimer des classes\n```html\n<div id=\"box\" class=\"a b c\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass('a').attr('class'); // \"b c\"\nel.rclass().attr('class'); // \"\"\n</script>\n```\n\n### el.rclass2(search, [delay])\n\nType: `method`\n\nSupprime les classes qui contiennent un texte ou correspondent à une expression régulière.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Le texte à rechercher, ou une expression régulière. |\n| `delay` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `jQuery` Le même élément.\n\nLes appels retardés partagent un seul minuteur par élément : un nouvel appel retardé à `aclass()`, `rclass()` ou `rclass2()` annule donc celui qui est encore en attente.\n\nExample: Supprimer selon un motif\n```html\n<div id=\"box\" class=\"size-1 size-2 color-red ok\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass2('size-').attr('class'); // \"color-red ok\"\nel.rclass2(/^color/).attr('class'); // \"ok\"\n</script>\n```\n\n### el.RECONFIGURE(selector, value)\n\nType: `method`\n\nModifie la configuration des composants à l'intérieur de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le sélecteur du composant. |\n| `value` | `String or Object` | yes |  | La nouvelle configuration. |\n\nReturns: `jQuery` Le même élément.\n\nLe sélecteur a les mêmes formes que dans [FIND()](#find).\n\nExample: Reconfigurer des composants\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', 'step:1', function(self) {});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tpanel.RECONFIGURE('counter', 'step:5');\n\tconsole.log(panel.FIND('counter').config.step);\n\tpanel.RECONFIGURE('counter', { step: 9 });\n\tconsole.log(panel.FIND('counter').config.step);\n});\n</script>\n```\n\n### el.scope()\n\nType: `method`\n\nRenvoie le scope qui contient l'élément.\n\nReturns: `Scope` Le scope. En dehors d'un scope, le résultat est vide.\n\nConsulte [Scope](../scope/).\n\nExample: Lire le path du scope\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').scope().path);\n}, 500);\n</script>\n```\n\n### el.SETTER([wait], selector, method, [args...])\n\nType: `method`\n\nAppelle une méthode sur les composants à l'intérieur de l'élément qui correspondent à un sélecteur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Utilise `true` pour attendre le composant. |\n| `selector` | `String` | yes |  | Le sélecteur du composant. |\n| `method` | `String` | yes |  | Le nom de la méthode. |\n| `args` | `Object` | no |  | Les arguments de la méthode. |\n\nReturns: `jQuery` Le même élément.\n\nLe sélecteur a les mêmes formes que dans [FIND()](#find). La méthode peut être un nom imbriqué comme `nested.run`, et elle peut aussi faire partie du sélecteur sous la forme `selector/method`. Avec `true` comme premier argument, l'appel attend qu'un composant correspondant existe.\n\nExample: Appeler les composants correspondants\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').SETTER('counter', 'hello', 'Ann');\n\t$('#panel').SETTER('.data.b/hello', 'Bob');\n});\n</script>\n```\n\nExample: Attendre un composant\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').SETTER(true, 'late', 'hello', 'Ann');\n\nCOMPONENT('late', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('hello', name);\n\t};\n});\n\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.tclass(name, [state])\n\nType: `method`\n\nBascule une classe.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la classe. |\n| `state` | `Boolean` | no |  | `true` ajoute la classe et `false` la retire. |\n\nReturns: `jQuery` Le même élément.\n\nExample: Basculer une classe\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\n\nel.tclass('open').hclass('open'); // true\nel.tclass('open').hclass('open'); // false\nel.tclass('open', true).hclass('open'); // true\n</script>\n```\n\n### el.vbind()\n\nType: `method`\n\nRenvoie le binder virtuel d'un élément créé par `VBINDARRAY()`.\n\nReturns: `Object` Le binder de l'élément de la liste, ou `null`.\n\nL'élément peut être l'élément de la liste ou un élément situé à l'intérieur. Consulte [Binder virtuel](../vbinder/).\n\nExample: Lire le binder de l'élément de la liste\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }, { name: 'Bob' }]);\n\n$('#list b').last().vbind().index; // 1\n</script>\n```\n\n### el.vbindarray()\n\nType: `method`\n\nRenvoie l'objet créé par `VBINDARRAY()` pour l'élément ou son parent le plus proche.\n\nReturns: `Object` Le tableau de binders virtuels, ou `null`.\n\nConsulte [Binder virtuel](../vbinder/).\n\nExample: Lire le binder du tableau\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }]);\n\n$('#list b').vbindarray() === list; // true\n</script>\n```\n\n### $.components\n\nType: `property`\n\nUne référence à l'objet global `M`.\n\nConsulte [M](../m/).\n\nExample: Le même objet\n```js\n$.components === M; // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"el.aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"el.asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"el.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"el.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"el.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"el.binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"el.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"el.component()","since":"","deprecated":false},{"type":"method","name":"components()","signature":"el.components([fn])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"el.EXEC(name, [args...])","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"el.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"el.hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"el.multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"el.plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"el.psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"el.rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"el.rattrd(name, [name2], ...)","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"el.rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"el.rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"el.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"el.scope()","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"el.SETTER([wait], selector, method, [args...])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"el.tclass(name, [state])","since":"","deprecated":false},{"type":"method","name":"vbind()","signature":"el.vbind()","since":"","deprecated":false},{"type":"method","name":"vbindarray()","signature":"el.vbindarray()","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammeB4wj61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/jquery/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"it","title":"Estensioni di jQuery","summary":"Metodi che jComponent aggiunge a jQuery per lavorare con classi, attributi, SVG, componenti e scope.","markdown":"---\ntitle: Estensioni di jQuery\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/reference/jquery/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Estensioni di jQuery\n\n> Metodi che jComponent aggiunge a jQuery per lavorare con classi, attributi, SVG, componenti e scope.\n\njComponent include jQuery e aggiunge questi metodi a `$.fn`, quindi funzionano su ogni oggetto jQuery. La pagina [Componente](../component/) descrive gli oggetti restituiti dai metodi dei componenti e [Uso dei componenti](../../guides/using-components/) spiega come si dichiarano i componenti.\n\n## API\n\n### el.aclass(name, [delay])\n\nType: `method`\n\nAggiunge una o più classi, subito o dopo un ritardo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | I nomi delle classi, separati da spazi. |\n| `delay` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nLe chiamate ritardate condividono un solo timer per elemento, quindi una nuova chiamata ritardata di `aclass()`, `rclass()` o `rclass2()` annulla quella ancora in attesa.\n\nExample: Aggiungi una classe\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\nel.aclass('active');\nel.hclass('active'); // true\n\nel.aclass('later', 50);\nel.hclass('later'); // false\n\nsetTimeout(function() {\n\tconsole.log(el.hclass('later'));\n}, 100);\n</script>\n```\n\n### el.asvg(tag)\n\nType: `method`\n\nAggiunge un elemento SVG all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nome di tag o markup SVG. |\n\nReturns: `jQuery` Il nuovo elemento, quando `tag` è un nome di tag.\n\nUn nome di tag crea un elemento nel namespace SVG e lo restituisce. Un testo con markup aggiunge tutti i suoi elementi; usa un nome di tag quando ti serve il nuovo elemento in seguito.\n\nExample: Aggiungi elementi SVG\n```html\n<svg id=\"chart\"></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.asvg('circle').attr('r', 5);\nsvg.asvg('<rect width=\"3\"/><line/>');\n\nsvg.children().length; // 3\nsvg.children()[0].namespaceURI; // \"http://www.w3.org/2000/svg\"\n</script>\n```\n\n### el.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 il prefisso `data-`. |\n| `value` | `Object` | no |  | Il nuovo valore. |\n\nReturns: `String or jQuery` Il valore in lettura, lo stesso elemento in scrittura.\n\nExample: Attributi data\n```html\n<div id=\"box\" data-id=\"7\"></div>\n\n<script>\nvar el = $('#box');\n\nel.attrd('id'); // \"7\"\nel.attrd('name', 'Ann');\nel.attr('data-name'); // \"Ann\"\n</script>\n```\n\n### el.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 il prefisso `data-`. |\n\nReturns: `String` Il valore, oppure `undefined`.\n\nExample: Eredita un valore\n```html\n<div data-id=\"7\"><span id=\"child\"></span></div>\n\n<script>\n$('#child').attrd2('id'); // \"7\"\n$('#child').attrd2('missing'); // undefined\n</script>\n```\n\n### el.autofocus([selector])\n\nType: `method`\n\nSposta il focus sul primo campo visibile dentro l'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `'input,select,textarea'` | I campi da cercare. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nQuando nessun campo può ricevere il focus, il metodo riprova ogni 200 millisecondi, fino a 15 volte. Sui dispositivi mobili non fa nulla.\n\nExample: Dai il focus a un form\n```html\n<div id=\"form\">\n\t<input id=\"hidden\" style=\"display:none\">\n\t<input id=\"name\">\n\t<textarea id=\"note\"></textarea>\n</div>\n\n<script>\n$('#form').autofocus();\ndocument.activeElement.id; // \"name\"\n\n$('#form').autofocus('textarea');\ndocument.activeElement.id; // \"note\"\n</script>\n```\n\n### el.binder()\n\nType: `method`\n\nRestituisce il binder dell'elemento o del genitore più vicino.\n\nReturns: `Object` Il binder, oppure `null`.\n\nVedi [ui-bind](../ui-bind/).\n\nExample: Leggi un binder\n```html\n<ui-bind path=\"user.name\" config=\"show\"><span id=\"label\"></span></ui-bind>\n\n<script>\nsetTimeout(function() {\n\tconsole.log($('#label').binder().path);\n}, 500);\n</script>\n```\n\n### el.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nEsegue un comando in tutti i componenti dentro l'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n| `a` | `Object` | no |  | Il primo di un massimo di cinque argomenti per il comando. |\n\nI componenti registrano i comandi con `self.command()`. Vedi [Componente](../component/).\n\nExample: Esegui un comando\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.make = function() {\n\t\tself.command('reset', function(value) {\n\t\t\tconsole.log(self.path, value);\n\t\t});\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').CMD('reset', 0);\n});\n</script>\n```\n\n### el.component()\n\nType: `method`\n\nRestituisce il componente dell'elemento o del genitore più vicino.\n\nReturns: `Component` Il componente, oppure `null`.\n\nExample: Trova il componente padre\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#inner').component().path);\n});\n</script>\n```\n\n### el.components([fn])\n\nType: `method`\n\nElenca o percorre i componenti pronti dentro l'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | no |  | Chiamata per ogni componente. |\n\nReturns: `Array or jQuery` Senza `fn`, un array di componenti, oppure `null` quando non ce ne sono. Con `fn`, gli elementi dei componenti.\n\nCon `fn`, la funzione viene chiamata con il componente come `this` e la posizione del suo elemento come argomento.\n\nExample: Percorri i componenti\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#panel').components().length);\n\t$('#panel').components(function(index) {\n\t\tconsole.log(index, this.path);\n\t});\n});\n</script>\n```\n\n### el.EXEC(name, [args...])\n\nType: `method`\n\nChiama un metodo sui componenti dentro l'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del metodo, eventualmente con il prefisso `^`. |\n| `args` | `Object` | no |  | Gli argomenti del metodo. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nCon il prefisso `^`, il metodo viene chiamato sui componenti degli elementi genitori. I componenti privi del metodo vengono saltati.\n\nExample: Chiama un metodo\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').EXEC('hello', 'Ann');\n});\n</script>\n```\n\nExample: Chiama un metodo sui genitori\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#inner').EXEC('^hello', 'Bob');\n});\n</script>\n```\n\n### el.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nTrova i componenti dentro l'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore del componente. |\n| `many` | `Boolean` | no |  | Usa `true` per ottenere tutti i componenti corrispondenti. |\n| `callback` | `Function` | no |  | Riceve il risultato quando è disponibile. |\n| `timeout` | `Number` | no |  | Il tempo massimo di attesa in millisecondi. |\n\nReturns: `Component, Array or jQuery` Il primo componente, oppure un array con `many`. Con `callback`, lo stesso elemento.\n\nIl selettore può essere un nome di componente, `name[path]`, `.path`, `#id` o `*`.\n\nCon `callback`, il metodo attende che esista un componente e poi chiama `callback(component)`, con il componente anche come `this`. Se `timeout` scade prima, il callback non viene chiamato. Puoi omettere `many` quando passi un callback.\n\nExample: Trova i componenti\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tconsole.log(panel.FIND('counter').path);\n\tconsole.log(panel.FIND('counter', true).length);\n\tconsole.log(panel.FIND('.data.b').path);\n\tconsole.log(panel.FIND('counter[data.b]').path);\n});\n</script>\n```\n\nExample: Attendi un componente\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').FIND('late', function(component) {\n\tconsole.log('found', component.path);\n}, 3000);\n\nCOMPONENT('late', function(self) {});\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.hclass(name)\n\nType: `method`\n\nControlla se l'elemento ha una classe.\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: Controlla una classe\n```html\n<div id=\"box\" class=\"active\"></div>\n\n<script>\n$('#box').hclass('active'); // true\n$('#box').hclass('missing'); // false\n</script>\n```\n\n### el.multiple(selectors)\n\nType: `method`\n\nEsegue più chiamate di `find()` e restituisce i risultati sotto i rispettivi nomi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Nomi e selettori. |\n\nReturns: `Object` Oggetti jQuery sotto gli stessi nomi.\n\nExample: Trova più elementi\n```html\n<div id=\"form\"><input id=\"name\"><button>Save</button></div>\n\n<script>\nvar ui = $('#form').multiple({ name: 'input', save: 'button' });\n\nui.name.attr('id'); // \"name\"\nui.save.text(); // \"Save\"\n</script>\n```\n\n### el.plugin()\n\nType: `method`\n\nRestituisce il plugin che contiene l'elemento.\n\nReturns: `Plugin` Il plugin, oppure `undefined`.\n\nVedi [Plugin](../plugin/).\n\nExample: Raggiungi un plugin\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n\texports.total = function() {\n\t\treturn 3;\n\t};\n});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').plugin().total());\n}, 500);\n</script>\n```\n\n### el.psvg(tag)\n\nType: `method`\n\nAntepone un elemento SVG all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nome di tag o markup SVG. |\n\nReturns: `jQuery` Il nuovo elemento, quando `tag` è un nome di tag.\n\nFunziona come [asvg()](#asvg), ma il nuovo contenuto viene inserito per primo.\n\nExample: Anteponi un elemento SVG\n```html\n<svg id=\"chart\"><circle r=\"5\"></circle></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.psvg('text').attr('x', 1);\nsvg.children()[0].nodeName; // \"text\"\n</script>\n```\n\n### el.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` Lo stesso elemento.\n\nExample: Rimuovi un attributo\n```html\n<div id=\"box\" title=\"Hello\"></div>\n\n<script>\n$('#box').rattr('title').attr('title'); // undefined\n</script>\n```\n\n### el.rattrd(name, [name2], ...)\n\nType: `method`\n\nRimuove uno o più attributi `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | I nomi degli attributi senza il prefisso `data-`. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nExample: Rimuovi gli attributi data\n```html\n<div id=\"box\" data-a=\"1\" data-b=\"2\" data-c=\"3\"></div>\n\n<script>\nvar el = $('#box').rattrd('a', 'b');\n\nel.attr('data-a'); // undefined\nel.attr('data-b'); // undefined\nel.attr('data-c'); // \"3\"\n</script>\n```\n\n### el.rclass([name], [delay])\n\nType: `method`\n\nRimuove le classi, subito o dopo un ritardo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | I nomi delle classi, separati da spazi. |\n| `delay` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nSenza un nome, vengono rimosse tutte le classi. Le chiamate ritardate condividono un solo timer per elemento, quindi una nuova chiamata ritardata di `aclass()`, `rclass()` o `rclass2()` annulla quella ancora in attesa.\n\nExample: Rimuovi le classi\n```html\n<div id=\"box\" class=\"a b c\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass('a').attr('class'); // \"b c\"\nel.rclass().attr('class'); // \"\"\n</script>\n```\n\n### el.rclass2(search, [delay])\n\nType: `method`\n\nRimuove le classi che contengono un testo o corrispondono a un'espressione regolare.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Il testo da cercare o un'espressione regolare. |\n| `delay` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nLe chiamate ritardate condividono un solo timer per elemento, quindi una nuova chiamata ritardata di `aclass()`, `rclass()` o `rclass2()` annulla quella ancora in attesa.\n\nExample: Rimuovi in base a un modello\n```html\n<div id=\"box\" class=\"size-1 size-2 color-red ok\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass2('size-').attr('class'); // \"color-red ok\"\nel.rclass2(/^color/).attr('class'); // \"ok\"\n</script>\n```\n\n### el.RECONFIGURE(selector, value)\n\nType: `method`\n\nCambia la configurazione dei componenti dentro l'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il selettore del componente. |\n| `value` | `String or Object` | yes |  | La nuova configurazione. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nIl selettore ha le stesse forme di [FIND()](#find).\n\nExample: Riconfigura i componenti\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', 'step:1', function(self) {});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tpanel.RECONFIGURE('counter', 'step:5');\n\tconsole.log(panel.FIND('counter').config.step);\n\tpanel.RECONFIGURE('counter', { step: 9 });\n\tconsole.log(panel.FIND('counter').config.step);\n});\n</script>\n```\n\n### el.scope()\n\nType: `method`\n\nRestituisce lo scope che contiene l'elemento.\n\nReturns: `Scope` Lo scope. Fuori da uno scope, il risultato è vuoto.\n\nVedi [Scope](../scope/).\n\nExample: Leggi il path dello scope\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').scope().path);\n}, 500);\n</script>\n```\n\n### el.SETTER([wait], selector, method, [args...])\n\nType: `method`\n\nChiama un metodo sui componenti dentro l'elemento che corrispondono a un selettore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Usa `true` per attendere il componente. |\n| `selector` | `String` | yes |  | Il selettore del componente. |\n| `method` | `String` | yes |  | Il nome del metodo. |\n| `args` | `Object` | no |  | Gli argomenti del metodo. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nIl selettore ha le stesse forme di [FIND()](#find). Il metodo può essere un nome annidato come `nested.run` e può anche far parte del selettore come `selector/method`. Con `true` come primo argomento, la chiamata attende che esista un componente corrispondente.\n\nExample: Chiama i componenti corrispondenti\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').SETTER('counter', 'hello', 'Ann');\n\t$('#panel').SETTER('.data.b/hello', 'Bob');\n});\n</script>\n```\n\nExample: Attendi un componente\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').SETTER(true, 'late', 'hello', 'Ann');\n\nCOMPONENT('late', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('hello', name);\n\t};\n});\n\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.tclass(name, [state])\n\nType: `method`\n\nAttiva o disattiva una classe.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome della classe. |\n| `state` | `Boolean` | no |  | `true` aggiunge la classe e `false` la rimuove. |\n\nReturns: `jQuery` Lo stesso elemento.\n\nExample: Attiva o disattiva una classe\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\n\nel.tclass('open').hclass('open'); // true\nel.tclass('open').hclass('open'); // false\nel.tclass('open', true).hclass('open'); // true\n</script>\n```\n\n### el.vbind()\n\nType: `method`\n\nRestituisce il binder virtuale di un elemento creato da `VBINDARRAY()`.\n\nReturns: `Object` Il binder della voce, oppure `null`.\n\nL'elemento può essere la voce stessa o un elemento al suo interno. Vedi [Binder virtuale](../vbinder/).\n\nExample: Leggi il binder della voce\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }, { name: 'Bob' }]);\n\n$('#list b').last().vbind().index; // 1\n</script>\n```\n\n### el.vbindarray()\n\nType: `method`\n\nRestituisce l'oggetto creato da `VBINDARRAY()` per l'elemento o per il genitore più vicino.\n\nReturns: `Object` L'array di binder virtuali, oppure `null`.\n\nVedi [Binder virtuale](../vbinder/).\n\nExample: Leggi il binder dell'array\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }]);\n\n$('#list b').vbindarray() === list; // true\n</script>\n```\n\n### $.components\n\nType: `property`\n\nUn riferimento all'oggetto globale `M`.\n\nVedi [M](../m/).\n\nExample: Lo stesso oggetto\n```js\n$.components === M; // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"el.aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"el.asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"el.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"el.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"el.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"el.binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"el.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"el.component()","since":"","deprecated":false},{"type":"method","name":"components()","signature":"el.components([fn])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"el.EXEC(name, [args...])","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"el.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"el.hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"el.multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"el.plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"el.psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"el.rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"el.rattrd(name, [name2], ...)","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"el.rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"el.rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"el.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"el.scope()","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"el.SETTER([wait], selector, method, [args...])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"el.tclass(name, [state])","since":"","deprecated":false},{"type":"method","name":"vbind()","signature":"el.vbind()","since":"","deprecated":false},{"type":"method","name":"vbindarray()","signature":"el.vbindarray()","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammeB4wj61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/jquery/","project":"jcomponent-v19","version":"19-194","section":"reference","language":"sk","title":"Rozšírenia jQuery","summary":"Metódy, ktoré jComponent pridáva do jQuery na prácu s triedami, atribútmi, SVG, komponentmi a scopmi.","markdown":"---\ntitle: \"Rozšírenia jQuery\"\nproject: jComponent V19\nversion: 19.194\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/jquery/\nupdated: 2026-11-18T13:58:29.465Z\n---\n\n# Rozšírenia jQuery\n\n> Metódy, ktoré jComponent pridáva do jQuery na prácu s triedami, atribútmi, SVG, komponentmi a scopmi.\n\njComponent obsahuje jQuery a pridáva tieto metódy do `$.fn`, takže fungujú na každom objekte jQuery. Objekty vrátené metódami komponentov popisuje stránka [Komponent](../component/) a deklarovanie komponentov vysvetľuje časť [Používanie komponentov](../../guides/using-components/).\n\n## API\n\n### el.aclass(name, [delay])\n\nType: `method`\n\nPridá jednu alebo viac tried, okamžite alebo s oneskorením.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názvy tried oddelené medzerami. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `jQuery` Ten istý element.\n\nOneskorené volania zdieľajú jeden časovač na element, takže nové oneskorené volanie `aclass()`, `rclass()` alebo `rclass2()` zruší to, ktoré ešte čaká.\n\nExample: Pridaj triedu\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\nel.aclass('active');\nel.hclass('active'); // true\n\nel.aclass('later', 50);\nel.hclass('later'); // false\n\nsetTimeout(function() {\n\tconsole.log(el.hclass('later'));\n}, 100);\n</script>\n```\n\n### el.asvg(tag)\n\nType: `method`\n\nPripojí k elementu element SVG.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Názov značky alebo značkovanie SVG. |\n\nReturns: `jQuery` Nový element, keď je `tag` názov značky.\n\nNázov značky vytvorí jeden element v mennom priestore SVG a vráti ho. Text so značkami pripojí všetky svoje elementy; ak nový element potrebuješ aj potom, použi názov značky.\n\nExample: Pripoj elementy SVG\n```html\n<svg id=\"chart\"></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.asvg('circle').attr('r', 5);\nsvg.asvg('<rect width=\"3\"/><line/>');\n\nsvg.children().length; // 3\nsvg.children()[0].namespaceURI; // \"http://www.w3.org/2000/svg\"\n</script>\n```\n\n### el.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 prefixu `data-`. |\n| `value` | `Object` | no |  | Nová hodnota. |\n\nReturns: `String or jQuery` Pri čítaní hodnota, pri zápise ten istý element.\n\nExample: Atribúty data\n```html\n<div id=\"box\" data-id=\"7\"></div>\n\n<script>\nvar el = $('#box');\n\nel.attrd('id'); // \"7\"\nel.attrd('name', 'Ann');\nel.attr('data-name'); // \"Ann\"\n</script>\n```\n\n### el.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 prefixu `data-`. |\n\nReturns: `String` Hodnota alebo `undefined`.\n\nExample: Zdeď hodnotu\n```html\n<div data-id=\"7\"><span id=\"child\"></span></div>\n\n<script>\n$('#child').attrd2('id'); // \"7\"\n$('#child').attrd2('missing'); // undefined\n</script>\n```\n\n### el.autofocus([selector])\n\nType: `method`\n\nPresunie fokus na prvé viditeľné pole vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `'input,select,textarea'` | Polia, ktoré sa majú hľadať. |\n\nReturns: `jQuery` Ten istý element.\n\nKeď žiadne pole nemôže prijať fokus, metóda to skúša znova každých 200 milisekúnd, najviac 15-krát. Na mobilných zariadeniach nerobí nič.\n\nExample: Presuň fokus na formulár\n```html\n<div id=\"form\">\n\t<input id=\"hidden\" style=\"display:none\">\n\t<input id=\"name\">\n\t<textarea id=\"note\"></textarea>\n</div>\n\n<script>\n$('#form').autofocus();\ndocument.activeElement.id; // \"name\"\n\n$('#form').autofocus('textarea');\ndocument.activeElement.id; // \"note\"\n</script>\n```\n\n### el.binder()\n\nType: `method`\n\nVráti binder elementu alebo jeho najbližšieho nadradeného elementu.\n\nReturns: `Object` Binder alebo `null`.\n\nPozri [ui-bind](../ui-bind/).\n\nExample: Prečítaj binder\n```html\n<ui-bind path=\"user.name\" config=\"show\"><span id=\"label\"></span></ui-bind>\n\n<script>\nsetTimeout(function() {\n\tconsole.log($('#label').binder().path);\n}, 500);\n</script>\n```\n\n### el.CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nSpustí príkaz vo všetkých komponentoch vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov príkazu. |\n| `a` | `Object` | no |  | Prvý z najviac piatich argumentov príkazu. |\n\nKomponenty registrujú príkazy pomocou `self.command()`. Pozri [Komponent](../component/).\n\nExample: Spusti príkaz\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.make = function() {\n\t\tself.command('reset', function(value) {\n\t\t\tconsole.log(self.path, value);\n\t\t});\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').CMD('reset', 0);\n});\n</script>\n```\n\n### el.component()\n\nType: `method`\n\nVráti komponent elementu alebo jeho najbližšieho nadradeného elementu.\n\nReturns: `Component` Komponent alebo `null`.\n\nExample: Nájdi nadradený komponent\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#inner').component().path);\n});\n</script>\n```\n\n### el.components([fn])\n\nType: `method`\n\nVypíše alebo prejde pripravené komponenty vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | no |  | Zavolá sa pre každý komponent. |\n\nReturns: `Array or jQuery` Bez `fn` pole komponentov, alebo `null`, keď žiadne nie sú. S `fn` elementy komponentov.\n\nS `fn` sa funkcia zavolá s komponentom ako `this` a s pozíciou jeho elementu ako argumentom.\n\nExample: Prejdi komponenty\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tconsole.log($('#panel').components().length);\n\t$('#panel').components(function(index) {\n\t\tconsole.log(index, this.path);\n\t});\n});\n</script>\n```\n\n### el.EXEC(name, [args...])\n\nType: `method`\n\nZavolá metódu komponentov vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov metódy, voliteľne s predponou `^`. |\n| `args` | `Object` | no |  | Argumenty metódy. |\n\nReturns: `jQuery` Ten istý element.\n\nS predponou `^` sa metóda zavolá na komponentoch v nadradených elementoch. Komponenty bez tejto metódy sa preskočia.\n\nExample: Zavolaj metódu\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').EXEC('hello', 'Ann');\n});\n</script>\n```\n\nExample: Zavolaj metódu na nadradených komponentoch\n```html\n<ui-component name=\"counter\" path=\"data.a\"><b id=\"inner\"></b></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#inner').EXEC('^hello', 'Bob');\n});\n</script>\n```\n\n### el.FIND(selector, [many], [callback], [timeout])\n\nType: `method`\n\nNájde komponenty vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor komponentu. |\n| `many` | `Boolean` | no |  | Ak chceš získať všetky zodpovedajúce komponenty, použi `true`. |\n| `callback` | `Function` | no |  | Dostane výsledok, keď je dostupný. |\n| `timeout` | `Number` | no |  | Maximálny čas čakania v milisekundách. |\n\nReturns: `Component, Array or jQuery` Prvý komponent, alebo pole s `many`. S `callback` ten istý element.\n\nSelektor môže byť názov komponentu, `name[path]`, `.path`, `#id` alebo `*`.\n\nS `callback` metóda počká, kým komponent nebude existovať, a potom zavolá `callback(component)`, pričom komponent je aj `this`. Keď najprv uplynie `timeout`, callback sa nezavolá. Keď odovzdáš callback, môžeš `many` vynechať.\n\nExample: Nájdi komponenty\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tconsole.log(panel.FIND('counter').path);\n\tconsole.log(panel.FIND('counter', true).length);\n\tconsole.log(panel.FIND('.data.b').path);\n\tconsole.log(panel.FIND('counter[data.b]').path);\n});\n</script>\n```\n\nExample: Počkaj na komponent\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').FIND('late', function(component) {\n\tconsole.log('found', component.path);\n}, 3000);\n\nCOMPONENT('late', function(self) {});\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.hclass(name)\n\nType: `method`\n\nSkontroluje, či má element triedu.\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: Skontroluj triedu\n```html\n<div id=\"box\" class=\"active\"></div>\n\n<script>\n$('#box').hclass('active'); // true\n$('#box').hclass('missing'); // false\n</script>\n```\n\n### el.multiple(selectors)\n\nType: `method`\n\nSpustí niekoľko volaní `find()` a vráti výsledky pod ich názvami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Názvy a selektory. |\n\nReturns: `Object` Objekty jQuery pod rovnakými názvami.\n\nExample: Nájdi viacero elementov\n```html\n<div id=\"form\"><input id=\"name\"><button>Save</button></div>\n\n<script>\nvar ui = $('#form').multiple({ name: 'input', save: 'button' });\n\nui.name.attr('id'); // \"name\"\nui.save.text(); // \"Save\"\n</script>\n```\n\n### el.plugin()\n\nType: `method`\n\nVráti plugin, ktorý obsahuje element.\n\nReturns: `Plugin` Plugin alebo `undefined`.\n\nPozri [Plugin](../plugin/).\n\nExample: Získaj plugin\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n\texports.total = function() {\n\t\treturn 3;\n\t};\n});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').plugin().total());\n}, 500);\n</script>\n```\n\n### el.psvg(tag)\n\nType: `method`\n\nVloží element SVG na začiatok elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Názov značky alebo značkovanie SVG. |\n\nReturns: `jQuery` Nový element, keď je `tag` názov značky.\n\nFunguje ako [asvg()](#asvg) a nový obsah ide na začiatok.\n\nExample: Vlož element SVG na začiatok\n```html\n<svg id=\"chart\"><circle r=\"5\"></circle></svg>\n\n<script>\nvar svg = $('#chart');\n\nsvg.psvg('text').attr('x', 1);\nsvg.children()[0].nodeName; // \"text\"\n</script>\n```\n\n### el.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ý element.\n\nExample: Odstráň atribút\n```html\n<div id=\"box\" title=\"Hello\"></div>\n\n<script>\n$('#box').rattr('title').attr('title'); // undefined\n</script>\n```\n\n### el.rattrd(name, [name2], ...)\n\nType: `method`\n\nOdstráni jeden alebo viac atribútov `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názvy atribútov bez predpony `data-`. |\n\nReturns: `jQuery` Ten istý element.\n\nExample: Odstráň atribúty data\n```html\n<div id=\"box\" data-a=\"1\" data-b=\"2\" data-c=\"3\"></div>\n\n<script>\nvar el = $('#box').rattrd('a', 'b');\n\nel.attr('data-a'); // undefined\nel.attr('data-b'); // undefined\nel.attr('data-c'); // \"3\"\n</script>\n```\n\n### el.rclass([name], [delay])\n\nType: `method`\n\nOdstráni triedy, okamžite alebo s oneskorením.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Názvy tried oddelené medzerami. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `jQuery` Ten istý element.\n\nBez názvu sa odstránia všetky triedy. Oneskorené volania zdieľajú jeden časovač na element, takže nové oneskorené volanie `aclass()`, `rclass()` alebo `rclass2()` zruší to, ktoré ešte čaká.\n\nExample: Odstráň triedy\n```html\n<div id=\"box\" class=\"a b c\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass('a').attr('class'); // \"b c\"\nel.rclass().attr('class'); // \"\"\n</script>\n```\n\n### el.rclass2(search, [delay])\n\nType: `method`\n\nOdstráni triedy, ktoré obsahujú zadaný text alebo zodpovedajú regulárnemu výrazu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Hľadaný text alebo regulárny výraz. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `jQuery` Ten istý element.\n\nOneskorené volania zdieľajú jeden časovač na element, takže nové oneskorené volanie `aclass()`, `rclass()` alebo `rclass2()` zruší to, ktoré ešte čaká.\n\nExample: Odstráň podľa vzoru\n```html\n<div id=\"box\" class=\"size-1 size-2 color-red ok\"></div>\n\n<script>\nvar el = $('#box');\n\nel.rclass2('size-').attr('class'); // \"color-red ok\"\nel.rclass2(/^color/).attr('class'); // \"ok\"\n</script>\n```\n\n### el.RECONFIGURE(selector, value)\n\nType: `method`\n\nZmení konfiguráciu komponentov vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor komponentu. |\n| `value` | `String or Object` | yes |  | Nová konfigurácia. |\n\nReturns: `jQuery` Ten istý element.\n\nSelektor má rovnaké tvary ako vo [FIND()](#find).\n\nExample: Prekonfiguruj komponenty\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', 'step:1', function(self) {});\n\nON('ready', function() {\n\tvar panel = $('#panel');\n\tpanel.RECONFIGURE('counter', 'step:5');\n\tconsole.log(panel.FIND('counter').config.step);\n\tpanel.RECONFIGURE('counter', { step: 9 });\n\tconsole.log(panel.FIND('counter').config.step);\n});\n</script>\n```\n\n### el.scope()\n\nType: `method`\n\nVráti scope, ktorý obsahuje element.\n\nReturns: `Scope` Scope. Mimo scopu je výsledok prázdny.\n\nPozri [Scope](../scope/).\n\nExample: Prečítaj path scopu\n```html\n<ui-plugin path=\"orders\"><div id=\"inner\"></div></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nsetTimeout(function() {\n\tconsole.log($('#inner').scope().path);\n}, 500);\n</script>\n```\n\n### el.SETTER([wait], selector, method, [args...])\n\nType: `method`\n\nZavolá metódu komponentov vnútri elementu, ktoré zodpovedajú selektoru.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `wait` | `Boolean` | no |  | Ak chceš počkať na komponent, použi `true`. |\n| `selector` | `String` | yes |  | Selektor komponentu. |\n| `method` | `String` | yes |  | Názov metódy. |\n| `args` | `Object` | no |  | Argumenty metódy. |\n\nReturns: `jQuery` Ten istý element.\n\nSelektor má rovnaké tvary ako vo [FIND()](#find). Metóda môže byť vnorený názov, napríklad `nested.run`, a môže byť aj súčasťou selektora ako `selector/method`. S `true` ako prvým argumentom volanie počká, kým zodpovedajúci komponent nebude existovať.\n\nExample: Zavolaj zodpovedajúce komponenty\n```html\n<div id=\"panel\">\n\t<ui-component name=\"counter\" path=\"data.a\"></ui-component>\n\t<ui-component name=\"counter\" path=\"data.b\"></ui-component>\n</div>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log(self.path, 'hello', name);\n\t};\n});\n\nON('ready', function() {\n\t$('#panel').SETTER('counter', 'hello', 'Ann');\n\t$('#panel').SETTER('.data.b/hello', 'Bob');\n});\n</script>\n```\n\nExample: Počkaj na komponent\n```html\n<div id=\"panel\"></div>\n\n<script>\n$('#panel').SETTER(true, 'late', 'hello', 'Ann');\n\nCOMPONENT('late', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('hello', name);\n\t};\n});\n\n$('#panel').append('<ui-component name=\"late\" path=\"data.late\"></ui-component>');\nCOMPILE();\n</script>\n```\n\n### el.tclass(name, [state])\n\nType: `method`\n\nPrepne triedu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov triedy. |\n| `state` | `Boolean` | no |  | `true` triedu pridá a `false` ju odstráni. |\n\nReturns: `jQuery` Ten istý element.\n\nExample: Prepni triedu\n```html\n<div id=\"box\"></div>\n\n<script>\nvar el = $('#box');\n\nel.tclass('open').hclass('open'); // true\nel.tclass('open').hclass('open'); // false\nel.tclass('open', true).hclass('open'); // true\n</script>\n```\n\n### el.vbind()\n\nType: `method`\n\nVráti virtuálny binder položky vytvorenej pomocou `VBINDARRAY()`.\n\nReturns: `Object` Binder položky alebo `null`.\n\nElement môže byť položka alebo element vnútri nej. Pozri [Virtuálny binder](../vbinder/).\n\nExample: Prečítaj binder položky\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }, { name: 'Bob' }]);\n\n$('#list b').last().vbind().index; // 1\n</script>\n```\n\n### el.vbindarray()\n\nType: `method`\n\nVráti objekt vytvorený pomocou `VBINDARRAY()` pre element alebo jeho najbližší nadradený element.\n\nReturns: `Object` Pole virtuálnych binderov alebo `null`.\n\nPozri [Virtuálny binder](../vbinder/).\n\nExample: Prečítaj binder poľa\n```html\n<div id=\"list\"></div>\n\n<script>\nvar list = VBINDARRAY('<div><b data-bind=\"name__text\"></b></div>', $('#list'));\nlist.set([{ name: 'Ann' }]);\n\n$('#list b').vbindarray() === list; // true\n</script>\n```\n\n### $.components\n\nType: `property`\n\nOdkaz na globálny objekt `M`.\n\nPozri [M](../m/).\n\nExample: Ten istý objekt\n```js\n$.components === M; // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"el.aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"el.asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"el.attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"el.attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"el.autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"el.binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"el.CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"el.component()","since":"","deprecated":false},{"type":"method","name":"components()","signature":"el.components([fn])","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"el.EXEC(name, [args...])","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"el.FIND(selector, [many], [callback], [timeout])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"el.hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"el.multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"el.plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"el.psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"el.rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"el.rattrd(name, [name2], ...)","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"el.rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"el.rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"RECONFIGURE()","signature":"el.RECONFIGURE(selector, value)","since":"","deprecated":false},{"type":"method","name":"scope()","signature":"el.scope()","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"el.SETTER([wait], selector, method, [args...])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"el.tclass(name, [state])","since":"","deprecated":false},{"type":"method","name":"vbind()","signature":"el.vbind()","since":"","deprecated":false},{"type":"method","name":"vbindarray()","signature":"el.vbindarray()","since":"","deprecated":false},{"type":"property","name":"$.components","signature":"$.components","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:29.465Z"}
{"id":"JammTN1cM61f","url":"https://totaljs.es/docs/jcomponent-v19/19-194/faq/faq/","project":"jcomponent-v19","version":"19-194","section":"faq","language":"en","title":"FAQ","summary":"Answers to the questions developers ask most often when they start with jComponent.","markdown":"---\ntitle: FAQ\nproject: jComponent V19\nversion: 19.194\nsection: faq\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v19/19-194/faq/faq/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# FAQ\n\n> Answers to the questions developers ask most often 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## Do I need a build step?\n\nNo. jComponent is a script that you include in the page. The published build also contains jQuery, the Tangular template engine and the routing. See [Getting started](../../guides/getting-started/).\n\n## Why does the page not change when I assign a value to a variable?\n\nA plain assignment does not tell the library that anything happened. Use `SET()`, or call `UPD()` after you change the object yourself:\n\n```html\n<script>\n    var user = { name: 'Peter' };\n</script>\n\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n\n<script>\n    user.name = 'Lucia';       // The page still shows Peter\n    UPD('user.name');          // The page shows Lucia\n    SET('user.name', 'Anna');  // The page shows Anna\n</script>\n```\n\nSee [Paths](../../guides/paths/) and [Data binding](../../guides/data-binding/).\n\n## How do I run code when a value changes?\n\nUse `WATCH()`. The callback receives the path, the value and the type of the change:\n\n```js\nWATCH('cart.total', function(path, value, type) {\n    console.log(path, value);\n});\n\nSET('cart.total', 5); // cart.total 5\n```\n\nSee [Data binding](../../guides/data-binding/).\n\n## Why does FIND() return nothing when my script starts?\n\nComponents are created after the scripts of the page have run. On a page with components, wait for the `ready` event:\n\n```js\nON('ready', function() {\n    var component = FIND('hello');\n});\n```\n\nSee [Using components](../../guides/using-components/) and the [events reference](../../reference/events/).\n\n## When should I use a component, a plugin or a macro?\n\n- A [component](../../guides/creating-components/) is a reusable piece of interface, such as an input or a grid.\n- A [plugin](../../guides/plugins/) holds the data and logic of a part of the application, such as a page or a form.\n- A [macro](../../guides/macros/) adds a small behaviour to a single `<ui-bind>` element.\n\n## What does the question mark in a path mean?\n\nInside `<ui-plugin>`, `?` stands for the path of the plugin. With the plugin `orders`, `?.items` is `orders.items` and `?/refresh` is the method `refresh` of the plugin. See [Scopes](../../guides/scopes/).\n\n## How do I call a plugin method from HTML?\n\nAdd the class `exec` and name the method in `data-exec`:\n\n```html\n<ui-plugin path=\"counter\">\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nFrom JavaScript, use `EXEC('counter/increment')`. See [Plugins](../../guides/plugins/).\n\n## How do I render a list from an array?\n\nUse the `template` command of `<ui-bind>` with a Tangular loop. The list is rendered again when the array changes:\n\n```html\n<script>\n    var products = [{ name: 'Keyboard' }, { name: 'Mouse' }];\n</script>\n\n<ui-bind path=\"products\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach item in value }}<li>{{ item.name }}</li>{{ end }}\n    </script>\n</ui-bind>\n```\n\n`PUSH('products', { name: 'Monitor' })` adds a third item to the page. See [Templates with Tangular](../../guides/tangular/).\n\n## Are values in templates safe against HTML injection?\n\n`{{ value }}` is encoded. A command with a helper is not encoded unless you add the `encode` helper at the end, as in `{{ value | upper | encode }}`, and `raw` writes the value as it is. See [Templates with Tangular](../../guides/tangular/).\n\n## How do I load part of a page on demand?\n\nUse `IMPORT('/parts/form.html', '#target')` from code or `<ui-import config=\"url:/parts/form.html\">` in the markup. See [Importing content](../../guides/importing/).\n\n## Why did the script of an imported file run only once?\n\n`<ui-import>` removes scripts and styles when the same address is imported again. Add `reevaluate:true` to the `config` attribute if each copy has to run its script. See [Importing content](../../guides/importing/).\n\n## How do I show a \"page not found\" screen?\n\nListen to the `404` event, which is emitted when no route matches the address:\n\n```js\nON('404', function() {\n    SET('common.page', 'notfound');\n});\n```\n\nSee [Routing](../../guides/routing/).\n\n## Why is my route never called?\n\nCheck the case and the number of segments. Addresses are compared in lowercase, so `ROUTE('/Admin/', fn)` never matches. Write it as `ROUTE('/admin/', fn)`. See [Routing](../../guides/routing/).\n\n## How do I protect a route?\n\nDeclare a middleware with `MIDDLEWARE()`, name it in the route, and call `next(false)` to stop the navigation. See [Routing](../../guides/routing/).\n\n## Why is my required field marked invalid on a fresh form?\n\nAn empty required field is invalid from the start, so it has the `ui-invalid` class right away. Combine the classes in your CSS to show the error only after the user has touched the field:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\nSee [Forms and validation](../../guides/forms/).\n\n## Why is my save button still disabled when the form is valid?\n\n`CAN()` needs a valid form **and** at least one field the user has changed. Use `VALID()` if you only care about validity. See [Forms and validation](../../guides/forms/).\n\n## Why is the text in my HTML not translated?\n\n`@(text)` is translated in component configuration, in `<ui-bind>` templates and in imported content. Static HTML of the page stays as it is. See [Localization](../../guides/localization/).\n\n## How do I change the date and number formats?\n\nSet `DEF.dateformat`, `DEF.thousandsseparator` and `DEF.decimalseparator` when the application starts. See [Localization](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTN1cM61f-de","url":"https://totaljs.es/docs/de/jcomponent-v19/19-194/faq/faq/","project":"jcomponent-v19","version":"19-194","section":"faq","language":"de","title":"FAQ","summary":"Antworten auf die Fragen, die Entwickler beim Einstieg in jComponent am häufigsten stellen.","markdown":"---\ntitle: FAQ\nproject: jComponent V19\nversion: 19.194\nsection: faq\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v19/19-194/faq/faq/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# FAQ\n\n> Antworten auf die Fragen, die Entwickler beim Einstieg in jComponent am häufigsten stellen.\n\nKurze Antworten auf die Fragen, die als Erstes auftauchen. Jede Antwort verweist auf die Seite, die das Thema ausführlich erklärt.\n\n## Brauche ich einen Build-Schritt?\n\nNein. jComponent ist ein Skript, das du in die Seite einbindest. Der veröffentlichte Build enthält auch jQuery, die Template-Engine Tangular und das Routing. Siehe [Erste Schritte](../../guides/getting-started/).\n\n## Warum ändert sich die Seite nicht, wenn ich einer Variablen einen Wert zuweise?\n\nEine einfache Zuweisung teilt der Bibliothek nicht mit, dass etwas passiert ist. Verwende `SET()` oder rufe `UPD()` auf, nachdem du das Objekt selbst geändert hast:\n\n```html\n<script>\n    var user = { name: 'Peter' };\n</script>\n\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n\n<script>\n    user.name = 'Lucia';       // The page still shows Peter\n    UPD('user.name');          // The page shows Lucia\n    SET('user.name', 'Anna');  // The page shows Anna\n</script>\n```\n\nSiehe [Paths](../../guides/paths/) und [Datenbindung](../../guides/data-binding/).\n\n## Wie führe ich Code aus, wenn sich ein Wert ändert?\n\nVerwende `WATCH()`. Der Callback erhält den Path, den Wert und den Typ der Änderung:\n\n```js\nWATCH('cart.total', function(path, value, type) {\n    console.log(path, value);\n});\n\nSET('cart.total', 5); // cart.total 5\n```\n\nSiehe [Datenbindung](../../guides/data-binding/).\n\n## Warum liefert FIND() nichts, wenn mein Skript startet?\n\nKomponenten werden erstellt, nachdem die Skripte der Seite gelaufen sind. Warte auf einer Seite mit Komponenten auf das Event `ready`:\n\n```js\nON('ready', function() {\n    var component = FIND('hello');\n});\n```\n\nSiehe [Komponenten verwenden](../../guides/using-components/) und die [Event-Referenz](../../reference/events/).\n\n## Wann sollte ich eine Komponente, ein Plugin oder ein Macro verwenden?\n\n- Eine [Komponente](../../guides/creating-components/) ist ein wiederverwendbarer Teil der Oberfläche, etwa ein Eingabefeld oder ein Grid.\n- Ein [Plugin](../../guides/plugins/) enthält die Daten und die Logik eines Teils der Anwendung, etwa einer Seite oder eines Formulars.\n- Ein [Macro](../../guides/macros/) ergänzt ein einzelnes `<ui-bind>`-Element um ein kleines Verhalten.\n\n## Was bedeutet das Fragezeichen in einem Path?\n\nInnerhalb von `<ui-plugin>` steht `?` für den Path des Plugins. Beim Plugin `orders` ist `?.items` gleich `orders.items` und `?/refresh` die Methode `refresh` des Plugins. Siehe [Scopes](../../guides/scopes/).\n\n## Wie rufe ich eine Plugin-Methode aus HTML auf?\n\nFüge die Klasse `exec` hinzu und nenne die Methode in `data-exec`:\n\n```html\n<ui-plugin path=\"counter\">\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nAus JavaScript verwendest du `EXEC('counter/increment')`. Siehe [Plugins](../../guides/plugins/).\n\n## Wie rendere ich eine Liste aus einem Array?\n\nVerwende den Befehl `template` von `<ui-bind>` mit einer Tangular-Schleife. Die Liste wird neu gerendert, wenn sich das Array ändert:\n\n```html\n<script>\n    var products = [{ name: 'Keyboard' }, { name: 'Mouse' }];\n</script>\n\n<ui-bind path=\"products\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach item in value }}<li>{{ item.name }}</li>{{ end }}\n    </script>\n</ui-bind>\n```\n\n`PUSH('products', { name: 'Monitor' })` fügt der Seite einen dritten Eintrag hinzu. Siehe [Templates mit Tangular](../../guides/tangular/).\n\n## Sind Werte in Templates vor HTML-Injection geschützt?\n\n`{{ value }}` wird kodiert. Ein Befehl mit einem Helper wird nicht kodiert, es sei denn, du fügst am Ende den Helper `encode` hinzu, wie in `{{ value | upper | encode }}`, und `raw` schreibt den Wert unverändert. Siehe [Templates mit Tangular](../../guides/tangular/).\n\n## Wie lade ich einen Teil einer Seite bei Bedarf?\n\nVerwende `IMPORT('/parts/form.html', '#target')` im Code oder `<ui-import config=\"url:/parts/form.html\">` im Markup. Siehe [Inhalte importieren](../../guides/importing/).\n\n## Warum lief das Skript einer importierten Datei nur einmal?\n\n`<ui-import>` entfernt Skripte und Styles, wenn dieselbe Adresse erneut importiert wird. Füge dem Attribut `config` den Wert `reevaluate:true` hinzu, wenn jede Kopie ihr Skript ausführen soll. Siehe [Inhalte importieren](../../guides/importing/).\n\n## Wie zeige ich einen Bildschirm \"Seite nicht gefunden\" an?\n\nLausche auf das Event `404`, das ausgelöst wird, wenn keine Route zur Adresse passt:\n\n```js\nON('404', function() {\n    SET('common.page', 'notfound');\n});\n```\n\nSiehe [Routing](../../guides/routing/).\n\n## Warum wird meine Route nie aufgerufen?\n\nPrüfe die Groß- und Kleinschreibung und die Anzahl der Segmente. Adressen werden in Kleinbuchstaben verglichen, daher passt `ROUTE('/Admin/', fn)` nie. Schreibe stattdessen `ROUTE('/admin/', fn)`. Siehe [Routing](../../guides/routing/).\n\n## Wie schütze ich eine Route?\n\nDeklariere eine Middleware mit `MIDDLEWARE()`, nenne sie in der Route und rufe `next(false)` auf, um die Navigation zu stoppen. Siehe [Routing](../../guides/routing/).\n\n## Warum ist mein Pflichtfeld in einem neuen Formular als ungültig markiert?\n\nEin leeres Pflichtfeld ist von Anfang an ungültig und hat daher sofort die Klasse `ui-invalid`. Kombiniere die Klassen in deinem CSS, damit der Fehler erst erscheint, nachdem das Feld berührt wurde:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\nSiehe [Formulare und Validierung](../../guides/forms/).\n\n## Warum ist mein Speichern-Button deaktiviert, obwohl das Formular gültig ist?\n\n`CAN()` braucht ein gültiges Formular **und** mindestens ein vom Benutzer geändertes Feld. Verwende `VALID()`, wenn es dir nur um die Gültigkeit geht. Siehe [Formulare und Validierung](../../guides/forms/).\n\n## Warum wird der Text in meinem HTML nicht übersetzt?\n\n`@(text)` wird in der Komponentenkonfiguration, in `<ui-bind>`-Templates und in importierten Inhalten übersetzt. Statisches HTML der Seite bleibt unverändert. Siehe [Lokalisierung](../../guides/localization/).\n\n## Wie ändere ich die Datums- und Zahlenformate?\n\nSetze `DEF.dateformat`, `DEF.thousandsseparator` und `DEF.decimalseparator` beim Start der Anwendung. Siehe [Lokalisierung](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTN1cM61f-es","url":"https://totaljs.es/docs/es/jcomponent-v19/19-194/faq/faq/","project":"jcomponent-v19","version":"19-194","section":"faq","language":"es","title":"Preguntas frecuentes","summary":"Respuestas a las preguntas más habituales de quienes empiezan con jComponent.","markdown":"---\ntitle: Preguntas frecuentes\nproject: jComponent V19\nversion: 19.194\nsection: faq\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v19/19-194/faq/faq/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Preguntas frecuentes\n\n> Respuestas a las preguntas más habituales de quienes empiezan con jComponent.\n\nRespuestas breves a las primeras preguntas que surgen. Cada respuesta enlaza con la página que explica el tema a fondo.\n\n## ¿Necesito un paso de compilación?\n\nNo. jComponent es un script que incluyes en la página. La versión publicada también contiene jQuery, el motor de plantillas Tangular y el enrutamiento. Consulta [Primeros pasos](../../guides/getting-started/).\n\n## ¿Por qué no cambia la página cuando asigno un valor a una variable?\n\nUna asignación simple no le dice a la biblioteca que haya ocurrido algo. Usa `SET()`, o llama a `UPD()` después de cambiar tú mismo el objeto:\n\n```html\n<script>\n    var user = { name: 'Peter' };\n</script>\n\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n\n<script>\n    user.name = 'Lucia';       // The page still shows Peter\n    UPD('user.name');          // The page shows Lucia\n    SET('user.name', 'Anna');  // The page shows Anna\n</script>\n```\n\nConsulta [Paths](../../guides/paths/) y [Enlace de datos](../../guides/data-binding/).\n\n## ¿Cómo ejecuto código cuando cambia un valor?\n\nUsa `WATCH()`. El callback recibe el path, el valor y el tipo de cambio:\n\n```js\nWATCH('cart.total', function(path, value, type) {\n    console.log(path, value);\n});\n\nSET('cart.total', 5); // cart.total 5\n```\n\nConsulta [Enlace de datos](../../guides/data-binding/).\n\n## ¿Por qué FIND() no devuelve nada cuando arranca mi script?\n\nLos componentes se crean después de que se ejecuten los scripts de la página. En una página con componentes, espera al evento `ready`:\n\n```js\nON('ready', function() {\n    var component = FIND('hello');\n});\n```\n\nConsulta [Usar componentes](../../guides/using-components/) y la [referencia de eventos](../../reference/events/).\n\n## ¿Cuándo debo usar un componente, un plugin o una macro?\n\n- Un [componente](../../guides/creating-components/) es una pieza reutilizable de la interfaz, como un input o una tabla.\n- Un [plugin](../../guides/plugins/) contiene los datos y la lógica de una parte de la aplicación, como una página o un formulario.\n- Una [macro](../../guides/macros/) añade un pequeño comportamiento a un único elemento `<ui-bind>`.\n\n## ¿Qué significa el signo de interrogación en un path?\n\nDentro de `<ui-plugin>`, `?` representa el path del plugin. Con el plugin `orders`, `?.items` es `orders.items` y `?/refresh` es el método `refresh` del plugin. Consulta [Scopes](../../guides/scopes/).\n\n## ¿Cómo llamo a un método de un plugin desde HTML?\n\nAñade la clase `exec` e indica el método en `data-exec`:\n\n```html\n<ui-plugin path=\"counter\">\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nDesde JavaScript, usa `EXEC('counter/increment')`. Consulta [Plugins](../../guides/plugins/).\n\n## ¿Cómo renderizo una lista a partir de un array?\n\nUsa el comando `template` de `<ui-bind>` con un bucle de Tangular. La lista se vuelve a renderizar cuando cambia el array:\n\n```html\n<script>\n    var products = [{ name: 'Keyboard' }, { name: 'Mouse' }];\n</script>\n\n<ui-bind path=\"products\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach item in value }}<li>{{ item.name }}</li>{{ end }}\n    </script>\n</ui-bind>\n```\n\n`PUSH('products', { name: 'Monitor' })` añade un tercer ítem a la página. Consulta [Plantillas con Tangular](../../guides/tangular/).\n\n## ¿Los valores de las plantillas están protegidos contra la inyección de HTML?\n\n`{{ value }}` se codifica. Un comando con un helper no se codifica salvo que añadas el helper `encode` al final, como en `{{ value | upper | encode }}`, y `raw` escribe el valor tal cual. Consulta [Plantillas con Tangular](../../guides/tangular/).\n\n## ¿Cómo cargo una parte de una página bajo demanda?\n\nUsa `IMPORT('/parts/form.html', '#target')` desde el código o `<ui-import config=\"url:/parts/form.html\">` en el marcado. Consulta [Importar contenido](../../guides/importing/).\n\n## ¿Por qué el script de un archivo importado se ejecutó solo una vez?\n\n`<ui-import>` elimina los scripts y los estilos cuando se vuelve a importar la misma dirección. Añade `reevaluate:true` al atributo `config` si cada copia tiene que ejecutar su script. Consulta [Importar contenido](../../guides/importing/).\n\n## ¿Cómo muestro una pantalla de «página no encontrada»?\n\nEscucha el evento `404`, que se emite cuando ninguna ruta coincide con la dirección:\n\n```js\nON('404', function() {\n    SET('common.page', 'notfound');\n});\n```\n\nConsulta [Enrutamiento](../../guides/routing/).\n\n## ¿Por qué nunca se llama a mi ruta?\n\nComprueba las mayúsculas y minúsculas y el número de segmentos. Las direcciones se comparan en minúsculas, así que `ROUTE('/Admin/', fn)` nunca coincide. Escríbela como `ROUTE('/admin/', fn)`. Consulta [Enrutamiento](../../guides/routing/).\n\n## ¿Cómo protejo una ruta?\n\nDeclara un middleware con `MIDDLEWARE()`, indícalo en la ruta y llama a `next(false)` para detener la navegación. Consulta [Enrutamiento](../../guides/routing/).\n\n## ¿Por qué mi campo obligatorio aparece como inválido en un formulario recién abierto?\n\nUn campo obligatorio vacío es inválido desde el principio, así que tiene la clase `ui-invalid` desde el primer momento. Combina las clases en tu CSS para mostrar el error solo después de que el usuario haya tocado el campo:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\nConsulta [Formularios y validación](../../guides/forms/).\n\n## ¿Por qué mi botón de guardar sigue desactivado cuando el formulario es válido?\n\n`CAN()` necesita un formulario válido **y** al menos un campo que el usuario haya cambiado. Usa `VALID()` si solo te importa la validez. Consulta [Formularios y validación](../../guides/forms/).\n\n## ¿Por qué no se traduce el texto de mi HTML?\n\n`@(text)` se traduce en la configuración de los componentes, en las plantillas de `<ui-bind>` y en el contenido importado. El HTML estático de la página se queda como está. Consulta [Localización](../../guides/localization/).\n\n## ¿Cómo cambio los formatos de fecha y de número?\n\nDefine `DEF.dateformat`, `DEF.thousandsseparator` y `DEF.decimalseparator` cuando arranque la aplicación. Consulta [Localización](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTN1cM61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v19/19-194/faq/faq/","project":"jcomponent-v19","version":"19-194","section":"faq","language":"fr","title":"FAQ","summary":"Les réponses aux questions que les développeurs posent le plus souvent quand ils débutent avec jComponent.","markdown":"---\ntitle: FAQ\nproject: jComponent V19\nversion: 19.194\nsection: faq\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v19/19-194/faq/faq/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# FAQ\n\n> Les réponses aux questions que les développeurs posent le plus souvent quand ils débutent avec jComponent.\n\nDes réponses courtes aux premières questions qui se posent. Chaque réponse renvoie vers la page qui explique le sujet en détail.\n\n## Ai-je besoin d'une étape de build ?\n\nNon. jComponent est un script que tu inclus dans la page. Le build publié contient aussi jQuery, le moteur de modèles Tangular et le routage. Consulte [Bien démarrer](../../guides/getting-started/).\n\n## Pourquoi la page ne change-t-elle pas quand j'assigne une valeur à une variable ?\n\nUne simple assignation ne signale rien à la bibliothèque. Utilise `SET()`, ou appelle `UPD()` après avoir modifié l'objet toi-même :\n\n```html\n<script>\n    var user = { name: 'Peter' };\n</script>\n\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n\n<script>\n    user.name = 'Lucia';       // The page still shows Peter\n    UPD('user.name');          // The page shows Lucia\n    SET('user.name', 'Anna');  // The page shows Anna\n</script>\n```\n\nConsulte [Paths](../../guides/paths/) et [Liaison de données](../../guides/data-binding/).\n\n## Comment exécuter du code quand une valeur change ?\n\nUtilise `WATCH()`. Le callback reçoit le path, la valeur et le type de la modification :\n\n```js\nWATCH('cart.total', function(path, value, type) {\n    console.log(path, value);\n});\n\nSET('cart.total', 5); // cart.total 5\n```\n\nConsulte [Liaison de données](../../guides/data-binding/).\n\n## Pourquoi FIND() ne renvoie-t-il rien au démarrage de mon script ?\n\nLes composants sont créés après l'exécution des scripts de la page. Sur une page avec des composants, attends l'événement `ready` :\n\n```js\nON('ready', function() {\n    var component = FIND('hello');\n});\n```\n\nConsulte [Utiliser les composants](../../guides/using-components/) et la [référence des événements](../../reference/events/).\n\n## Quand utiliser un composant, un plugin ou une macro ?\n\n- Un [composant](../../guides/creating-components/) est un élément d'interface réutilisable, comme un champ de saisie ou une grille.\n- Un [plugin](../../guides/plugins/) contient les données et la logique d'une partie de l'application, comme une page ou un formulaire.\n- Une [macro](../../guides/macros/) ajoute un petit comportement à un seul élément `<ui-bind>`.\n\n## Que signifie le point d'interrogation dans un path ?\n\nÀ l'intérieur de `<ui-plugin>`, `?` représente le path du plugin. Avec le plugin `orders`, `?.items` correspond à `orders.items` et `?/refresh` à la méthode `refresh` du plugin. Consulte [Scopes](../../guides/scopes/).\n\n## Comment appeler une méthode de plugin depuis le HTML ?\n\nAjoute la classe `exec` et indique le nom de la méthode dans `data-exec` :\n\n```html\n<ui-plugin path=\"counter\">\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nDepuis JavaScript, utilise `EXEC('counter/increment')`. Consulte [Plugins](../../guides/plugins/).\n\n## Comment afficher une liste à partir d'un tableau ?\n\nUtilise la commande `template` de `<ui-bind>` avec une boucle Tangular. La liste est de nouveau rendue quand le tableau change :\n\n```html\n<script>\n    var products = [{ name: 'Keyboard' }, { name: 'Mouse' }];\n</script>\n\n<ui-bind path=\"products\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach item in value }}<li>{{ item.name }}</li>{{ end }}\n    </script>\n</ui-bind>\n```\n\n`PUSH('products', { name: 'Monitor' })` ajoute un troisième élément à la page. Consulte [Modèles avec Tangular](../../guides/tangular/).\n\n## Les valeurs des modèles sont-elles protégées contre l'injection HTML ?\n\n`{{ value }}` est encodé. Une commande avec un helper n'est pas encodée, sauf si tu ajoutes le helper `encode` à la fin, comme dans `{{ value | upper | encode }}`, et `raw` écrit la valeur telle quelle. Consulte [Modèles avec Tangular](../../guides/tangular/).\n\n## Comment charger une partie de page à la demande ?\n\nUtilise `IMPORT('/parts/form.html', '#target')` depuis le code ou `<ui-import config=\"url:/parts/form.html\">` dans le balisage. Consulte [Importer du contenu](../../guides/importing/).\n\n## Pourquoi le script d'un fichier importé ne s'est-il exécuté qu'une seule fois ?\n\n`<ui-import>` supprime les scripts et les styles quand la même adresse est importée de nouveau. Ajoute `reevaluate:true` à l'attribut `config` si chaque copie doit exécuter son script. Consulte [Importer du contenu](../../guides/importing/).\n\n## Comment afficher un écran « page introuvable » ?\n\nÉcoute l'événement `404`, émis quand aucune route ne correspond à l'adresse :\n\n```js\nON('404', function() {\n    SET('common.page', 'notfound');\n});\n```\n\nConsulte [Routage](../../guides/routing/).\n\n## Pourquoi ma route n'est-elle jamais appelée ?\n\nVérifie la casse et le nombre de segments. Les adresses sont comparées en minuscules, donc `ROUTE('/Admin/', fn)` ne correspond jamais. Écris plutôt `ROUTE('/admin/', fn)`. Consulte [Routage](../../guides/routing/).\n\n## Comment protéger une route ?\n\nDéclare un middleware avec `MIDDLEWARE()`, indique son nom dans la route et appelle `next(false)` pour arrêter la navigation. Consulte [Routage](../../guides/routing/).\n\n## Pourquoi mon champ obligatoire est-il marqué comme invalide sur un formulaire vierge ?\n\nUn champ obligatoire vide est invalide dès le départ, il a donc immédiatement la classe `ui-invalid`. Combine les classes dans ton CSS pour n'afficher l'erreur qu'une fois que l'utilisateur a touché le champ :\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\nConsulte [Formulaires et validation](../../guides/forms/).\n\n## Pourquoi mon bouton d'enregistrement reste-t-il désactivé alors que le formulaire est valide ?\n\n`CAN()` exige un formulaire valide **et** au moins un champ modifié par l'utilisateur. Utilise `VALID()` si seule la validité t'intéresse. Consulte [Formulaires et validation](../../guides/forms/).\n\n## Pourquoi le texte de mon HTML n'est-il pas traduit ?\n\n`@(text)` est traduit dans la configuration des composants, dans les modèles `<ui-bind>` et dans le contenu importé. Le HTML statique de la page reste tel quel. Consulte [Localisation](../../guides/localization/).\n\n## Comment changer les formats de date et de nombre ?\n\nDéfinis `DEF.dateformat`, `DEF.thousandsseparator` et `DEF.decimalseparator` au démarrage de l'application. Consulte [Localisation](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTN1cM61f-it","url":"https://totaljs.es/docs/it/jcomponent-v19/19-194/faq/faq/","project":"jcomponent-v19","version":"19-194","section":"faq","language":"it","title":"FAQ","summary":"Risposte alle domande più frequenti di chi inizia a usare jComponent.","markdown":"---\ntitle: FAQ\nproject: jComponent V19\nversion: 19.194\nsection: faq\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v19/19-194/faq/faq/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# FAQ\n\n> Risposte alle domande più frequenti di chi inizia a usare jComponent.\n\nRisposte brevi alle prime domande che emergono. Ogni risposta rimanda alla pagina che tratta l'argomento per esteso.\n\n## Mi serve una fase di build?\n\nNo. jComponent è uno script che includi nella pagina. La build pubblicata contiene anche jQuery, il motore di template Tangular e il routing. Vedi [Primi passi](../../guides/getting-started/).\n\n## Perché la pagina non cambia quando assegno un valore a una variabile?\n\nUna semplice assegnazione non comunica alla libreria che è successo qualcosa. Usa `SET()`, oppure chiama `UPD()` dopo aver modificato tu stesso l'oggetto:\n\n```html\n<script>\n    var user = { name: 'Peter' };\n</script>\n\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n\n<script>\n    user.name = 'Lucia';       // The page still shows Peter\n    UPD('user.name');          // The page shows Lucia\n    SET('user.name', 'Anna');  // The page shows Anna\n</script>\n```\n\nVedi [Path](../../guides/paths/) e [Associazione dei dati](../../guides/data-binding/).\n\n## Come eseguo del codice quando un valore cambia?\n\nUsa `WATCH()`. Il callback riceve il path, il valore e il tipo della modifica:\n\n```js\nWATCH('cart.total', function(path, value, type) {\n    console.log(path, value);\n});\n\nSET('cart.total', 5); // cart.total 5\n```\n\nVedi [Associazione dei dati](../../guides/data-binding/).\n\n## Perché FIND() non restituisce nulla all'avvio del mio script?\n\nI componenti vengono creati dopo l'esecuzione degli script della pagina. In una pagina con componenti, attendi l'evento `ready`:\n\n```js\nON('ready', function() {\n    var component = FIND('hello');\n});\n```\n\nVedi [Uso dei componenti](../../guides/using-components/) e il [riferimento degli eventi](../../reference/events/).\n\n## Quando devo usare un componente, un plugin o una macro?\n\n- Un [componente](../../guides/creating-components/) è una parte riutilizzabile dell'interfaccia, come un input o una griglia.\n- Un [plugin](../../guides/plugins/) contiene i dati e la logica di una parte dell'applicazione, come una pagina o un form.\n- Una [macro](../../guides/macros/) aggiunge un piccolo comportamento a un singolo elemento `<ui-bind>`.\n\n## Che cosa significa il punto interrogativo in un path?\n\nDentro `<ui-plugin>`, `?` rappresenta il path del plugin. Con il plugin `orders`, `?.items` è `orders.items` e `?/refresh` è il metodo `refresh` del plugin. Vedi [Scope](../../guides/scopes/).\n\n## Come chiamo un metodo di un plugin dall'HTML?\n\nAggiungi la classe `exec` e indica il metodo in `data-exec`:\n\n```html\n<ui-plugin path=\"counter\">\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nDa JavaScript, usa `EXEC('counter/increment')`. Vedi [Plugin](../../guides/plugins/).\n\n## Come eseguo il rendering di un elenco a partire da un array?\n\nUsa il comando `template` di `<ui-bind>` con un ciclo Tangular. L'elenco viene renderizzato di nuovo quando l'array cambia:\n\n```html\n<script>\n    var products = [{ name: 'Keyboard' }, { name: 'Mouse' }];\n</script>\n\n<ui-bind path=\"products\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach item in value }}<li>{{ item.name }}</li>{{ end }}\n    </script>\n</ui-bind>\n```\n\n`PUSH('products', { name: 'Monitor' })` aggiunge un terzo elemento alla pagina. Vedi [Template con Tangular](../../guides/tangular/).\n\n## I valori nei template sono protetti dall'iniezione di HTML?\n\n`{{ value }}` viene codificato. Un comando con un helper non viene codificato, a meno che tu non aggiunga l'helper `encode` alla fine, come in `{{ value | upper | encode }}`, e `raw` scrive il valore così com'è. Vedi [Template con Tangular](../../guides/tangular/).\n\n## Come carico una parte di una pagina su richiesta?\n\nUsa `IMPORT('/parts/form.html', '#target')` dal codice oppure `<ui-import config=\"url:/parts/form.html\">` nel markup. Vedi [Importazione dei contenuti](../../guides/importing/).\n\n## Perché lo script di un file importato è stato eseguito una sola volta?\n\n`<ui-import>` rimuove script e stili quando lo stesso indirizzo viene importato di nuovo. Aggiungi `reevaluate:true` all'attributo `config` se ogni copia deve eseguire il proprio script. Vedi [Importazione dei contenuti](../../guides/importing/).\n\n## Come mostro una schermata \"pagina non trovata\"?\n\nResta in ascolto dell'evento `404`, che viene emesso quando nessuna rotta corrisponde all'indirizzo:\n\n```js\nON('404', function() {\n    SET('common.page', 'notfound');\n});\n```\n\nVedi [Routing](../../guides/routing/).\n\n## Perché la mia rotta non viene mai chiamata?\n\nControlla le maiuscole e il numero di segmenti. Gli indirizzi vengono confrontati in minuscolo, quindi `ROUTE('/Admin/', fn)` non corrisponde mai. Scrivila come `ROUTE('/admin/', fn)`. Vedi [Routing](../../guides/routing/).\n\n## Come proteggo una rotta?\n\nDichiara un middleware con `MIDDLEWARE()`, indicalo nella rotta e chiama `next(false)` per interrompere la navigazione. Vedi [Routing](../../guides/routing/).\n\n## Perché il mio campo obbligatorio risulta non valido in un form appena aperto?\n\nUn campo obbligatorio vuoto è non valido fin dall'inizio, quindi ha subito la classe `ui-invalid`. Combina le classi nel tuo CSS per mostrare l'errore solo dopo che l'utente ha toccato il campo:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\nVedi [Form e validazione](../../guides/forms/).\n\n## Perché il mio pulsante di salvataggio resta disabilitato quando il form è valido?\n\n`CAN()` richiede un form valido **e** almeno un campo modificato dall'utente. Usa `VALID()` se ti interessa solo la validità. Vedi [Form e validazione](../../guides/forms/).\n\n## Perché il testo nel mio HTML non viene tradotto?\n\n`@(text)` viene tradotto nella configurazione dei componenti, nei template di `<ui-bind>` e nei contenuti importati. L'HTML statico della pagina resta invariato. Vedi [Localizzazione](../../guides/localization/).\n\n## Come cambio i formati di data e numero?\n\nImposta `DEF.dateformat`, `DEF.thousandsseparator` e `DEF.decimalseparator` all'avvio dell'applicazione. Vedi [Localizzazione](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
{"id":"JammTN1cM61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v19/19-194/faq/faq/","project":"jcomponent-v19","version":"19-194","section":"faq","language":"sk","title":"Časté otázky","summary":"Odpovede na otázky, ktoré si vývojári kladú najčastejšie, keď s jComponent začínajú.","markdown":"---\ntitle: \"Časté otázky\"\nproject: jComponent V19\nversion: 19.194\nsection: faq\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v19/19-194/faq/faq/\nupdated: 2026-11-18T13:55:44.124Z\n---\n\n# Časté otázky\n\n> Odpovede na otázky, ktoré si vývojári kladú najčastejšie, keď s jComponent začínajú.\n\nKrátke odpovede na otázky, ktoré sa objavia ako prvé. Každá odpoveď odkazuje na stránku, ktorá tému vysvetľuje podrobne.\n\n## Potrebujem krok zostavenia?\n\nNie. jComponent je skript, ktorý vložíš do stránky. Zverejnené zostavenie obsahuje aj jQuery, šablónovací nástroj Tangular a smerovanie. Pozri [Začíname](../../guides/getting-started/).\n\n## Prečo sa stránka nezmení, keď priradím hodnotu premennej?\n\nObyčajné priradenie knižnici neoznámi, že sa niečo stalo. Použi `SET()` alebo po vlastnej zmene objektu zavolaj `UPD()`:\n\n```html\n<script>\n    var user = { name: 'Peter' };\n</script>\n\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n\n<script>\n    user.name = 'Lucia';       // The page still shows Peter\n    UPD('user.name');          // The page shows Lucia\n    SET('user.name', 'Anna');  // The page shows Anna\n</script>\n```\n\nPozri [Path](../../guides/paths/) a [Dátová väzba](../../guides/data-binding/).\n\n## Ako spustím kód, keď sa zmení hodnota?\n\nPouži `WATCH()`. Callback dostane path, hodnotu a typ zmeny:\n\n```js\nWATCH('cart.total', function(path, value, type) {\n    console.log(path, value);\n});\n\nSET('cart.total', 5); // cart.total 5\n```\n\nPozri [Dátová väzba](../../guides/data-binding/).\n\n## Prečo FIND() nič nevráti, keď sa spustí môj skript?\n\nKomponenty sa vytvárajú až po spustení skriptov stránky. Na stránke s komponentmi počkaj na udalosť `ready`:\n\n```js\nON('ready', function() {\n    var component = FIND('hello');\n});\n```\n\nPozri [Používanie komponentov](../../guides/using-components/) a [referenciu udalostí](../../reference/events/).\n\n## Kedy mám použiť komponent, plugin alebo macro?\n\n- [Komponent](../../guides/creating-components/) je opakovane použiteľná časť rozhrania, napríklad vstupné pole alebo mriežka.\n- [Plugin](../../guides/plugins/) obsahuje údaje a logiku časti aplikácie, napríklad stránky alebo formulára.\n- [Macro](../../guides/macros/) pridáva drobné správanie jednému elementu `<ui-bind>`.\n\n## Čo znamená otáznik v path?\n\nVnútri `<ui-plugin>` predstavuje `?` path pluginu. Pri plugine `orders` je `?.items` to isté ako `orders.items` a `?/refresh` je metóda `refresh` pluginu. Pozri [Scopy](../../guides/scopes/).\n\n## Ako zavolám metódu pluginu z HTML?\n\nPridaj triedu `exec` a metódu uveď v `data-exec`:\n\n```html\n<ui-plugin path=\"counter\">\n    <button class=\"exec\" data-exec=\"?/increment\">+1</button>\n</ui-plugin>\n```\n\nV JavaScripte použi `EXEC('counter/increment')`. Pozri [Pluginy](../../guides/plugins/).\n\n## Ako vykreslím zoznam z poľa?\n\nPouži príkaz `template` elementu `<ui-bind>` s cyklom Tangular. Zoznam sa znova vykreslí, keď sa pole zmení:\n\n```html\n<script>\n    var products = [{ name: 'Keyboard' }, { name: 'Mouse' }];\n</script>\n\n<ui-bind path=\"products\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach item in value }}<li>{{ item.name }}</li>{{ end }}\n    </script>\n</ui-bind>\n```\n\n`PUSH('products', { name: 'Monitor' })` pridá na stránku tretiu položku. Pozri [Šablóny s Tangular](../../guides/tangular/).\n\n## Sú hodnoty v šablónach chránené pred vložením HTML?\n\n`{{ value }}` sa kóduje. Príkaz s helperom sa nekóduje, pokiaľ na koniec nepridáš helper `encode`, ako v `{{ value | upper | encode }}`, a `raw` zapíše hodnotu tak, ako je. Pozri [Šablóny s Tangular](../../guides/tangular/).\n\n## Ako načítam časť stránky na požiadanie?\n\nV kóde použi `IMPORT('/parts/form.html', '#target')` alebo v značkovaní `<ui-import config=\"url:/parts/form.html\">`. Pozri [Import obsahu](../../guides/importing/).\n\n## Prečo sa skript importovaného súboru spustil iba raz?\n\n`<ui-import>` odstráni skripty a štýly, keď sa tá istá adresa importuje znova. Ak má každá kópia spustiť svoj skript, pridaj do atribútu `config` hodnotu `reevaluate:true`. Pozri [Import obsahu](../../guides/importing/).\n\n## Ako zobrazím obrazovku „stránka sa nenašla“?\n\nPočúvaj udalosť `404`, ktorá sa vyvolá, keď adrese nezodpovedá žiadna trasa:\n\n```js\nON('404', function() {\n    SET('common.page', 'notfound');\n});\n```\n\nPozri [Smerovanie](../../guides/routing/).\n\n## Prečo sa moja trasa nikdy nezavolá?\n\nSkontroluj veľkosť písmen a počet segmentov. Adresy sa porovnávajú malými písmenami, takže `ROUTE('/Admin/', fn)` sa nikdy nezhoduje. Napíš ju ako `ROUTE('/admin/', fn)`. Pozri [Smerovanie](../../guides/routing/).\n\n## Ako ochránim trasu?\n\nDeklaruj middleware pomocou `MIDDLEWARE()`, uveď ho v trase a navigáciu zastav zavolaním `next(false)`. Pozri [Smerovanie](../../guides/routing/).\n\n## Prečo je moje povinné pole na novom formulári označené ako neplatné?\n\nPrázdne povinné pole je neplatné od začiatku, takže má triedu `ui-invalid` hneď. Ak chceš chybu zobraziť až po tom, čo sa používateľ poľa dotkol, skombinuj triedy vo svojom CSS:\n\n```css\n.ui-touched.ui-invalid input { border-color: red; }\n```\n\nPozri [Formuláre a validácia](../../guides/forms/).\n\n## Prečo je moje tlačidlo na uloženie stále zakázané, keď je formulár platný?\n\n`CAN()` potrebuje platný formulár **a** aspoň jedno pole, ktoré používateľ zmenil. Ak ti záleží iba na platnosti, použi `VALID()`. Pozri [Formuláre a validácia](../../guides/forms/).\n\n## Prečo sa text v mojom HTML neprekladá?\n\n`@(text)` sa prekladá v konfigurácii komponentov, v šablónach `<ui-bind>` a v importovanom obsahu. Statické HTML stránky zostáva tak, ako je. Pozri [Lokalizácia](../../guides/localization/).\n\n## Ako zmením formáty dátumov a čísel?\n\nPri štarte aplikácie nastav `DEF.dateformat`, `DEF.thousandsseparator` a `DEF.decimalseparator`. Pozri [Lokalizácia](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:44.124Z"}
