vendredi 10 juillet 2015

Emberjs - Can I set controller in View inside didInsertElement?

I am new to EmberJS and have existing code. I have a login form which should be posted on hitting enter button.

First time everything goes smooth and working as expected, once I log out- it clears the session and redirects me to login view and then the problem starts as that.get("controller") is undefined this time.

My Login view is having below code

didInsertElement: function () {
    var that = this;
    Ember.$(document).keyup(function (e) {
        if (e.which == 13) {
            that.get("controller").send("login");
            // **As that.get("controller") is undefined I want to set that**
            //that.set("controller"); //- **CAN I DO THIS?**            
        }
    });
}

My problem is - that.get("controller") is undefined.

When I tried that.set("controller"); - it says that

Assertion Failed: calling set on destroyed object

Thank you.




Aucun commentaire:

Enregistrer un commentaire