# j-LoadContent

> The component loads a content from the template <script type='text/html'> and appends it into the element. It's a great solution for reusable content. Learn from example.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: a3a08f3b2e76e53c8f767eacfb4702d273c17e4fd37620c5c7eb3084b875ef39
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

The component loads a content from the template `<script type="text/html">` and appends it into the element. It's a great solution for reusable content. Learn from example.


__Configuration__:

- `selector {String}` a jQuery selector (it will use it for entire DOM)
- `wait {Number}` repeats finding of template in entered milliseconds (default: `0`)
- `replace {String}` replaces entered pharses in the form: `find1=replace1,find2=replace2` (default: empty)
- `exec {String}` a link to the `function(element)`, it's executed after the template is loaded

__Good to know__:

- all `SCR` pharses will be replaced to the `script` phrase

Use it with `<ui-component name="loadcontent">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<script type="text/html" id="template">
	<div>AAA PATH CCC</div>
	<ui-bind path="cities" config="template" class="block">
		<SCR type="text/html">
			{{ foreach m in value }}
				<div>{{ m }}</div>
			{{ end }}
		</SCR>
	</ui-bind>
</script>

<ui-component name="loadcontent" config="selector:#template;replace:PATH=111"></ui-component>
<br />
<ui-component name="loadcontent" config="selector:#template;replace:PATH=222"></ui-component>
<br />
<ui-component name="loadcontent" config="selector:#template;replace:PATH=333"></ui-component>
<br />
<ui-component name="loadcontent" config="selector:#template;replace:PATH=444"></ui-component>

<script>
	var cities = ['Bratislava', 'Berlin', 'Barcelona'];
</script>
```
