Quantcast
Viewing all articles
Browse latest Browse all 8068

Invalid type passed to a function while trying to open a view

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>

newrecord (view)

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

taxes.js (controller)

var args = arguments[0] || {};
 
function newRecord() {
  var new_record_view = Alloy.createController('newrecord').getView();
  new_record_view.open(); 
}

newrecord.js (controller)

exports.openMainWindow = function(_tab) {
    _tab.open($.child_window);
}
With this code when I click the button 'New Record' everything freezes. When I try to open the window in a tab changing the taxes controller to:

taxes.js (controller)

function newRecord() {
  var new_record_view = Alloy.createController('newrecord');
  new_record_view.openMainWindow($.taxes);
}
It blows with the error:
[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] :  }

Any ideas about what I'm doing wrong or how can I use tabs and open views in tabs using Alloy MVC ?

Thanks in advance, Dimitar


Viewing all articles
Browse latest Browse all 8068

Trending Articles