How they turn to an object from a cult method



  • I can't describe it pretty, so I'd better show you the example.
    In the example below, this will refer to DOM the element from which the event worked.
    How, in that case, to access an object without knowing his name.

    object = {
    
    method : function(){
        this
    }
    

    };

    myObject = Object.create(object);

    $('someone').click(myObject.method)



  • object = {
    
        method : function(obj){
    
            console.log($(obj).attr('class'));
        }
    
    };
    
    myObject = Object.create(object);
    
    
    $('.class').bind('click',function(){myObject.method(this);});
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2