Titanium JIRA Archive
Alloy (ALOY)

[ALOY-878] <SplitWindow> not recognized when used with formFactor tags

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionWon't Fix
Resolution Date2013-11-18T14:29:59.000+0000
Affected Version/sAlloy 1.2.2
Fix Version/sn/a
ComponentsAppcelerator Studio, Titanium SDK
LabelsAlloy, Studio
ReporterJamil Spain
AssigneeTony Lukasavage
Created2013-11-18T02:38:12.000+0000
Updated2014-02-28T23:57:14.000+0000

Description

I have the following index.xml view: I'm working on a formFactor tags with iphone and ipad layouts using formfactor tags. Whichever one is second never gets processed. If I switch the SplitWindow to be before the tag, it gets processed but when you start the iphone layout, it won't get processed. Attaching a test project. Working on some work with Citi Group and had some questions about iPad / SplitWindow workings with Alloy.

Attachments

FileDateSize
SplitWindowTest.zip2013-11-18T02:38:12.000+00009197032

Comments

  1. Tony Lukasavage 2013-11-18

    What does "it doesn't get processed" mean? It doesn't generate code? It throws an error? I need more specifics to understand what is going on here. I'll work with it in the meantime, but a little more detail would be helpful.
  2. Jamil Spain 2013-11-18

    It throws an error: 'undefined' is not an object ( evaluating '$.index.open') at index.js ( line ## )
  3. Jamil Spain 2013-11-18

    I think it's looking for this line to be in the (!Alloy.isTablet ) block that would be evaluating for iPhone. on Line 52 it calls the $.index.open(); $.__views.index && $.addTopLevelView($.__views.index); Here is the output from the index.js controller in Resources folder: https://gist.github.com/jamilspain-appc/7528528
  4. Tony Lukasavage 2013-11-18

    I assume you haven't given explicit IDs to the Window or SplitWindow? This is why you are getting some kind of error (still not clear though since you didn't say exactly what is happening). You can't use the automatic ID to apply to multiple elements when the conditional you are using is a runtime conditional, like form factor, since this can't be determined at compile time. You need to give an explicit ID to your components and this will work just fine. Here's a slight modification of your case that works just fine for iphone and ipad, regardless of the order of elements.

    index.xml

       <Alloy>
       
       	<Window id="win" formFactor="handheld" backgroundColor="white">
       		<Label>this is a iPhone Window</Label>
       	</Window>
       
       	<SplitWindow id="win" formFactor="tablet">
       		<Window backgroundColor="red"></Window>
       		<Window backgroundColor="blue"></Window>
       	</SplitWindow>
       
       </Alloy>
       

    index.js

       $.win.open();
       
  5. Jamil Spain 2013-11-18

    Gotcha.. so as a general rule for trainings, it's just best to just assign explicit IDs to top level objects and that will always work no matter what the situation. If you don't, then the only use case that will work for ( the automatic ID ) is with a single top level object in a View Layout. Sound accurate, any more exceptions?
  6. Tony Lukasavage 2013-11-18

    Yeah, that might be the safest bet. The only situation this should occur in is if you have multiple top level elements that are relying on the auto id of the controller name AND you are using runtime conditionals on them (like form factor). A very specific case you managed to find. ;-)

JSON Source