# j-Navigation

> j-Navigation: a simple navigation component like Tree; easy for customization

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

- a simple navigation component like Tree
- easy for customization
- supports __dark mode__


__Configuration__:

- `exec {String}` a link to the function
- `pk {String}` a primary key (default: `id`) for remembering last state of tree

__Data-source__:

```javascript
[
	{
		id: 1,
		name: 'Text to navigation item',
		title: 'Optional, a title attribute',
		collapsed: true, // only for children, default "false"
		children: [
			// Can contain same structure as the parent
		]
	}
]
```

__Good to know__:

- only items without children are clickable
- `exec` returns an entire object

Use it with `<ui-component name="navigation">`. 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
<div class="row">
	<div class="col-xs-6">
		<div style="border: 1px solid #E0E0E0">
			<ui-component name="navigation" path="items" config="exec:navclick"></ui-component>
		</div>
	</div>
</div>

<script>
	var items = [];
	items.push({ name: 'Home' });
	items.push({ name: 'Admin', collapsed: true, children: [{ name: 'Users' }, { name: 'Products' }] });
	items.push({ name: 'Settings' });

	function navclick(item) {
		console.log(item);
	}
</script>
```
