Click here to Skip to main content
15,886,791 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hey all...
i have the following scenario
jquery ui tabs that has 4 tabs that each contain some text + images
i also use jquery to make the tabs take 90% of the available width
so far all was good until i had to add an unordered list to one of the tabs content.
When I did that, the width of the tab headers shrunk to what im guessing is the default width or something.

here is the jquery code that i use to make the tab headers take the desired width:

C#
function stretchTabs() {
    var tabNums = $('#consultancyTabs ul li').length;
    var w = 1000 / tabNums;
    var wi = w - 10 + "px";
    //alert(wi);
    $('.ui-tabs .ui-tabs-nav li').css({
        'width': wi
    });
    $('.ui-tabs .ui-tabs-nav li a').css({
        'width': 90 + "%",
        'text-align':'center'
    });

}


I call the above function in the document.ready function after converting the target content into tabs
i have jquery ui tabs used on other pages and they work just fine as long as the content does not contain any lists

I am guessing that the workaround is something trivial but i still didnt figure it out
Any help is greatly appreciated
Thanks in advance :)
Posted

1 solution

i managed to solve the problem after debugging my jquery code
i had to modify the selector and make it more specific

the updated function would be :
C#
function stretchTabs() {
    var tabNums = $('#consultancyTabs:first-child ul:first li').length;
    var w = 1000 / tabNums;
    var wi = w - 10 + "px";
    $('.ui-tabs .ui-tabs-nav li').css({
        'width': wi
    });
    $('.ui-tabs .ui-tabs-nav li a').css({
        'width': 90 + "%",
        'text-align':'center'
    });

}


Cheers :)
 
Share this answer
 
Comments
You can accept your own answer, if problem is solved.

Thanks,
Tadit
Reda Makarem 24-Sep-13 4:23am    
forgot to do that
thanks for the reminder
Most Welcome... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900