Detecting the Active Tab

20 views
Skip to first unread message

dave1167

unread,
Feb 26, 2018, 8:16:01 AM2/26/18
to Joomla! General Development
Hi

I'm developing a  component which uses a form which has 3 tabs on it. There is a master record which is displayed in a form field at the top of the form, then each Tab is displaying a list of records associated with the master record    In order to use the new record button and edit button which will then open the correct save and edit functions .   I need to be able to detect the active Tab.  I can't seem to find any global variable which holds this information. 

Is there a way to find which tab is currently open?

Thanks in anticipation

Maciek Wołpiuk

unread,
Feb 26, 2018, 8:27:34 AM2/26/18
to joomla-de...@googlegroups.com
Hello
U want to save info about which one tab is active ?

I use something like this.

$('#mwtripsTabs').on('show.bs.tab', function(e) {
var name = $(e.target).attr('href');
tabname_length = name.length;
tabname = name.substring(name.indexOf("#")+1, tabname_length);
jQuery.ajax({
method : 'POST',
url: 'index.php?option=com_mwtrips&task=trip.save_tab',
data: { tab_name: tabname }
})
.done(function(data) {
});
});

public function save_tab() {
$app = JFactory::getApplication();
$user = JFactory::getUser();
$response = array();
$jinput = $app->input;
$tabname = $jinput->get('tab_name','', 'STRING');
$app->setUserState('com_mwtrips.tab',$tabname);
$response['wiadomosc'] = "Gotowe";
echo json_encode($response);
$app->close();
}

Sins
Mac


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.
To post to this group, send email to joomla-dev-general@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

dave1167

unread,
Mar 1, 2018, 7:08:57 AM3/1/18
to Joomla! General Development
Hi
it is not the active tab I need to save.  The page has three forms on it  all acccessed via 3 tabs

[Tab 1]  [Tab 2]  [Tab 3]

I need to know which tab is active so I can set up the toolbar/tasks to access the correct toolbar  buttons and correct model.   I suspect I need to use jQuery to find which tab has been clicked then pass that as a variable back to Joomla.  I am total novice on jQuery so I decided to set up a test based  on the first Tab only .  I figure if i can detect the first tab I can write  a routine to look at all the tabs and work out which one is being clicked :-
The code below is not workking.  I can get an alert box to appear  just on the document.ready function when the document loads, so I know jQuery is loaded , however when add in the click function I can't get the Tab1 id  to be recognised.   Has anyone got any ideas?  

jQuery(document).ready(function(){

jQuery
("#Tab1").click(function(){
        alert
("The Tab was clicked.");
   
});
});Enter code here...

Mike Smith

unread,
Mar 1, 2018, 7:12:01 AM3/1/18
to joomla-de...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages