ForgeKomponenty
sk

Komponenty

j-HashChange

jComponent 20 · jcomponent@20 component Príklad načítaný s jComponent 20

Komponent zachytáva všetky zmeny pre #hashtag v URL adrese. Pri zmene vygeneruje udalosť hash. Komponent reaguje na skutočné zmeny.

  • singleton

Konfigurácia:

  • delay {Number} oneskorenie pre vysielanie udalosti hash (predvolené: 0)
  • NEW: middleware {String} middleware (oddelený čiarkou) na úvodné vysielanie udalosti hash

Ako zachytiť zmenu hash?

// Global:
ON('hash', function(hash) {
	// @hash {String} - it can be "empty"
});

// Or in the Plugin declaration:
exports.on('hash', function(hash) {

});

Použite ho so <ui-component name="hashchange">. Keď komponent ešte nie je načítaný, jComponent ho stiahne pri prvom použití z adresy v DEF.fallback (predvolene CDN Componentator). Autor: Peter Širka. Zdroj: úložisko komponentov Componentator, licencia MIT.

example.html
<ui-component name="hashchange"></ui-component>

<ui-bind path="currenthash" config="text"></ui-bind>

<script>

	setInterval(() => location.hash = GUID(10), 1000);

	ON('hash', function(hash) {
		SET('currenthash', hash);
	});

</script>