TabControl.removeItem

Syntax

removeItem (value);

Parameters

value. Index of the element to be removed.

Description

The removeItem method removes a tab from the component by its index.

Example

To execute the example, connect the PP.js components library and the PP.css visual styles table. Create the TabControl component and HTML button clicking which deletes selected tab.

<body>

<div id="tabcont1"></div>

<!--Button that deletes selected tab-->

<button onclick="tabcontrol.removeItem(tabcontrol.getSelectedIndex());">Remove selected</button>

<script type="text/javascript">

    // Create the TabControl component:

    var tabcontrol = new PP.Ui.TabControl({

            //ID for the tag div

            ParentNode: document.getElementById("tabcont1"),

            Width: 300,

            Height: 300,

            //Path to the folder that stores images:

            ImagePath: "img"

        });

    //Add tabs:

    tabcontrol.addItem(new PP.Ui.TabItem({ Position: PP.LTRB.Top, Caption: "First tab", Content: "First tab content" }));

    tabcontrol.addItem(new PP.Ui.TabItem({ Position: PP.LTRB.Top, Caption: "Second tab", Content: "Second tab content" }));

</script>

</body>

After executing the example the HTML page will contain the TabControl component which includes two tabs and the button labeled Remove Selected. Clicking the button removes the selected tab.

NOTE. The tab can be deleted using the removeItem method if some content is set for the tab.

See also:

TabControl