show window on Jet

Hello,

I want to show a modal window by opening it from a sidebar menu by calling the $oninit function of the windows view.

This is the view:



define(function () {

    var layout = {
        type: "space",
        width: 500,
        height: 500,
        on: {
            onShow: function () {
                console.dir('show');

            }
        },
        id: 'deviceWindow',
        head: "Add Device",
        rows: [

        ]

    };


    return {
        $ui: layout,
        $windows:[
            { view:"window", id:"win2", position:"center",
                head:{ cols:[
                    {},
                    {view:"icon", icon:"times", click:function(){
                        this.getTopParentView().hide();
                    }}
                ]},
                body:"Data is loaded"
            },
            { view:"popup", id:"win1", position:"center", body:"You've clicked me!"}

        ],
        $oninit:function(view){
          //  view.parse(records.data);
            console.dir($$("win2"));
            $$("win2").show();
        }
    };
});

`


The window config I've taken from a working sample. The issue is that $$("win2") is undefined so i cannot show the window. 

I've tried all kind of configurate methods of the window but I cannot make it to actually show it.

Thank you