jQWidgets Forums
jQuery UI Widgets › Forums › Navigation › Tabs › How to find a tab based in the tab title?
This topic contains 4 replies, has 3 voices, and was last updated by bruthe 11 years, 4 months ago.
-
Author
-
Hi Team,
I have a vertical menu on the left part of a splitter and tab on the right part of the splitter.
On clicking the menu item, based on the menu item name, a new tab has to be added (if it does not already exist) and if the tab exists the content has to be replaced.
Could you please support me with an example on this.
Thanks,
SushmaHello Sushma,
Here is an example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>Untitled Page</title> <link type="text/css" rel="Stylesheet" href="jqwidgets/styles/jqx.base.css" /> <script type="text/javascript" src="scripts/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="jqwidgets/jqxtabs.js"></script> <script type="text/javascript" src="jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="jqwidgets/jqxsplitter.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#jqxsplitter").jqxSplitter({ width: 700, height: 400, panels: [{size: 250}, {size: 450}] }); $("#jqxmenu").jqxMenu({ width: 120, height: 150, mode: 'vertical' }); $("#jqxtabs").jqxTabs({ width: 400, height: 300 }); $('#jqxmenu').bind('itemclick', function (event) { switch (event.target.innerHTML) { case "First": $('#jqxtabs').jqxTabs('removeAt', 0); $('#jqxtabs').jqxTabs('addAt', 0, "First", "Updated content"); break; case "Second": $('#jqxtabs').jqxTabs('removeAt', 1); $('#jqxtabs').jqxTabs('addAt', 1, "Second", "Updated content"); break; case "Third": $('#jqxtabs').jqxTabs('removeAt', 2); $('#jqxtabs').jqxTabs('addAt', 2, "Third", "Updated content"); break; }; }); }); </script></head><body> <div id="jqxsplitter"> <div id="left"> <div id="jqxmenu"> <ul> <li>First</li> <li>Second</li> <li>Third</li> </ul> </div> </div> <div id="right"> <div id='jqxtabs'> <ul style='margin-left: 20px;'> <li>Tab 1</li> <li>Tab 2</li> </ul> <div> Initial content 1 </div> <div> Initial content 2 </div> </div> </div> </div></body></html>
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi Dimitar,
This looks fine.. But I may have 10 to 15 tabs.. so could you please let me know if I can get the position of the tab based on the tab title.
Thanks,
SushmaHi Sushma,
In that case, this code snippet should do the job.
var tabsCount = $("#jqxtabs").jqxTabs('length'); var position; for (var i = 0; i < tabsCount; i++) { var tabTitle = $("#jqxtabs").jqxTabs('getTitleAt', i); if (tabTitle == "First") { position = i; break; }; };
The position variable gets the position of the tab with the given title.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Dimitar,cool!
i have find the way ,thank you -
AuthorPosts
You must be logged in to reply to this topic.