We often have a use case where we’d like to be able to use a wizard, except that users occasionally need to jump around between screens. So we use tabsets, and add a Pagetitle component at the top of each tab, with Next Tab and Previous Tab buttons that run a snippet called ‘nextTab’ and ‘previousTab’, respectively.
Here’s the generic inline javascript to make it work:
<br>// Tabs<br>(function (skuid){<br>//Shortcuts<br>var $ = skuid.$;<br>//Helper Functions<br>// Given the button that was clicked, find the parent tabset.<br>var getTabset = function (button) {<br>return $(button).closest('.ui-tabs-panel').parent();<br>}<br>// Given the active tabset, find the active tab.<br>var getCurrentTab = function (tabset) {<br>return $(tabset).tabs("option", "active");<br>}<br>//Build Snippets<br>var snippets = {<br>'nextTab': function () {<br>var clickedButton = arguments 0].button;<br>var parentTabset = getTabset(clickedButton);<br>$(parentTabset).tabs("option", "active", getCurrentTab(parentTabset) + 1);<br>},<br>'previousTab': function () {<br>var clickedButton = arguments 0].button;<br>var parentTabset = getTabset(clickedButton);<br>var currentTab = getCurrentTab(parentTabset);<br>if (currentTab > 0) {<br>$(parentTabset).tabs("option", "active", currentTab - 1);<br>}<br>}<br>};<br>//Register Snippets<br>$.each(snippets,function(name,func){ skuid.snippet.registerSnippet(name,func); });<br>})(skuid);
You could accomplish something similar with a single pagetitle component above the tabset, instead of one within each tab. You would just have to modify the jQuery to find the right tabset and tab. For our use case this method is better.
(Thanks to Barry for some awesome jQuery help with a few other problems. In a round-about way, you’re responsible for this!)