0
votes

My Backbone view has a event Popout which when clicked creates a new View and open that view inside a Kendo Window. What i want is when i click on button, my events inside this view gets unbind and i can use my new view inside Kendo Window. Next when i close Kendo Window, i want my events to rebind. However i am getting a error on this.

Uncaught TypeError: Object [object Object] has no method 'delegateEvents' How can i rebind my events on close function of Kendo window?

popout: function(){
                this.stopListening();
                  //this.delegateEvents();
                  this.undelegateEvents();              
                var model = this.model;
                var popOutModuleView = new PopOutModuleView({model:model});
                lightRegion.show(popOutModuleView);
                Backbone.trigger("popout");
                event.preventDefault();
                var a = $('#lightbox').kendoWindow({
                    actions: ["Maximize", "Close"],
                    title: name,
                    width: "90%",
                        height: "90%",
                        resizable: true,
                    close: function(e){
                        popOutModuleView.remove();
                        lightRegion.close();
                        this.delegateEvents();                  
                    }
                });
1

1 Answers

1
votes

"this" does not refer to the Backbone.View, hence delegateEvents() is unknown. You'll have to bind this to the close function or make this available in the scope of the close function.

popout: function() {
    var _this = this;
    // CODE
    var a = $('#lightbox').kendoWindow({
        // CODE
        close: function() {
             _this.delegateEvents();
        }
    });
}