Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/145#discussion_r20426295
  
    --- Diff: app/addons/config/views.js ---
    @@ -149,31 +149,15 @@ function(app, FauxtonAPI, Config, Components) {
       });
     
     
    -  Views.AddConfigOptionsButton = FauxtonAPI.View.extend({
    +  Views.AddConfigOptionsButton = Components.Tray.extend({
         template: 'addons/config/templates/add_config_option',
     
         events: {
    -      'click #add-new-section': 'toggleTray',
           'click #js-create-config-section': 'createConfigOption'
         },
     
         initialize: function () {
    -      var hideTray = _.bind(this.hideTray, this),
    -        trayVisible = _.bind(this.trayVisible, this);
    -
    -      $('body').on('click.add-new-section', function(e) {
    -        var $clickEl = $(e.target);
    -
    -        if (!trayVisible()) { return; }
    -        if ($clickEl.closest('.add-new-section').length) { return; }
    -        if (!$clickEl.closest('.add-section-tray').length) {
    -          hideTray();
    -        }
    -      });
    -    },
    -
    -    cleanup: function () {
    -      $('body').off('click.add-new-section');
    +      this.initTray({ toggleTrayBtnSelector: '#add-new-section' });
    --- End diff --
    
    Hey @benkeen I really like this code reuse. But I also really dislike the 
`initTray` idea. 
    I think you can do something like [this 
instead](https://github.com/apache/couchdb-fauxton/blob/master/assets/js/plugins/cloudant.pagingcollection.js#L54-L72).
 That way you can pass in the `toggleTrayBtnSelector` on standard construction 
and not have to have another method to initialize.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to