[ALOY-844] Alloy - Event Listeners added repeated to different XML formFactors
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Cannot Reproduce |
Resolution Date | 2014-02-06T22:05:48.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Alloy 1.4.0, 2014 Sprint 03 |
Components | Widgets, XML |
Labels | alloy, event, eventlistener |
Reporter | Rafael Kellermann Streit |
Assignee | Tim Poulsen |
Created | 2013-10-14T11:47:07.000+0000 |
Updated | 2014-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
- 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(); }