Spanish Total.js
English
Documentation For AI agents
Contents

Introduction

What jComponent is, the ideas it is built on and what the library includes.

.md GitHub
On this page

jComponent is the client-side UI library of Total.js. You keep the data of your application in plain JavaScript objects, address that data with string paths and connect it to the page with custom HTML elements. When a value changes through the library, every element that depends on it updates itself.

There is no build step. A page needs one script and one stylesheet.

A first look

<p>Hello <ui-bind path="common.user" config="text"></ui-bind></p>
SET('common.user', 'Ana');

// Later, from any place in your code:
setTimeout(function() {
    SET('common.user', 'Peter');
}, 500);

The page shows Hello Ana and, half a second later, Hello Peter. The code never touches the DOM: it writes a value to the path common.user, and the <ui-bind> element that listens to this path renders it.

The building blocks

ConceptWhat it doesGuide
PathA string such as app.user.name that addresses a value in the global window objectPaths
FlagA word such as @change added to a path that changes how an operation behavesFlags and path modifiers
<ui-bind>An element that renders a value of the model into the pageData binding
ComponentA reusable widget that reads a value from a path and can write it backUsing components, Creating components
PluginA block of application logic with its own part of the modelPlugins

How data flows

  1. Your code calls SET(), or a component writes a value that the user entered.
  2. The library stores the value at the path, inside a normal JavaScript object.
  3. The library notifies everything that depends on the path: components, <ui-bind> elements and watchers registered with WATCH().
  4. Each of them updates its own part of the page.

Because the model is a plain object, you can read it at any time, for example app.user.name in the browser console.

What the library includes

The file spa.min@20.js is a single bundle with everything a page needs:

  • jComponent itself
  • jQuery 3.7.1, available as $
  • Tangular, the template engine
  • Routing for single-page applications, with ROUTE(), REDIRECT() and NAV

The file spa.min@20.css contains a CSS reset, a responsive grid and helper classes such as hidden and invisible.

Where to go next

Follow Getting started to build a working page with a custom component and bound data. All functions are listed in the global functions reference.

Made in Europe