0
votes

So I've got simple tabbed Titanium Mobile application using Alloy. I'm trying to open new view via a button in the taxes tab:

index.xml (view)

<Alloy>
  <TabGroup>
    <Require src="taxes" />
</TabGroup>

taxes.xml (view)

<Alloy>
<Tab id="taxes" title="Taxes"  icon="taxes.png">
    <Window title="Taxes" class="container">
        <Toolbar bottom="0">
            <Items>
                <Button id="newrecord" title="New Record" onClick="newRecord"></Button>
            </Items>
        </Toolbar>
    </Window>
</Tab>

taxes.js (controller)

var args = arguments[0] || {};

function newRecord() {
  var new_record_view = Alloy.createController('newrecord').getView();
  new_record_view.open(); 
}

newrecord.xml (view)

<Alloy>
    <Window title="New Record" class="container" id="newrecord">
        New Record
    </Window>
</Alloy>

When I click the button everything freezes.

If I try to change the code for newRecord() function in taxes.js to open in the current tab it gives me the error below:

taxes.js (controller)

function newRecord() {
  var new_record_view = Alloy.createController('newrecord');
  new_record_view.openMainWindow($.taxes);
}

newrecord.js (controller)

exports.openMainWindow = function(_tab) {
    _tab.open($.newrecord);
}



[ERROR] :  Script Error {
[ERROR] :      backtrace = "#0 () at :0";
[ERROR] :      line = 31;
[ERROR] :      message = "Invalid type passed to function";
[ERROR] :      nativeLocation = "-[TiUITabProxy openWindow:] (TiUITabProxy.m:225)";
[ERROR] :      nativeReason = "expected: TiWindowProxy, was: (null)";
[ERROR] :      sourceId = 301260640;
[ERROR] :      sourceURL =     "file:///Users/dimitar/Library/Application%20Support/iPhone%20Simulator/7.1/Applications/8FD72932-FC27-43D4-9D3D-33F34F3E3039/autoservice.app/alloy/controllers/taxes.js";
[ERROR] :  }

EDIT:

So, the issue was that I was trying to open window with id child_window instead of new record. Now there is no error and the window is opened, but it looks there is so kind of glitch which can be seen in the video:

https://www.youtube.com/watch?v=Aq-nEAZCb80

1
Show me newrecord.xmlWahhab_mirza
I've updated the question. It gives me that error if I try to open the view in the current tab and freezes if I try to open the view directly.mytrile
What does openMainWindow() from newrecord.js file?daniula
I've added newrecord.js file with openMainWindow functionmytrile

1 Answers

2
votes

So basically it was mistyped windows id causing the problem and the "glitch" is nothing more than fast switching animation from window with light background to a window with dark background.