ForgeComponents
en

Components

j-TabMenu

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

Configuration:

  • class {String} optional, is a class name for a selected element (default: selected)
  • selector {String} optional, is a jQuery selector (default: li)
  • datasource {String} optional, a path to a data-source, content must be Tangular template
  • disabled {Boolean} optional, it can disable tabs
  • exec {String} optional, a link to the function (it will be executed when the tab is changed)
  • attr {String} optional, a default attribute for obtaining tab identifier (default: id)

Use it with <ui-component name="tabmenu">. 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.

example.html
<h2>Static tabs</h2>

<ui-component name="tabmenu" path="tab">
	<ul>
		<li data-id="tab1">Tab 1</li>
		<li data-id="tab2">Tab 2</li>
		<li data-id="tab3">Tab 3</li>
	</ul>
</ui-component>

<ui-bind path="tab" config="show:value==='tab1'" class="block hidden">
	TAB 1 content
</ui-bind>
<ui-bind path="tab" config="show:value==='tab2'" class="block hidden">
	TAB 2 content
</ui-bind>
<ui-bind path="tab" config="show:value==='tab3'" class="block hidden">
	TAB 3 content
</ui-bind>

<br />

<h2>Dynamic tabs</h2>
<ui-component name="tabmenu" path="tab" config="datasource:tabs">
	<script type="text/html">
		<ul>
			{{ foreach m in value }}
			<li data-id="{{ m.id }}">{{ m.name }}</li>
			{{ end }}
		</ul>
	</script>
</ui-component>

<ui-bind path="tab" config="show:value==='tab1'" class="block hidden">
	Dynamic TAB 1 content
</ui-bind>
<ui-bind path="tab" config="show:value==='tab2'" class="block hidden">
	Dynamic TAB 2 content
</ui-bind>
<ui-bind path="tab" config="show:value==='tab3'" class="block hidden">
	Dynamic TAB 3 content
</ui-bind>

<script>
	var tab = 'tab1';
	var tabs = [{ name: 'Tab 1', id: 'tab1' }, { name: 'Tab2', id: 'tab2' }, { name: 'Tab 3', id: 'tab3' }];
</script>