hotkey remembered

hotkey stay working even after destroying the window where the button is situated in.

Tagged:

Comments

  • Hello,

    can you please provide a more concrete example?

  • edited January 30
    var ui_login = {
        view:"window", modal:true, id:"login-win", position:'center', width:300, height:450, css:"bradius",
        head: { height:38, template: "Login" },
        body:{
            padding:18, view:"form", minWidth:300, id:"login-form",
            elements:[
                {view:"text", placeholder:"Enter User", name: "userid", label:"User", labelAlign:"right", id:"userid",
                    required: true
                },
                {view:"text", placeholder:"Password", name:"password", type:"password",label:"Password", labelAlign:"right", id:"password",
                    required: true
                },
                {cols:[
                    {},
                    {view:"button", value:"Ok", align:"right", id: "loginBut", hotkey: "enter",
                        click:function() {
                            if ($$('login-form').validate()) {
                                var temp = {};
                                temp.user = $$('userid').getValue().toUpperCase();
                                temp.pas = $$('password').getValue();
                                temp.sid = 'login';
                                var promise = LoginServer(temp);
                                promise.then(function (data) {
                                    if (data.LoggedIn !== undefined) {
                                        $$('password').setValue('');
                                        $$('login-form').validate();
                                    } else {
                                        webix.storage.session.put('sid', data.sid);
                                        if ($$('order-win'))
                                            $$('order-win').hide();
                                        if ($$('form-layout'))
                                            $$('order-form').removeView('form-layout');
    
                                        tcds.main.hide();
                                        $$('login-win').hide();
                                        $$('login-win').destructor();
                                        loadFirst();
                                        tcds.main.show();
                                    }
                                }).fail(function (err) {
                                    //error
    
                                });
                            }
                        }
                    }
                ]}
            ]
        },
        on: {'onShow': function(){
                getCSSRule('.webix_modal', 'mystyle').style.opacity = 0.8;
            },
            'onHide' : function(){
                getCSSRule('.webix_modal', 'mystyle').style.opacity = 0.01;
            }
        }
    };
    /**
    

    The hotkey enter stays know even after destroying the window ($$('login-win').destructor(); )

    If I press enter on a form after been logged in, it still triggers the hotkey and gives an error in webix

        triggerEvent:function(node, type, name){
            if(document.createEventObject){
                var ev = document.createEventObject();
                if (node.fireEvent)
                    node.fireEvent("on"+name, ev);
            } else{
                var ev = document.createEvent(type);
                ev.initEvent(name, true, true);
                if (node.dispatchEvent)
                    node.dispatchEvent(ev);
            }
        },
    

    gives error ( Cannot read property 'dispatchEvent' of null(…)).
    node is null

  • Unfortunately, we can't repeat this problem. We will appreciate a concise demo that will show the problem. But anyway, I can suggest two things:

    a) usewebix.delay for destructor. It usually helps to avoid conflicts of code execution.

    b) check It is the actual number of event handlers.
    With the debug version of the library, log webix.UIManager._hotkeys before and after destroying the view and check for the array of objects withdebug:"enter" attribute.

    One more thing:close() is equal to hide+destrutor.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!