:: Forum >>

Tabs behaviour ... Carlos

Hi Alex,
In the sample below, Why if I mouse-click on a tab then the "Next" button does not select next-tab?
note: the "Prev" button does it, Am I missing something?
Thanks.
<script>

    var tabs = new AW.UI.Tabs;
    tabs.setId("tabs");
    tabs.setItemText([" Info", "preferences", "Privacy", "Content", "Connections"]);
    tabs.setItemCount(5);
    tabs.setSelectedItems([0]);
    document.write(tabs);

    document.write('<br>');
    var button12 = new AW.UI.Button;
    button12.setId("button12");
    button12.setControlText("Prev");
    button12.setControlDisabled(true)
    document.write(button12);

    var button13 = new AW.UI.Button;
    button13.setId("button13");
    button13.setControlText("Next");
    document.write(button13);

    var button14 = new AW.UI.Button;
    button14.setId("button14");
    button14.setControlText("Apply");
    document.write(button14);


    button12.onClick = function(){
var curI = tabs.getSelectedItems()[0]
if(curI>0){
tabs.setSelectedItems( [curI-1]);
tabs.setCurrentItem(curI-1);
}
if( curI - 1 == 0 ){ button12.setControlDisabled(true) }
if( curI < tabs.getItemCount() ){ button13.setControlDisabled(false) }
}

    button13.onClick = function(){
var curI = tabs.getSelectedItems()[0];
var countabs = tabs.getItemCount();
if( curI < countabs ){
tabs.setSelectedItems( [curI+1]);
tabs.setCurrentItem(curI+1)
}
if( curI + 1 > 0 ){ button12.setControlDisabled(false) }
if( curI + 1 == countabs-1 ){ button13.setControlDisabled(true) }
}

tabs.onSelectedItemsChanged = function( i) {
tabs.setCurrentItem(i);
if( i == 0 ){ button12.setControlDisabled(true);button13.setControlDisabled(false); }
if( i == tabs.getItemCount()-1 ){ button12.setControlDisabled(false); button13.setControlDisabled(true) }
if( i > 0 && i < tabs.getItemCount()-1 ){ button12.setControlDisabled(false);button13.setControlDisabled(false) }
tabs.setCurrentItem(i)
}

</script>
Carlos
Monday, January 4, 2010
Solved,
Seems that tabs.getSelectedItems()[0] is sometimes returning the value as string instead of number, so just replace (in both buttons):
var curI = tabs.getSelectedItems()[0];
with:
var curI = Number(tabs.getSelectedItems()[0]);
solve the issue, although I'm still unsure why it acts different on those cases.
HTH
Friday, January 8, 2010

This topic is archived.


Back to support forum

Forum search