Thanks for your help here Klaus, and sorry again for the length...
Here's the behavior I'm after:
- A list of records with edit links on each.
- Clicking one opens a dialog containing a tab set. Each tab contains
an ajax form for editing different aspects of that record.
- The last tab you view is remembered in a cookie, and displayed the
next time you edit.
For this to work, some things have to happen when you click edit:
- The url of each tab needs to be adjusted to use the ID of the
clicked item.
- "After" that, the last tab you viewed needs to get loaded and
selected.
- Once a tab is loaded, its form needs to be ajaxForm'd.
- The dialog needs to be shown.
Ideally, the dialog and the tab set get created when the list pg
loads, and reused from then on.
I've got all this working, except for problems with the initially
selected tab:
- If the tabs are defined with
selected: getLastEditTab()
...the tab looks selected, but as you'd logically expect, an ajax
call to load the last selected tab gets made when the pg loads. This
is useless, because no item has been chosen to edit, so the tab urls
don't have a real item ID to work with. Not ideal, but not horrible,
probably ok enough if there's no better way.
- If instead the tabs are defined with
selected: null
...the last selected tab doesn't appear selected when the page first
opens. It loads, but even though I've explicitly selected it after
updating the tab urls, and after the original call to tabs(), all tabs
appear unselected. Using selected: null must force all tabs to be
deselected, in some way that takes effect after I explicitly select
the one I want, even though my select() code runs later.
Calling tabs('select', lastTab) in the onTabLoad callback does make
the tab look selected, but two ajax calls get made when you select a
new tab, and three the first time you edit. I couldn't find any
callback point that made the tab look selected without additional
loads.
What I think I really need is to define the tab object in such a way
that it doesn't try to manage loading, selecting, or deselecting any
tabs at all intially -- just let me do it. Setting selected: null
forces all tabs to be deselected, and an out of range tab index throws
an error. Is there some way to achieve this that I don't know about?
There's another issue, with a workaround. In either case above, if any
tab except [0] is the most-recently-used tab I select, that tab, *and
all tabs to the right of it* get the 'ui-tabs-loading' class applied
to them during load. Again not ideal, but not horrible, probably ok
enough if there's no better way. This seems like a bug.
In some situations that I haven't quite pinned down, all those tabs
end up selected-looking when the loading class is removed, and stay
that way until you manually choose another tab. That's pretty bad.
Worked around it by using this to load a tab:
function loadAndSelectTab(tabObj, index)
{
tabObj.tabs('load', index);
tabObj.children('li:not(:eq(' + index + '))').removeClass('ui-tabs-
selected');
}
I tried a bunch of other things, none as successful, so I'm living
with the extra ajax call on pg load, and manually adjusting the tab
selection classes.
Thanks again for any help, Klaus and others.