editor: openSelect view - hide list trigger on empty items list
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 25 Mar 2014 13:03:54 +0000 (14:03 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 25 Mar 2014 13:03:54 +0000 (14:03 +0100)
src/editor/views/openSelect/openSelect.js

index 451570e..eeea988 100644 (file)
@@ -19,13 +19,18 @@ var OpenSelect = Backbone.View.extend({
         this.$el.append(_.template(template)({value: this.options.value || ''}));
         this.$('.toggle').dropdown();
         this.menu = this.$('.dropdown-menu');
+        this.toggleHandler(false);
         if(this.options.inputTemplate) {
             this.input = $(this.options.inputTemplate);
             this.$('.input-wrapper').append(this.input);
         }
     },
+    toggleHandler: function(toggle) {
+        this.$('.toggle').css('visibility', toggle ? 'inherit' : 'hidden');
+    },
     addItem: function(value) {
         this.menu.append(_.template(itemTemplate)({value: value}));
+        this.toggleHandler(true);
     },
     onSelection: function(e) {
         var val = $(e.target).text();