techiferous/tabulous

How to detect the tab or the subtab that the user clicked on

Closed this issue · 3 comments

I am using tabulous in a rails application that also uses bootstrap 3.0. On a particular page, it shows tabs and subtabs. I want to select the subtab that the user clicked on, to implement some special behavior. With the $(.subtabs).click method, I know that the user clicked on one of the subtabs. But this is actually referring to the parent div element that the subtab belongs to. How do I select the particular subtab that the user has clicked on?

See the screenshot below:
image

The user may click on the Negotiations...sub tab or the Attachments subtab and I need to be able to detect the exact subtab that the user clicked on. Any suggestions?

Unfortunately, tabulous' default HTML structure makes it difficult to do this, but not impossible. You can use jQuery to target a particular subtab by its position or by its href attribute. The other option is to write your own custom tabulous renderer that creates HTML that is easier to work with.

Wyatt, Yes there is a way, I found, without any further customization. See below:

$('.subtabs').click(function(){

tgtURL = $(".subtabs li a").attr("href")
//Use this URL however you want
})

If I have 3 subtabs, this gets me the URL of the subtab that I clicked on. I could have selected any a tag. But I needed it from the subtabs only. Hence this quest for this solution.

Thank you for developing this gem.

Glad you found a solution!