I am trying to create a simple ui tabs from basic structure.
I have four tabs
- Apple
- Orange
- Mango
- More
When I drag Orange
and More
their height increases and when dropped goes back to normal. This does not happen with Apple
and Mango
elements.
HTML:
<div id="tabs">
<ul>
<li><a href="#tabs-1">Apple</a>
<span class="ui-icon ui-icon-close" role="presentation">Remove Tab</span>
</li>
<li>
<a href="#tabs-2">Orange</a>
<span class="ui-icon ui-icon-close" role="presentation">Remove Tab</span>
</li>
<li>
<a href="#tabs-3">Mango</a>
<span class="ui-icon ui-icon-close" role="presentation">Remove Tab</span>
</li>
<li>
<a href="#tabs-4">More</a>
<span class="ui-icon ui-icon-close" role="presentation">Remove Tab</span>
</li>
</ul>
<div id="tabs-1"><p>Apple</p></div>
<div id="tabs-2"><p>Orange</p></div>
<div id="tabs-3"><p>Mango</p></div>
<div id="tabs-4"><p>More</p></div>
</div>
CSS:
#tabs li .ui-icon-close {
float: left;
margin: 0.4em 0.2em 0 0;
cursor: pointer;
}
JS : JSFIDDLE
var tabs = $("#tabs").tabs();
// Make Tabs Sortable
tabs.find(".ui-tabs-nav").sortable({
axis: "x",
stop: function () {
tabs.tabs("refresh");
}
});
// close icon: removing the tab on click
tabs.delegate("span.ui-icon-close", "click", function () {
var panelId = $(this).closest("li").remove().attr("aria-controls");
$("#" + panelId).remove();
tabs.tabs("refresh");
});