From 831d6564771aa131a77469865668aa9706600fb1 Mon Sep 17 00:00:00 2001 From: Felix Gnass Date: Thu, 23 Aug 2012 14:29:22 +0200 Subject: [PATCH] fixed the upper right menu and made it dynamic The menu did not work because `this['$'+view.id]=...` was called with the wrong scope. Besides this fix, the template now looks at the actual `sidebarViews` array and renders the buttons dynamically. --- src/view.multiview.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/view.multiview.js b/src/view.multiview.js index f6d0b968..3645719d 100644 --- a/src/view.multiview.js +++ b/src/view.multiview.js @@ -111,8 +111,9 @@ my.MultiView = Backbone.View.extend({ \ \
\ @@ -246,6 +247,7 @@ my.MultiView = Backbone.View.extend({ render: function() { var tmplData = this.model.toTemplateJSON(); tmplData.views = this.pageViews; + tmplData.sidebarViews = this.sidebarViews; var template = Mustache.render(this.template, tmplData); $(this.el).html(template); @@ -265,7 +267,7 @@ my.MultiView = Backbone.View.extend({ _.each(this.sidebarViews, function(view) { this['$'+view.id] = view.view.el; $dataSidebar.append(view.view.el); - }); + }, this); var pager = new recline.View.Pager({ model: this.model.queryState @@ -308,13 +310,7 @@ my.MultiView = Backbone.View.extend({ _onMenuClick: function(e) { e.preventDefault(); var action = $(e.target).attr('data-action'); - if (action === 'filters') { - this.$filterEditor.toggle(); - } else if (action === 'fields') { - this.$fieldsView.toggle(); - } else if (action === 'transform') { - this.transformView.el.toggle(); - } + this['$'+action].toggle(); }, _onSwitchView: function(e) {