recursive window/view managament

You must Login before you can answer or comment on any questions.

Dear Appcelerator Community,

i'm trying to implement a recursive window management. that means, as i go into the hirarchy of my app (home window > 1st level window > 2nd level window > 3rd level window > etc ), i want to use the same js-file for creating the 'window' every time (namely DetailContainerWindow.js). the currently active window will listen for an event on itsself, announcing that a new window is to be opened.

the start of the recursion is of course the applicationwindow.js. there i have the code:

var DetailContainerWindow = require('ui/common/DetailContainerWindow');
 
    masterView.addEventListener('categorySelected', function(e) {
        //create detail view container
 
        var detailContainerWindow = new DetailContainerWindow();
 
        detailContainerWindow.fireEvent('recieveOwnView', e);
        detailContainerWindow.open();
    });
the event 'categorySelected' is fired by the masterview. until here (and also a bit further) everything works perfectly fine.

now, the DetailContainerWindow.js file contains the following code:

self.addEventListener('recieveOwnView', function(e) {
        var OwnView = new require(e.url); //  e.g:  e.url = '/ui/common/DetailView'
        var ownView = new OwnView();
 
        ownView.addEventListener('test', function(e){
            Titanium.UI.createNotification({duration : 500,message : "angekommen 2"}).show();
        });
 
        ownView.addEventListener('openNewWindow', function(e) {
            var NewWindow = require('ui/common/DetailContainerWindow');
            var newWindow = new NewWindow();
 
            var NewView = require(e.url);
            var newView = new NewView();
 
            newWindow.add(newView);
 
            newWindow.fireEvent('recieveOwnView', e);
 
            newWindow.open();
        });
 
        self.add(ownView);
    });
and an the newly opened view would contain:
lbl.addEventListener('click', function(e) {
        self.fireEvent('openNewWindow', {
            url: "ui/common/DetailView0Level2",
            categoryName: "Level2"
        });
    });
well, for the first two levels of recursion, everything works as i thought it would... but as i enter the third level of recursion, the 'NewWindow'-eventListener simply will NOT HEAR THE EVENTS FROM ITS CHILD VIEW any more !!

i checked whether the event is fired at all by adding an eventlistener to the view.js. this eventlistener did hear the fired 'openNewWindow' event. so it has to be a matter of the communication between the view-object and its parent window-object.

i hope that i supplied enough code enable you to analyze the problem.

i realize that this problem might be pretty tough to look through... or not, and i'm just too blind to see it. in any case, i would hugely appreciate any help!!!!

cheers, kai

supplementary infos: device-os: android, device: emulator, titanium studio build: 2.1.2.201208301612 , computer-os: os x 10.7

Your Answer

Think you can help? Login to answer this question!