Menubox - allow title change after rendered
authorDarren <darren@darrenwhitlen.com>
Sun, 5 Jan 2014 23:23:44 +0000 (23:23 +0000)
committerDarren <darren@darrenwhitlen.com>
Sun, 5 Jan 2014 23:23:44 +0000 (23:23 +0000)
client/src/views/menubox.js

index 71931c3df738d9b9ba166a639ef1185b0c56854a..4249bb3ef06eabbe9ae793646cc643419444942f 100644 (file)
@@ -20,10 +20,10 @@ _kiwi.view.MenuBox = Backbone.View.extend({
 
         this.$el.find('*').remove();
 
+        $('<div class="ui_menu_title"></div>').appendTo(this.$el);
         if (this._title) {
-            $('<div class="ui_menu_title"></div>')
-                .text(this._title)
-                .appendTo(this.$el);
+            this.$el.find('.ui_menu_title')
+                .text(this._title);
         }
 
 
@@ -39,6 +39,16 @@ _kiwi.view.MenuBox = Backbone.View.extend({
     },
 
 
+    setTitle: function(new_title) {
+        this._title = new_title;
+
+        if (!this._title)
+            return;
+
+        this.$el.find('.ui_menu_title').text(this._title);
+    },
+
+
     onDocumentClick: function(event) {
         var $target = $(event.target);