Panel model now .unbind()ing events
authorDarren <darren@darrenwhitlen.com>
Mon, 1 Oct 2012 13:57:02 +0000 (14:57 +0100)
committerDarren <darren@darrenwhitlen.com>
Mon, 1 Oct 2012 13:57:02 +0000 (14:57 +0100)
client_backbone/dev/model_applet.js
client_backbone/dev/model_application.js
client_backbone/dev/model_panel.js

index 36f548ab6eb999b4f0b664e085a3088a4ba2dd03..836c1d1ea70b8a8c103e8e1df96bb48935d6ce2d 100755 (executable)
@@ -61,5 +61,14 @@ kiwi.model.Applet = kiwi.model.Panel.extend({
             // Load a new instance of this applet\r
             that.load(new kiwi.applets[applet_name]());\r
         });\r
+    },\r
+\r
+    close: function () {\r
+        this.view.$el.remove();\r
+        this.destroy();\r
+        \r
+        this.view = undefined;\r
+\r
+        this.closePanel();\r
     }\r
 });
\ No newline at end of file
index 0ff5bce442ede75914e7c4ae28fd93ba299f3a1e..d3ec065b4c656def160ae05b8453929cb194f955 100755 (executable)
@@ -515,7 +515,7 @@ kiwi.model.Application = function () {
             \r
             kiwi.app.panels.add(panel);\r
             panel.view.show();\r
-\r
+            \r
             kiwi.app.channel_list = list;\r
         });\r
 \r
index 571ceb4ce1813f507483624d5fadea2b83800452..ac123d4aa8b090bfd2e8ca38aba83ae96b537d8c 100755 (executable)
@@ -54,9 +54,11 @@ kiwi.model.Panel = Backbone.Model.extend({
         this.trigger("msg", message_obj);\r
     },\r
 \r
-    close: function () {\r
-        this.view.remove();\r
-        delete this.view;\r
+    closePanel: function () {\r
+        if (this.view) {\r
+            this.view.remove();\r
+            delete this.view;\r
+        }\r
 \r
         var members = this.get('members');\r
         if (members) {\r
@@ -64,6 +66,7 @@ kiwi.model.Panel = Backbone.Model.extend({
             this.unset('members');\r
         }\r
 \r
+        this.unbind();\r
         this.destroy();\r
 \r
         // If closing the active panel, switch to the server panel\r
@@ -72,6 +75,11 @@ kiwi.model.Panel = Backbone.Model.extend({
         }\r
     },\r
 \r
+    // Alias to closePanel() for child objects to override\r
+    close: function () {\r
+        return this.closePanel();\r
+    },\r
+\r
     isChannel: function () {\r
         var channel_prefix = kiwi.gateway.get('channel_prefix'),\r
             this_name = this.get('name');\r