Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open a window in a new Tab (TabGroupContext) #20

Open
nvdnkpr opened this issue Jan 20, 2012 · 1 comment
Open

Open a window in a new Tab (TabGroupContext) #20

nvdnkpr opened this issue Jan 20, 2012 · 1 comment

Comments

@nvdnkpr
Copy link

nvdnkpr commented Jan 20, 2012

Hi Jacob,

i just tried to open up a window in a new Tab, which didn't work out:
Problem were the following lines in the open-function on line 646 in kranium.js:

open: function(parent o){   
       if(typeof parent === 'string'){
        parent = $$(parent)[0] || null;
    }

    if(el){
        switch(el._type){
            case 'window':
                if(parent == 'tab'){
                    if(block){ return; } else { block = true; }

                    el.addEventListener('open', function(){ block = false; });
                    K.currentWindow = el;

                    var tab = (
                        (tmp = ((o&&o.tab)||o)) &&
                        (typeof tmp === 'string') ? $$(tmp)[0] : tmp
                    ) || (
                        (tmp = $$('tabgroup')) && tmp[0] && tmp[0].activeTab
                    );

                    (tab||Ti.UI.currentTab).open(el, o||{});
                } else if(parent && parent._type && ['navigationgroup', 'tabgroup', 'tab'].indexOf(parent._type) !== -1) {

                    if(parent._type === 'tabgroup'){
                        parent = parent.activeTab;
                    }   
                    parent.open(el, o||{});
                } else {
                    el.open();
                }
                break;

            default:
                el.open && el.open(parent && K.create(parent, { type: 'window' }), o);
                break;
        }
    }
    return this;
},

the first lines if(typeof parent === 'string'){ immediately changes the variable parent to an object so that the comparison if(parent == 'tab') never get's executed. Executing K({…}).open('tab'); in the code alwys opens the new window in the first tab since the selector engines returns all tabs and the code only takes the first it finds.

@nvdnkpr
Copy link
Author

nvdnkpr commented Jan 20, 2012

My current workaround is changing if(typeof parent === 'string') into if(typeof parent === 'string' && parent !== 'tab')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant