Reputation: 2909
OBJECTIVE: How can I change content of ui tabs after it has been initialized.
See code below.Possible something after $tabs.find(content-1) etc
So ideally,
HTML:
<div id="tabs">
<ul>
<li><a href="#tabs-1">tab1</a>
</li>
<li><a href="#tabs-2">tab2</a>
</li>
<li><a href="#tabs-3">tab3</a>
</li>
</ul>
<div id="tabs-1">
<p>loading...</p>
</div>
<div id="tabs-2">
<p>loading...</p>
</div>
<div id="tabs-3">
<p>loading...</p>
</div>
</div>
JS
$tabs = $('#tabs').tabs({
cache: false,
});
//
$tabs.do something here
$tab. detect evet if tabs have initialized ..
then send ajax requests and append to tabs content area ..
Upvotes: 2
Views: 4443
Reputation: 4624
Try this
I guess this is what you need
$(document).ready(function () {
$tabs = $('#tabs').tabs({
cache: false,
});
if ($('#tabs').hasClass('ui-tabs')) { // check if tabs initilized
$('.tab').each(function () {
var tab = $(this);
$.ajax({
url: '/echo/html/',
success: function (data) {
tab.html("success"); // for demo
}
});
});
}
});
Upvotes: 1