Hi,

I found .tabs("option", "selected") will return -1, when the first tab
was dynamic created
I posted a demo on http://jsbin.com/uyigi

here is part of it, when click on #addtab button
it would add a tab, then fire tabs.add event, sellect the just created
tab with correct index
then, run .tabs("option", "selected") it would return -1 not 0

$("#addtab").click(function() {
  $("#tabs").tabs("add", "#tabs-" + id, "Tab-" + id);
  id++;
});

$('#tabs').tabs({
  tabTemplate: '<li class="tab"><a href="#{href}"><span>#{label}</
span></a></li>',
  add: function(event, ui) {
      $("#msg").html('add tab at index: ' + ui.index);
      //console.info(ui.panel.id);
      $("#tabs").tabs('select', ui.index);
  }
});

my solution is check the index, if it's -1 then return 0 instead,
something like

var index = $('#tabs').tabs('option', 'selected');
index = (index < 0) ? 0 : index;
$('#tabs').tabs('remove', index);

Am I using worng way to select tab after add, or it's a bug from
ui.tabs?

Thanks,
Ethan.

--

You received this message because you are subscribed to the Google Groups 
"jQuery UI" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jquery-ui?hl=.


Reply via email to