Looks like a bug. Please file a ticket here:

http://dev.jqueryui.com/newticket (note: requires registration)

Thanks.

- Richard

On Sat, Nov 14, 2009 at 10:49 AM, Ethan Liu <[email protected]> wrote:

> 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]<jquery-ui%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/jquery-ui?hl=.
>
>
>

--

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