You are here

function tabsexample_ajax_tabset in Tabs (jQuery UI tabs) 6

Generate an example set of tabs with one loaded via AJAX.

Shows how tabs can be explicitly rendered when not using forms.

1 string reference to 'tabsexample_ajax_tabset'
tabsexample_menu in docs/tabsexample.module
Implementation of hook_menu().

File

docs/tabsexample.module, line 89

Code

function tabsexample_ajax_tabset() {
  $tabset = array();
  $tabset['my_tabset'] = array(
    '#type' => 'tabset',
  );
  $tabset['my_tabset']['first_tab'] = array(
    // #type and #title are the minimum requirements.
    '#type' => 'tabpage',
    '#title' => t('One'),
    // This will be the content of the tab.
    '#content' => t('First tab content.'),
  );
  $tabset['my_tabset']['second_tab'] = array(
    '#type' => 'tabpage',
    '#title' => t('Two--Ajax loaded'),
    // The #ajax_url is the url to the content to be loaded.
    // Can be relative or absolute.
    // No content is needed as the content will be dynamically loaded.
    '#ajax_url' => url('tabsexample/ajax'),
  );
  $tabset['my_tabset']['third_tab'] = array(
    '#type' => 'tabpage',
    '#title' => t('Three'),
  );

  // Render the tabset.
  return tabs_render($tabset);
}