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

    https://github.com/apache/couchdb/pull/201#discussion_r11135546
  
    --- Diff: src/fauxton/app/addons/fauxton/base.js ---
    @@ -202,21 +202,17 @@ function(app, FauxtonAPI, resizeColumns) {
         afterRender: function(){
           $('#primary-navbar li[data-nav-name="' + app.selectedHeader + 
'"]').addClass('active');
     
    -      var menuOpen = true;
           var $selectorList = $('body');
    -      $('.brand').off();
    -      $('.brand').on({
    +      this.$('.burger').off();
    +      this.$('.burger').on({
             click: function(e){
    -          if(!$(e.target).is('a')){
                 toggleMenu();
    -          }
    -        }
    +         }
           });
     
           function toggleMenu(){
             $selectorList.toggleClass('closeMenu');
    -        menuOpen = $selectorList.hasClass('closeMenu');
    -        this.resizeColumns.onResizeHandler();
    +        app.windowResize.onResizeHandler();
    --- End diff --
    
    app doesn't exist in this context. I think you mean this.resize because 
this.resize is defined in the initialize function.
    
    
    the reason this.resizeColumns.onResizeHandler(); wouldn't work inside this 
toggle menu function is that it's context is outside the function. 
    
    toggleMenu's context (this) doesn't have a variable called resizeColumns.
    
    If you move toggleMenu out into the view's object, then it will have access 
to this.resizeColumns because it shares a context with it.
    
    
    But in future, if you ever come across this kinda thing,  you can always 
pass a context into a JS function using .call() or .apply()  or if you don't 
want to execute the function yet, you can use underscore's _.bind() method. 
    
    An example so you know what I mean:
    
    var  foo = { 
           name: "sue"
    };
    
    function sayName(greeting){
        return greeting+" "+this.name;
    };    
    sayName.call(foo,"hi");
    
    



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to