yui - YUI3 find current tab in TabView -
i'm using yui3 tabview component, , i'd able index of selected tab. i've been looking through api docs, can't seem find relevant way this.
http://developer.yahoo.com/yui/3/api/module_tabview.html
thanks!
"indexof" works if use "tabview.get('selection')" argument.
example:
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <title>untitled document</title> <script type="text/javascript" charset="utf-8" src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"> </script> </head> <body> <body class="yui3-skin-sam"> <p id="msg"></p> <input type='button' value='button' id='button'/> <div id="demo"> <ul> <li><a href="#foo">foo</a></li> <li><a href="#bar">bar</a></li> <li><a href="#baz">baz</a></li> </ul> <div> <div id="foo">foo content</div> <div id="bar">bar content</div> <div id="baz">baz content</div> </div> </div> <script> var yui; yui().use('event', 'node', 'tabview', function (y) { y.one('#msg').set('innerhtml', 'message area'); var tabview = new y.tabview({srcnode: '#demo'}); tabview.render(); var displayindex = function (tabview) { var sel = tabview.get('selection'); var idx = tabview.indexof(sel); y.one('#msg').set('innerhtml', 'selected tab index = ' + idx); } displayindex(tabview); y.after('click', function(e) { displayindex(this); },'body',tabview); }); </script> </body> </html>
Comments
Post a Comment