---
title: "Rozšírenia jQuery"
project: jComponent V19
version: 19.194
section: reference
language: sk
license: MIT
url: https://totaljs.es/docs/sk/jcomponent-v19/19-194/reference/jquery/
updated: 2026-11-18T13:58:29.465Z
---

# Rozšírenia jQuery

> Metódy, ktoré jComponent pridáva do jQuery na prácu s triedami, atribútmi, SVG, komponentmi a scopmi.

jComponent 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/).

## API

### el.aclass(name, [delay])

Type: `method`

Pridá jednu alebo viac tried, okamžite alebo s oneskorením.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názvy tried oddelené medzerami. |
| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |

Returns: `jQuery` Ten istý element.

Oneskorené volania zdieľajú jeden časovač na element, takže nové oneskorené volanie `aclass()`, `rclass()` alebo `rclass2()` zruší to, ktoré ešte čaká.

Example: Pridaj triedu
```html
<div id="box"></div>

<script>
var el = $('#box');
el.aclass('active');
el.hclass('active'); // true

el.aclass('later', 50);
el.hclass('later'); // false

setTimeout(function() {
	console.log(el.hclass('later'));
}, 100);
</script>
```

### el.asvg(tag)

Type: `method`

Pripojí k elementu element SVG.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tag` | `String` | yes |  | Názov značky alebo značkovanie SVG. |

Returns: `jQuery` Nový element, keď je `tag` názov značky.

Ná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.

Example: Pripoj elementy SVG
```html
<svg id="chart"></svg>

<script>
var svg = $('#chart');

svg.asvg('circle').attr('r', 5);
svg.asvg('<rect width="3"/><line/>');

svg.children().length; // 3
svg.children()[0].namespaceURI; // "http://www.w3.org/2000/svg"
</script>
```

### el.attrd(name, [value])

Type: `method`

Prečíta alebo zapíše atribút `data-`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov atribútu bez prefixu `data-`. |
| `value` | `Object` | no |  | Nová hodnota. |

Returns: `String or jQuery` Pri čítaní hodnota, pri zápise ten istý element.

Example: Atribúty data
```html
<div id="box" data-id="7"></div>

<script>
var el = $('#box');

el.attrd('id'); // "7"
el.attrd('name', 'Ann');
el.attr('data-name'); // "Ann"
</script>
```

### el.attrd2(name)

Type: `method`

Prečíta atribút `data-` z elementu alebo z jeho najbližšieho nadradeného elementu, ktorý ho má.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov atribútu bez prefixu `data-`. |

Returns: `String` Hodnota alebo `undefined`.

Example: Zdeď hodnotu
```html
<div data-id="7"><span id="child"></span></div>

<script>
$('#child').attrd2('id'); // "7"
$('#child').attrd2('missing'); // undefined
</script>
```

### el.autofocus([selector])

Type: `method`

Presunie fokus na prvé viditeľné pole vnútri elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selector` | `String` | no | `'input,select,textarea'` | Polia, ktoré sa majú hľadať. |

Returns: `jQuery` Ten istý element.

Keď ž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č.

Example: Presuň fokus na formulár
```html
<div id="form">
	<input id="hidden" style="display:none">
	<input id="name">
	<textarea id="note"></textarea>
</div>

<script>
$('#form').autofocus();
document.activeElement.id; // "name"

$('#form').autofocus('textarea');
document.activeElement.id; // "note"
</script>
```

### el.binder()

Type: `method`

Vráti binder elementu alebo jeho najbližšieho nadradeného elementu.

Returns: `Object` Binder alebo `null`.

Pozri [ui-bind](../ui-bind/).

Example: Prečítaj binder
```html
<ui-bind path="user.name" config="show"><span id="label"></span></ui-bind>

<script>
setTimeout(function() {
	console.log($('#label').binder().path);
}, 500);
</script>
```

### el.CMD(name, [a], [b], [c], [d], [e])

Type: `method`

Spustí príkaz vo všetkých komponentoch vnútri elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov príkazu. |
| `a` | `Object` | no |  | Prvý z najviac piatich argumentov príkazu. |

Komponenty registrujú príkazy pomocou `self.command()`. Pozri [Komponent](../component/).

Example: Spusti príkaz
```html
<div id="panel">
	<ui-component name="counter" path="data.a"></ui-component>
	<ui-component name="counter" path="data.b"></ui-component>
</div>

<script>
COMPONENT('counter', function(self) {
	self.make = function() {
		self.command('reset', function(value) {
			console.log(self.path, value);
		});
	};
});

ON('ready', function() {
	$('#panel').CMD('reset', 0);
});
</script>
```

### el.component()

Type: `method`

Vráti komponent elementu alebo jeho najbližšieho nadradeného elementu.

Returns: `Component` Komponent alebo `null`.

Example: Nájdi nadradený komponent
```html
<ui-component name="counter" path="data.a"><b id="inner"></b></ui-component>

<script>
COMPONENT('counter', function(self) {
	self.hello = function(name) {
		console.log(self.path, 'hello', name);
	};
});

ON('ready', function() {
	console.log($('#inner').component().path);
});
</script>
```

### el.components([fn])

Type: `method`

Vypíše alebo prejde pripravené komponenty vnútri elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `fn` | `Function` | no |  | Zavolá sa pre každý komponent. |

Returns: `Array or jQuery` Bez `fn` pole komponentov, alebo `null`, keď žiadne nie sú. S `fn` elementy komponentov.

S `fn` sa funkcia zavolá s komponentom ako `this` a s pozíciou jeho elementu ako argumentom.

Example: Prejdi komponenty
```html
<div id="panel">
	<ui-component name="counter" path="data.a"></ui-component>
	<ui-component name="counter" path="data.b"></ui-component>
</div>

<script>
COMPONENT('counter', function(self) {
	self.hello = function(name) {
		console.log(self.path, 'hello', name);
	};
});

ON('ready', function() {
	console.log($('#panel').components().length);
	$('#panel').components(function(index) {
		console.log(index, this.path);
	});
});
</script>
```

### el.EXEC(name, [args...])

Type: `method`

Zavolá metódu komponentov vnútri elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov metódy, voliteľne s predponou `^`. |
| `args` | `Object` | no |  | Argumenty metódy. |

Returns: `jQuery` Ten istý element.

S predponou `^` sa metóda zavolá na komponentoch v nadradených elementoch. Komponenty bez tejto metódy sa preskočia.

Example: Zavolaj metódu
```html
<div id="panel">
	<ui-component name="counter" path="data.a"></ui-component>
	<ui-component name="counter" path="data.b"></ui-component>
</div>

<script>
COMPONENT('counter', function(self) {
	self.hello = function(name) {
		console.log(self.path, 'hello', name);
	};
});

ON('ready', function() {
	$('#panel').EXEC('hello', 'Ann');
});
</script>
```

Example: Zavolaj metódu na nadradených komponentoch
```html
<ui-component name="counter" path="data.a"><b id="inner"></b></ui-component>

<script>
COMPONENT('counter', function(self) {
	self.hello = function(name) {
		console.log(self.path, 'hello', name);
	};
});

ON('ready', function() {
	$('#inner').EXEC('^hello', 'Bob');
});
</script>
```

### el.FIND(selector, [many], [callback], [timeout])

Type: `method`

Nájde komponenty vnútri elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selector` | `String` | yes |  | Selektor komponentu. |
| `many` | `Boolean` | no |  | Ak chceš získať všetky zodpovedajúce komponenty, použi `true`. |
| `callback` | `Function` | no |  | Dostane výsledok, keď je dostupný. |
| `timeout` | `Number` | no |  | Maximálny čas čakania v milisekundách. |

Returns: `Component, Array or jQuery` Prvý komponent, alebo pole s `many`. S `callback` ten istý element.

Selektor môže byť názov komponentu, `name[path]`, `.path`, `#id` alebo `*`.

S `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ť.

Example: Nájdi komponenty
```html
<div id="panel">
	<ui-component name="counter" path="data.a"></ui-component>
	<ui-component name="counter" path="data.b"></ui-component>
</div>

<script>
COMPONENT('counter', function(self) {
	self.hello = function(name) {
		console.log(self.path, 'hello', name);
	};
});

ON('ready', function() {
	var panel = $('#panel');
	console.log(panel.FIND('counter').path);
	console.log(panel.FIND('counter', true).length);
	console.log(panel.FIND('.data.b').path);
	console.log(panel.FIND('counter[data.b]').path);
});
</script>
```

Example: Počkaj na komponent
```html
<div id="panel"></div>

<script>
$('#panel').FIND('late', function(component) {
	console.log('found', component.path);
}, 3000);

COMPONENT('late', function(self) {});
$('#panel').append('<ui-component name="late" path="data.late"></ui-component>');
COMPILE();
</script>
```

### el.hclass(name)

Type: `method`

Skontroluje, či má element triedu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov triedy. |

Returns: `Boolean` `true`, keď je trieda prítomná.

Example: Skontroluj triedu
```html
<div id="box" class="active"></div>

<script>
$('#box').hclass('active'); // true
$('#box').hclass('missing'); // false
</script>
```

### el.multiple(selectors)

Type: `method`

Spustí niekoľko volaní `find()` a vráti výsledky pod ich názvami.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selectors` | `Object` | yes |  | Názvy a selektory. |

Returns: `Object` Objekty jQuery pod rovnakými názvami.

Example: Nájdi viacero elementov
```html
<div id="form"><input id="name"><button>Save</button></div>

<script>
var ui = $('#form').multiple({ name: 'input', save: 'button' });

ui.name.attr('id'); // "name"
ui.save.text(); // "Save"
</script>
```

### el.plugin()

Type: `method`

Vráti plugin, ktorý obsahuje element.

Returns: `Plugin` Plugin alebo `undefined`.

Pozri [Plugin](../plugin/).

Example: Získaj plugin
```html
<ui-plugin path="orders"><div id="inner"></div></ui-plugin>

<script>
PLUGIN('orders', function(exports) {
	exports.total = function() {
		return 3;
	};
});

setTimeout(function() {
	console.log($('#inner').plugin().total());
}, 500);
</script>
```

### el.psvg(tag)

Type: `method`

Vloží element SVG na začiatok elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `tag` | `String` | yes |  | Názov značky alebo značkovanie SVG. |

Returns: `jQuery` Nový element, keď je `tag` názov značky.

Funguje ako [asvg()](#asvg) a nový obsah ide na začiatok.

Example: Vlož element SVG na začiatok
```html
<svg id="chart"><circle r="5"></circle></svg>

<script>
var svg = $('#chart');

svg.psvg('text').attr('x', 1);
svg.children()[0].nodeName; // "text"
</script>
```

### el.rattr(name)

Type: `method`

Odstráni atribút.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov atribútu. |

Returns: `jQuery` Ten istý element.

Example: Odstráň atribút
```html
<div id="box" title="Hello"></div>

<script>
$('#box').rattr('title').attr('title'); // undefined
</script>
```

### el.rattrd(name, [name2], ...)

Type: `method`

Odstráni jeden alebo viac atribútov `data-`.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názvy atribútov bez predpony `data-`. |

Returns: `jQuery` Ten istý element.

Example: Odstráň atribúty data
```html
<div id="box" data-a="1" data-b="2" data-c="3"></div>

<script>
var el = $('#box').rattrd('a', 'b');

el.attr('data-a'); // undefined
el.attr('data-b'); // undefined
el.attr('data-c'); // "3"
</script>
```

### el.rclass([name], [delay])

Type: `method`

Odstráni triedy, okamžite alebo s oneskorením.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | no |  | Názvy tried oddelené medzerami. |
| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |

Returns: `jQuery` Ten istý element.

Bez 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á.

Example: Odstráň triedy
```html
<div id="box" class="a b c"></div>

<script>
var el = $('#box');

el.rclass('a').attr('class'); // "b c"
el.rclass().attr('class'); // ""
</script>
```

### el.rclass2(search, [delay])

Type: `method`

Odstráni triedy, ktoré obsahujú zadaný text alebo zodpovedajú regulárnemu výrazu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `search` | `String or RegExp` | yes |  | Hľadaný text alebo regulárny výraz. |
| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |

Returns: `jQuery` Ten istý element.

Oneskorené volania zdieľajú jeden časovač na element, takže nové oneskorené volanie `aclass()`, `rclass()` alebo `rclass2()` zruší to, ktoré ešte čaká.

Example: Odstráň podľa vzoru
```html
<div id="box" class="size-1 size-2 color-red ok"></div>

<script>
var el = $('#box');

el.rclass2('size-').attr('class'); // "color-red ok"
el.rclass2(/^color/).attr('class'); // "ok"
</script>
```

### el.RECONFIGURE(selector, value)

Type: `method`

Zmení konfiguráciu komponentov vnútri elementu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `selector` | `String` | yes |  | Selektor komponentu. |
| `value` | `String or Object` | yes |  | Nová konfigurácia. |

Returns: `jQuery` Ten istý element.

Selektor má rovnaké tvary ako vo [FIND()](#find).

Example: Prekonfiguruj komponenty
```html
<div id="panel">
	<ui-component name="counter" path="data.a"></ui-component>
	<ui-component name="counter" path="data.b"></ui-component>
</div>

<script>
COMPONENT('counter', 'step:1', function(self) {});

ON('ready', function() {
	var panel = $('#panel');
	panel.RECONFIGURE('counter', 'step:5');
	console.log(panel.FIND('counter').config.step);
	panel.RECONFIGURE('counter', { step: 9 });
	console.log(panel.FIND('counter').config.step);
});
</script>
```

### el.scope()

Type: `method`

Vráti scope, ktorý obsahuje element.

Returns: `Scope` Scope. Mimo scopu je výsledok prázdny.

Pozri [Scope](../scope/).

Example: Prečítaj path scopu
```html
<ui-plugin path="orders"><div id="inner"></div></ui-plugin>

<script>
PLUGIN('orders', function(exports) {});

setTimeout(function() {
	console.log($('#inner').scope().path);
}, 500);
</script>
```

### el.SETTER([wait], selector, method, [args...])

Type: `method`

Zavolá metódu komponentov vnútri elementu, ktoré zodpovedajú selektoru.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `wait` | `Boolean` | no |  | Ak chceš počkať na komponent, použi `true`. |
| `selector` | `String` | yes |  | Selektor komponentu. |
| `method` | `String` | yes |  | Názov metódy. |
| `args` | `Object` | no |  | Argumenty metódy. |

Returns: `jQuery` Ten istý element.

Selektor 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ť.

Example: Zavolaj zodpovedajúce komponenty
```html
<div id="panel">
	<ui-component name="counter" path="data.a"></ui-component>
	<ui-component name="counter" path="data.b"></ui-component>
</div>

<script>
COMPONENT('counter', function(self) {
	self.hello = function(name) {
		console.log(self.path, 'hello', name);
	};
});

ON('ready', function() {
	$('#panel').SETTER('counter', 'hello', 'Ann');
	$('#panel').SETTER('.data.b/hello', 'Bob');
});
</script>
```

Example: Počkaj na komponent
```html
<div id="panel"></div>

<script>
$('#panel').SETTER(true, 'late', 'hello', 'Ann');

COMPONENT('late', function(self) {
	self.hello = function(name) {
		console.log('hello', name);
	};
});

$('#panel').append('<ui-component name="late" path="data.late"></ui-component>');
COMPILE();
</script>
```

### el.tclass(name, [state])

Type: `method`

Prepne triedu.

| Parameter | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `name` | `String` | yes |  | Názov triedy. |
| `state` | `Boolean` | no |  | `true` triedu pridá a `false` ju odstráni. |

Returns: `jQuery` Ten istý element.

Example: Prepni triedu
```html
<div id="box"></div>

<script>
var el = $('#box');

el.tclass('open').hclass('open'); // true
el.tclass('open').hclass('open'); // false
el.tclass('open', true).hclass('open'); // true
</script>
```

### el.vbind()

Type: `method`

Vráti virtuálny binder položky vytvorenej pomocou `VBINDARRAY()`.

Returns: `Object` Binder položky alebo `null`.

Element môže byť položka alebo element vnútri nej. Pozri [Virtuálny binder](../vbinder/).

Example: Prečítaj binder položky
```html
<div id="list"></div>

<script>
var list = VBINDARRAY('<div><b data-bind="name__text"></b></div>', $('#list'));
list.set([{ name: 'Ann' }, { name: 'Bob' }]);

$('#list b').last().vbind().index; // 1
</script>
```

### el.vbindarray()

Type: `method`

Vráti objekt vytvorený pomocou `VBINDARRAY()` pre element alebo jeho najbližší nadradený element.

Returns: `Object` Pole virtuálnych binderov alebo `null`.

Pozri [Virtuálny binder](../vbinder/).

Example: Prečítaj binder poľa
```html
<div id="list"></div>

<script>
var list = VBINDARRAY('<div><b data-bind="name__text"></b></div>', $('#list'));
list.set([{ name: 'Ann' }]);

$('#list b').vbindarray() === list; // true
</script>
```

### $.components

Type: `property`

Odkaz na globálny objekt `M`.

Pozri [M](../m/).

Example: Ten istý objekt
```js
$.components === M; // true
```
