couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deathbearbrown <>
Subject [GitHub] couchdb pull request: COUCHDB-2215 Update primary nav.
Date Mon, 31 Mar 2014 20:38:16 GMT
Github user deathbearbrown commented on a diff in the pull request:
    --- 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(!$('a')){
    -          }
    -        }
    +         }
           function toggleMenu(){
    -        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+" ";

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

View raw message