Titanium JIRA Archive
Alloy (ALOY)

[ALOY-844] Alloy - Event Listeners added repeated to different XML formFactors

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-02-06T22:05:48.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.4.0, 2014 Sprint 03
ComponentsWidgets, XML
Labelsalloy, event, eventlistener
ReporterRafael Kellermann Streit
AssigneeTim Poulsen
Created2013-10-14T11:47:07.000+0000
Updated2014-05-19T17:13:26.000+0000

Description

Example: On this code, when click on favorite button on handheld device, favorite function will be fired twice. This is not the correct, because there is only one button to each formFactor.
<Alloy>
    <NavigationWindow platform="ios" formFactor="tablet">
        <Window id="win">
            <RightNavButton>
                <View id="viewButtonsNavBar">
                    <Button id="buttonFavorite" image="/images/Star.png" onClick="favorite" />
                </View>
            </RightNavButton>

            <Require type="view" src="place" id="placeView" />
        </Window>
    </NavigationWindow>

    <Window platform="ios" formFactor="handheld" id="win">
        <RightNavButton>
            <View id="viewButtonsNavBar">
                <Button id="buttonFavorite" image="/images/Star.png" onClick="favorite" />
            </View>
        </RightNavButton>
    </Window>
</Alloy>

Comments

  1. Tim Poulsen 2014-02-06

    I cannot reproduce this on: Alloy 1.3.0 Ti CLI: 3.2.0 SDK: 3.2.0.GA My code removed your required view and updated the controller with a simple favorites function and switcher so the right component opens on launch
       <Alloy>
           <NavigationWindow platform="ios" formFactor="tablet">
               <Window id="win" title="ALOY-844">
                   <RightNavButton>
                       <View id="viewButtonsNavBar">
                           <Button id="buttonFavorite" image="/images/Star.png" onClick="favorite" />
                       </View>
                   </RightNavButton>
                   <View>
                   	<Label text="This is a label"/>
                   </View>
               </Window>
           </NavigationWindow>
        
           <Window id="win" platform="ios" formFactor="handheld" backgroundColor="white">
               <RightNavButton>
                   <View id="viewButtonsNavBar">
                       <Button id="buttonFavorite" image="/images/Star.png" onClick="favorite" />
                   </View>
               </RightNavButton>
                   <View>
                   	<Label text="This is a label"/>
                   </View>
           </Window>
       </Alloy>
       
       function favorite() {
       	alert('favorite fired');
       }
       
       if(Alloy.isTablet) {
       	$.index.open();
       } else {
       	$.win.open();
       }
       

JSON Source