{"issue":{"created_at":"2011-12-06T13:09:11Z","state":"open","updated_at":"2011-12-12T21:11:21Z","user":{"gravatar_id":"08c421e261d870b2da41f73e4071d3f6","id":477658,"url":"https://api.github.com/users/Alex-Sh","login":"Alex-Sh","avatar_url":"https://secure.gravatar.com/avatar/08c421e261d870b2da41f73e4071d3f6?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":1,"body":"At this moment only way i found to select default tab is `initialIndex` property. \r\nWhen output html, it's more intuitive and useful to use anchor 'class = \"current\"' attribute to select initial tab, without js code. It doesn't work now, initial tab is always first.\r\n\r\nSmall snippet how to solve this, but I think this future must be out of the box.\r\n\r\n```javascript\r\n$(\".tabs\").each(function (index) {\r\n   //get index if tab selected by 'current' class\r\n   var initialIndex = $(this).find('li:has(a.current)').index();\r\n   //if no class=\"current\" was set index is -1\r\n   initialIndex = initialIndex < 0 ? 0 : initialIndex;\r\n   //init tabs using found index\r\n   $(this).tabs(\".tab-panes > div\", {initialIndex: initialIndex});\r\n});\r\n```\r\n\r\n\r\n\r\n","assignee":null,"id":2461854,"labels":[],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":581,"title":"Tabs: Select initial tab using class attribute","html_url":"https://github.com/jquerytools/jquerytools/issues/581","closed_at":null,"url":"https://api.github.com/repos/jquerytools/jquerytools/issues/581","milestone":null},"action":"created","comment":{"created_at":"2011-12-12T21:11:21Z","updated_at":"2011-12-12T21:11:21Z","user":{"gravatar_id":"abf8fc13792865bb880e7f3d1805be20","id":802739,"url":"https://api.github.com/users/alibby251","login":"alibby251","avatar_url":"https://secure.gravatar.com/avatar/abf8fc13792865bb880e7f3d1805be20?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Hi Alex-Sh,\r\n\r\nI think there is actually something that already does this - have a look at the getIndex() method, which is available as part of the API for Tabs? I think you would use it something like this:\r\n\r\n```var api = $('scroll').data(\"tabs\");\r\napi.getIndex();```\r\n\r\nI think you may be able to achieve a similar effect using the getCurrentTab() method as well? Whilst I like your concept, I can see why it would cause an issue, as the initialIndex by default will always start with the first indexed item?","id":3112832,"url":"https://api.github.com/repos/jquerytools/jquerytools/issues/comments/3112832"}}