Question

i added navbutton to navigation and i wrote 'click' function on to it doesn't work first time . actually am adding button to navigation bar on that first click it was not working on second click it works how can i solve this

my xml code is

 <Alloy>
<Window id="aboutWin" name="aboutWinName">
    <NavigationGroup id="navAbout" platform="ios">
        <Window class="container" id="aboutChildWin">
        <View id="aboutView">
        <ImageView id="logoImg"></ImageView>
        <ImageView id='logoWrd'></ImageView>
        <Label id="versionLbl"></Label>
        </View>
    <View id="footView"></View>
    </Window>
    </NavigationGroup>
</Window>
 </Alloy>

and my Js code is

var button = Titanium.UI.createButton({
// title:"Back",
backgroundImage:"/images/MenuList.png",
// top : 4.5,
height : 35,
width : 40,
// left : 4
})


$.aboutChildWin.leftNavButton = button;


button.addEventListener('click',function(){
 if(Ti.App.currentAnimateWindow  == "About")
 {
     Ti.App.socialWindow.hide();
     Ti.App.menuWindow.show();
     $.aboutWin.animate(animateLeft);
     Ti.App.currentAnimateWindow  = "Menu";
 }
 else if(Ti.App.currentAnimateWindow  == "Menu")
 {
     $.aboutWin.animate(animateRight);
     Ti.App.currentAnimateWindow  = "About";
 }

})

can any one solve this

Was it helpful?

Solution

i just make small change, insert of adding button to navigation window i add the navbutton to whole window.

code is :

$.aboutWin.leftNavButton = button;

OTHER TIPS

That might sound stupid but did you try to change the order?

var button = Titanium.UI.createButton({
  // title:"Back",
  backgroundImage:"/images/MenuList.png",
  // top : 4.5,
  height : 35,
  width : 40,
  // left : 4
});

button.addEventListener('click',function(){
 if(Ti.App.currentAnimateWindow  == "About")
 {
     Ti.App.socialWindow.hide();
     Ti.App.menuWindow.show();
     $.aboutWin.animate(animateLeft);
     Ti.App.currentAnimateWindow  = "Menu";
 }
 else if(Ti.App.currentAnimateWindow  == "Menu")
 {
     $.aboutWin.animate(animateRight);
     Ti.App.currentAnimateWindow  = "About";
 }
};

$.aboutChildWin.leftNavButton = button;

Without using alloy this change makes no difference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top