So I upgraded jquery ui from 1.8 to 1.10. Tabs seem to have been refactored in 1.9 already according to this: http://jqueryui.com/upgrade-guide/1.9
While reading through - this came up:
Deprecated idPrefix, tabTemplate, and panelTemplate options; use refresh method
As mentioned above, the add and remove methods have been deprecated. As a result, the idPrefix, tabTemplate, and panelTemplate options have been deprecated as well. You should replace all uses of the idPrefix, tabTemplate, and panelTemplate options with the markup you would like to use.
Not very clear what You should replace all uses... with the markup you would like to use
means.
HTML
<div id="main-xxx-tabs">
<ul>
<li><a href="link1.php">link1</a></li>
<li><a href="link2.php">link2</a></li>
</ul>
</div>
JS
jQuery("#main-xxx-tabs").tabs({
panelTemplate: "<div class='main-xxx-tabs-content'></div>"
})
If anyone could provide an example of how to upgrade this properly - would be much appreciated.
jQuery UI 1.8 had the
add
andremove
methods (and associated events) which served the purpose of dynamically removing or adding tabs to your widget.From the legacy 1.8 documentation for
tabs
:The two methods used the following options:
As you can see
panelTemplate
is the HTML template which the panel is created from using theadd
method.All of this is now deprecated - the current method of adding or removing tabs dynamically is with the assistance of the new
refresh
method:As the upgrade guide states, you need to remove all
add
andremove
method calls in your script, replacing them with code that directly manipulates the DOM, and then callingrefresh()
.Additionally, you need to discard any set options of
idPrefix
,tabTemplate
, andpanelTemplate
.As your code suggests, somewhere down the line you are using the
add
method, for example:With the new
tabs
API, you should do something similar to (taking into account your currentpanelTemplate
value):This would create a new tab. You can replace the value of
href
to be the same asaria-controls
\id
if you do not need a remote loading (ajax) tab.Finally, the upgrade guide also gives you an example of how to remove a tab with the new API.
Edit:
In case you were just using
panelTemplate
as a template for your primary (first) tabs, as opposed to dynamically creating them, then the same rules apply; you will have to directly add the appropriate html. If your html before the upgrade was:Then you should do something along the lines of:
And to further clarify, a
panel
is the content div for your tab.For ajax-loaded tabs, you do not need to create a panel - it will be automatically created for you.
So effectively, to get things going again, you just have to remove the
panelTemplate
option.Here is a JSFiddle demonstrating ajax-loaded, as well as preloaded tabs: http://jsfiddle.net/losnir/LWmVv/
See also the jQuery UI Tabs Documentation.